Hot answers tagged

34

This procedure will set up Emacs, AUCTeX, and the Okular viewer to handle integrated forward and inverse search. (These instructions were tested on a Debian system) Install Emacs. To install Emacs, open up the terminal and type the command: sudo apt-get install emacs Install AUCTeX. Within Emacs, run M-x package install RET auctex RET. To test for a ...


32

Note: users on more recent versions of macOS will not be able to follow these instructions due to new restrictions introduced in those versions. See comments for workarounds. It seems that the upgrade wiped the link from your Library (where MacTeX puts your actual TeX distribution) into your /usr/texbin. You can reinstate this link with the following: ln -...


27

Stick point somewhere near \usepackage{array,colortbl} and two buffers will open up for array and colortbl packages if you do M-x getpackage which you can bind to a key of your choice (defun getpackage () (interactive) (search-backward "\\") (re-search-forward "usepackage[^{}]*{" nil t) (while (looking-at "\\s-*,*\\([a-zA-Z0-9]+\\)") (re-search-forward "\...


26

Starting from version 11.88 of AUCTeX, you can add an option to the TeX processor with the file-local variable TeX-command-extra-options: %%% TeX-command-extra-options: "-shell-escape" As explained in the manual, you have to manually make this variable safe as a local variable because of the security holes it can open. Note: this question inspired me to ...


25

This should work (requires AUCTeX and you first need to enable TeX-fold-mode with C-c C-o C-f or M-x TeX-fold-mode) (defun mg-TeX-fold-brace () "Hide the group in which point currently is located with \"{...}\"." (interactive) (let ((opening-brace (TeX-find-opening-brace)) (closing-brace (TeX-find-closing-brace)) priority ov) (if (and ...


22

AUCTeX 11.89 Starting from this version of AUCTeX, the option TeX-file-line-error enables by default the file:line:error messages that solve the problem. Thus, from this version you shouldn't run anymore into this kind of problems. I also suggest to revert any change to LaTeX-command-style, in order to be sure to use the default value. See below for ...


22

AUCTeX parses the output buffer in order to report errors and warnings, and if there is none of them, it looks for a line like LaTeX2e <date> However, since April 2017, the date format of LaTeX has been changed from yyyy/mm/dd to yyyy-mm-dd and your version of AUCTeX can't find the line LaTeX2e <2017-04-15> This has been already fixed ...


19

The general problem of finding where a command is defined has no viable solution. Macros can and do change their meaning; a typical example is \\. This simple document \documentclass{article} \begin{document} \show\\ {\centering\show\\} \begin{tabular}{c} \show\\ \end{tabular} \end{document} gives the following output in the terminal window: > \\=...


18

If all LaTeX files in this directory will use the same engine, then you can set TeX-engine for all of them using Emacs per-directory local variables. Create a file in this directory named .dir-locals.el with the following contents: ((latex-mode (TeX-engine . luatex))) If all LaTeX files in this directory share the same master, then per-directory local ...


17

To skip the selection of the reference style you have to set the variable reftex-ref-macro-prompt to nil, see the RefTeX manual. To do this you can customize that variable or add the following code to your init file: (setq reftex-ref-macro-prompt nil) It has been reported that this solution to use RefTeX with the cleverref package no longer works with ...


17

AUCTeX has autocompletion mechanisms different from most of the other LaTeX editors. In Emacs, when TeX-latex-mode is activated, the sequence Ctrl-c Ctrl-e (the - means that the second key has to be pressed while holding the first, while the space implies the release of both keys before the next combination) opens the mini-buffer dialog interface at the ...


16

Scrolling is not my hobby... For easy navigation use the table of contents inside Emacs. Just type C-c = and Emacs displays it. You can navigate incredibly fast. From the comments, if it does not 'work out of the box,' you can use M-x reftex-mode to turn it on for the current buffer or, to make the change permanent, add the following to your .emacs: ; ...


16

The variable TeX-save-query controls this behavior: User Option: TeX-save-query If non-nil, then query the user before saving each file with TeX-save-document. Add the following line to your init file (setq TeX-save-query nil)


15

Here's what I add to my Preferences.el file (the .emacs equivalent for Aquamacs): (setq LaTeX-verbatim-environments-local '("Verbatim" "lstlisting")) This makes Verbatim and lstlisting behave like verbatim


14

Add the following to your .emacs file: (set-default 'preview-scale-function 1.2) Adjust the value according to your needs.


14

bibtool can sort your .bib file, among many other things. Although I do edit my bibliography file by hand, I don't use it much for this task, because emacs provides a better solution (see the comment by giordano, e.g.). To sort by bibkey, it is as simple as (options are not grouped here for clarity): bibtool -s -i input.bib -o output.bib To reverse sort ...


14

The tex master tells emacs which document to pass to latex. So you can have a section or even just a single equation in a file that is \input into your master document, and when you use C-c C-c or any other command that requires a full document, then the master document will be run.


13

For versions 11.86 and higher,¹ there is also M-x TeX-engine-set RET xetex RET which will make AUCTeX compile that particular file with XeTeX (or xelatex if the file is considered a LaTeX file). Note that this 'setting' will only continue to work so long as emacs is visiting that file. Often useful if you forgot to set the local variables, or you want ...


13

Adding %%% reftex-default-bibliography: ("path/to/bibfile.bib") at the end of my file with other commands related to the file looks better to me.


13

Add at the end of each chapter file %%% Local Variables: %%% mode: latex %%% TeX-master: "THEMAINFILE" %%% End: to point AUCTeX to the main file. Furthermore, (quoting the AUCTeX manual) if you often use \include or \input, you should make AUCTeX aware of the multi-file document structure. You can do this by inserting (setq-default TeX-master nil) ...


12

Add the following code to your init file (eval-after-load "latex" '(TeX-add-style-hook "cleveref" (lambda () (if (boundp 'reftex-ref-style-alist) (add-to-list 'reftex-ref-style-alist '("Cleveref" "cleveref" (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D))))) (reftex-ref-style-activate "...


12

AUCTeX uses bibtex as default bibliography processor. If one activates parsing of LaTeX documents setting the variable TeX-parse-self to t, in source files with an explicit \usepackage{biblatex} line AUCTeX prompts for biber or bibtex processor depending on the value of the variable LaTeX-biblatex-use-Biber, which defaults to t. But until version 11.87, ...


12

Of course AUCTeX is already able to do this out of the box! From the description of LaTeX-math-mode (C-h f LaTeX-math-mode RET): Easy insertion of LaTeX math symbols. If you give a prefix argument, the symbols will be surrounded by dollar signs. Thus, C-u ` t inserts $\tau$ If you want to automatically wrap dollars around the symbol when in text ...


12

Like for any other macro you want to insert in AUCTeX, you should use C-c RET cite RET (or C-c C-m cite RET; for more information about autocompletion in AUCTeX see the quick start or Completion section of the manual). This works also for all other citation macros provided by natbib, biblatex, ect... (\citep, \citealt, \parencite, \textcite, etc...) For ...


11

TeX-fold-mode is here to fold environments and macros (for example replacing \lambda with a Unicode lambda or hiding a long proof). outline-minor-mode is what you need, as you stated in the comments, but you shouldn't have to set the heading levels yourself, AUCTeX should take care of that for you. If the key mapping is a problem to you, the easiest way to ...


11

This is indeed a bug in AUCTeX. To fix it you need to customize TeX-command-list so that the LaTeX entry has the associated command equal to %`%l --jobname=%s %(mode)%' %t which includes an explicit setting of jobname to match that of your current file. The relevant part of the customize buffer looks like this (you need to have opened a tex file, before ...


11

The solution is to override built-in fontification with what you want. You can do that using the font-latex-add-keywords function. For more information about the argument specification, see Fontification of macros in the AUCTeX manual. To change fontification of the macros you mentioned, you can add this to your .emacs: (defun my-font-latex-add-custom-...


11

The Zathura SyncTeX interface has recently changed (I'm using v0.3.2 at time of writing): there is now no -s flag to activate SyncTeX. It might be the case that SyncTeX is active all the time. The SyncTeX support is complicated by two annoying quirks of Zathura: Zathura doesn't accept --synctex-forward if the file is not already open. The Zathura window ...


11

The problem was the PATH variable that Emacs uses (and passes on to shells it runs) is different from the users PATH variable. To customize Emacs' PATH one can use (setenv "PATH" "/usr/local/bin:/Library/TeX/texbin/:$PATH" t) With this change, AucTeX can call the command line programs again. See also this question. Update (Nov 2015): In AucTeX 11.88.9 ...


Only top voted, non community-wiki answers of a minimum length are eligible