[Tex/LaTex] Defining a new key combination in emacs to run Latex

auctexemacs

I want to define a new key combination in my .emacs such that it will directly run the latex command, unlike C-c C-c Ret which gives me different options every time (like view).
I am using xdvik for post processing and I don't need to run the view command each time I compile. Focusing on xdvik rereads the file, so there is no point.

Another problem: is there a way to remove the icon labels, which have been introduced in emacs 24? It is the main reason I am asking the previous question, since I have to go into some sub-menus to click the latex commands because the labels take unnecessary space on the window.

Thanks in advance

Best Answer

You can customize the toolbar with M-x customize-variable tool-bar-style. Pick "images" from the value list and you'll lose all the text labels.

The actual code run by the Latex button is a combination of two functions. You can run it with the following code:

(defun my-run-latex ()
  (interactive)
  (TeX-save-document (TeX-master-file))
  (TeX-command "LaTeX" 'TeX-master-file -1))

Put that in your .emacs, and call it directly with M-x my-run-latex, or bind it to a convenient key:

(defun my-LaTeX-hook ()
 (local-set-key (kbd "C-c C-a") 'my-run-latex))

(add-hook 'LaTeX-mode-hook 'my-LaTeX-hook)

Using local-set-key and running it as part of a mode hook means the new key-combo is only available when you're working on a latex file. When you use a global binding, the key is occupied for all modes, and you don't really need that.

Related Question