You are not logged in.

#1 2012-09-29 21:55:18

cheamh
Member
From: Ottawa
Registered: 2012-01-20
Posts: 23

Emacs/Latex Custom Command

Hey everyone,

I am new to emacs. Over the last week I managed to get everything working the way I want it (auctex, auto-complete-auctex, math autocomplete, pdf view...). One thing remains that I can't figure out. After editing a .tex file, I need to do the following:

C-x C-s: Save

C-c C-c: Compile (Here the mini buffer at the bottom says (default latex), I have to press enter for it to compile)

C-c C-v: View (Opens updated pdf)

The question is, can I add something to .emacs, to make all three commands happen in one key combination? And I also can I force emacs to use the default latex compiler without asking me?


Sorry if the question is newbish, I tried many things via googling and sadly have failed!

Here is my .emacs right now:

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(load "yasnippet.el" nil t t)
(load "auto-complete-auctex.el")

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(TeX-PDF-mode t)
 '(custom-enabled-themes (quote (wombat))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'Latex-mode-hook 'auto-complete-auctex)

(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)

(tool-bar-mode -1)

(require 'ac-math)

(add-to-list 'ac-modes 'latex-mode)   ; make auto-complete aware of {{{latex-mode}}}

(defun ac-latex-mode-setup ()         ; add ac-sources to default ac-sources
  (setq ac-sources
     (append '(ac-source-math-unicode ac-source-math-latex ac-source-latex-commands)
               ac-sources))
)

(add-hook 'latex-mode-hook 'ac-latex-mode-setup)

(add-to-list 'load-path "~/.emacs.d")    ; This may not be appeared if you have already added.
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(require 'auto-complete-config)
(ac-config-default)

"I'm not competent to judge. But no doubt he was a great man."...Paul Erdős

Offline

#2 2012-10-01 01:25:25

cheamh
Member
From: Ottawa
Registered: 2012-01-20
Posts: 23

Re: Emacs/Latex Custom Command

Any help guys? There must be some emacs experts around here...

Well one thing that I have been doing now is keeping the pdf open, it updates on C-c C-c, so I don't need that extra step of C-c C-v.

So now, if I can make it implicitly save and then compile with latex by C-c C-c without asking me about either, that would be great.


"I'm not competent to judge. But no doubt he was a great man."...Paul Erdős

Offline

#3 2012-10-01 02:01:15

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 13,826

Re: Emacs/Latex Custom Command

I use emacs and LaTeX.  An expert on either? Yeah, right  smile

I can tell you what I do, and it works very well.  I create a makefile that handles the creation of the pdf.  I open the pdf independently, outside of emacs, using Okular.  From emacs, I invoke the make command rather than latex.  When the pdf is updated, Okular notices and updates itself with the new file.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
You assume people are rational and influenced by evidence.  You must not work with the public much. -- Trilby
----
How to Ask Questions the Smart Way

Offline

#4 2012-10-02 03:29:37

cheamh
Member
From: Ottawa
Registered: 2012-01-20
Posts: 23

Re: Emacs/Latex Custom Command

ewaller wrote:

I use emacs and LaTeX.  An expert on either? Yeah, right  smile

I can tell you what I do, and it works very well.  I create a makefile that handles the creation of the pdf.  I open the pdf independently, outside of emacs, using Okular.  From emacs, I invoke the make command rather than latex.  When the pdf is updated, Okular notices and updates itself with the new file.


Thanks for the suggestion, two questions:

When this compiles, it shows the errors in a terminal seperate from emacs right? Or just saves them to the log file?

And were you able to save file and then run the make command using one key combination?


"I'm not competent to judge. But no doubt he was a great man."...Paul Erdős

Offline

Board footer

Powered by FluxBB