Hot answers tagged

20 votes
Accepted

How to let AUCTeX open PDF with pdf-tools

Here's my setup, using auctex-11.89 and pdf-tools-20151224.1159: ;; Use pdf-tools to open PDF files (setq TeX-view-program-selection '((output-pdf "PDF Tools")) TeX-source-correlate-start-...
Manuel Uberti's user avatar
9 votes
Accepted

Multiple major modes in one buffer (e.g., python-mode & LaTeX-mode)

MMM-mode (multiple major modes) seems exactly what you're looking for. It is mentionned on the emacs wiki. You need to define a submode class to mix LaTeX and python, specifying that python parts ...
JeanPierre's user avatar
  • 7,363
9 votes
Accepted

Define a new key binding for font (Auctex)

Customize LaTeX-font-list: M-x customize-variable RET LaTeX-font-list RET. Select Math Prefix: for ^C key (the prefix C-c C-f is omitted) and add \mathscr{ to "Math Prefix:" field and } to "Math ...
giordano's user avatar
  • 3,245
9 votes
Accepted

What is "override advice"?

Some information about advices An advice is mainly a method of last resort to customize the behavior of functions defined in other libraries. There are many variants of advice. Examples are: ...
Tobias's user avatar
  • 32.8k
8 votes

Indentation in square brackets

Setting LaTeX-begin-regexp and LaTeX-end-regexp does not help here because inside LaTeX-indent-level-count it searches a backslash before checking the regexp. I got it working by modifying TeX-brace-...
Hebi Li's user avatar
  • 81
8 votes
Accepted

Formatting of usepackage commands in LaTeX document

If you want a command to stay in a line on its own, add it to LaTeX-paragraph-commands: (setq LaTeX-paragraph-commands '("documentclass" "usepackage")) But, honestly, I didn't ever see anyone trying ...
giordano's user avatar
  • 3,245
8 votes
Accepted

How to pass flags to the LaTeX compiler with AUCTeX?

Use TeX-command-extra-options (and check out the manual before asking questions ;-) AUCTeX handles in a special way most of the main options that can be given to the TeX processors. When you need to ...
giordano's user avatar
  • 3,245
8 votes
Accepted

Emacs setup for LaTeX after (use-package) verse

The essential part is to load latex instead of tex, see the first line. (also I did some small cleanups) (use-package latex :mode ("\\.tex\\'" . latex-mode) :bind (:map LaTeX-mode-map ...
jue's user avatar
  • 4,501
8 votes
Accepted

AUCTeX - delete 'other' files like .out, .aux, .log on successful compilation

Actually, you don't need to customize anything. The variable in question is called LaTeX-clean-intermediate-suffixes and has the following default value: LaTeX-clean-intermediate-suffixes is a ...
Arash Esbati's user avatar
  • 1,855
8 votes
Accepted

Surprisingly persistent local variable

In case someone else runs into this, I had enabled TeX-auto-save, which saves settings to an auto/ directory and loads them when a file is revisited. https://www.gnu.org/software/auctex/manual/...
Toothrot's user avatar
  • 3,254
7 votes
Accepted

Trying to install auctex via package-install

Elpa seems to be having issues again. (Reddit discussion.) Maybe try adding (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") to your config as mentioned here.
nega's user avatar
  • 3,166
6 votes

How can I prevent auctex to indent a new environment inside another environment?

Add to your init file (add-to-list 'LaTeX-verbatim-environments "pycode") (add-to-list 'LaTeX-indent-environment-list '("pycode" current-indentation)) See (info "(auctex)Verbatim content") ...
giordano's user avatar
  • 3,245
6 votes

How can I set a key binding to run two other key bindings?

For this special case (save a *TeX buffer before running the compiler), you don't need to define a binding, or advice a function, but just set TeX-save-query to nil: (setq TeX-save-query nil)
giordano's user avatar
  • 3,245
6 votes
Accepted

AUCTeX: how to compile a file, which does end in '.ins'

Known extensions to AUCTeX are controlled by the variable TeX-file-extensions: TeX-file-extensions is a variable defined in ‘tex.el’. Its value is ("tex" "sty" "cls" "ltx" "texi" "txi" "texinfo" "...
Arash Esbati's user avatar
  • 1,855
6 votes

How to make Emacs start using the Xetex engine as default

From AUCTeX's documentation: User Option: TeX-engine This variable allows you to choose which TeX engine should be used for typesetting the document, i.e. the executables which will be used ...
Arash Esbati's user avatar
  • 1,855
6 votes
Accepted

How to create a small bibtex file from a bigger one?

reftex has the command reftex-create-bibtex-file that you can call via the menu Ref -> Global Actions -> Create BibTeX File. I cite the help of reftex-create-bibtex-file here: Create a new ...
Tobias's user avatar
  • 32.8k
6 votes
Accepted

Looking for a way to have LaTeX source code and its real-time rendering in side-by-side Emacs windows

latex-preview-pane on melpa can do that. You can enable it in a file being edited with AUCTeX by M-x latex-preview-pane RET or for any LaTeX file opened in this mode by placing (add-hook 'LaTeX-mode-...
gigiair's user avatar
  • 2,134
5 votes
Accepted

LaTeX Mode and Listings with $-signs?

Syntax highlighting would be correct if file parsing is enabled. First check whether the options suggested at the beginning of the AUCTeX manual are enabled: (setq TeX-auto-save t) (setq TeX-parse-...
JeanPierre's user avatar
  • 7,363
5 votes
Accepted

Why does filling in AUCTeX behave so badly?

The behavior of filling of math switches is controlled by the LaTeX-fill-break-at-separators variable and there are currently discussions about its best default value. I recently came up with with ...
giordano's user avatar
  • 3,245
5 votes
Accepted

delete-selection-mode and $

AUCTeX provides the feature to wrap opening and closing inline equation markers around active region on pressing $, when TeX-electric-math is non-nil (and this isn't the default). In order to have ...
giordano's user avatar
  • 3,245
5 votes

How can I set a key binding to run two other key bindings?

The general way to link multiple key-bindings to a single binding is a Keyboard Macro ((emacs) Keyboard Macros). Keyboard macros can either be 'recorded' interactively, or written in elisp (in string ...
Tyler's user avatar
  • 21.9k
5 votes
Accepted

Inform AucTeX about index style file

Very good question, it's strange that no one ever asked for this feature. Luckily, AUCTeX allows you to expand it with a bit of Lisp code. The trick is to add a new command to TeX-command-list and a ...
giordano's user avatar
  • 3,245
5 votes
Accepted

How to perform a search for a string inside math environments in a tex/latex document

Bundled with AUCTeX there is the texmathp utility (which, however, is independent from the TeX modes provided by AUCTeX and can be used without it), which allows you to test whether point is inside a ...
giordano's user avatar
  • 3,245
5 votes

How do I configure my own shortcuts in Auctex (Emacs)?

Here is an example of what you want to accomplish: (with-eval-after-load "latex" (define-key LaTeX-mode-map (kbd "s-z") (lambda () (interactive) (LaTeX-insert-environment "quote"))) ...
giordano's user avatar
  • 3,245
5 votes
Accepted

Fix indentation of LaTeX code without wrapping lines

If you only want to indent a region, you should call an indenting function, not a filling function that, as you guessed, is meant to break lines. For example, you can use C-M-\ (M-x indent-region RET)...
giordano's user avatar
  • 3,245
5 votes
Accepted

Setting MUpdf as default viewer in AUCTeX

Here is (I think) the simplest way to do this. The first adds mupdf as a new view program, while the second specifies it as the default for pdfs. (with-eval-after-load "tex" (add-to-list 'TeX-view-...
justbur's user avatar
  • 1,510
5 votes

Call emacsclient from a program called by Emacs

The solution is to run texdoc within an asynchronous process. The best way to do that is probably to use start-file-process instead of shell-command-to-string (which is a handy function for quick&...
Stefan's user avatar
  • 26.3k
5 votes
Accepted

How can I type simple underline "_" in Auctex

You can always insert a character literally by typing C-q first (quoted-insert). Many “electric” characters (that's what Emacs usually calls characters whose insertion has extra effects such as ...
Gilles 'SO- stop being evil''s user avatar
5 votes
Accepted

Don't switch to math-mode when entering `$` in a `minted` environment

You can add minted environments to the latex-verbatim-environment variable: M-x customize-variable latex-verbatim-environments, insert a new string "minted", and save your changes. You may need to ...
Tyler's user avatar
  • 21.9k
5 votes
Accepted

AUCTeX doesn't run bibtex even though .emacs file is set up appropriately

For some reason, the file wasn't actually parsed, so AUCTeX didn't know about the bibliography file. This shouldn't usually happen if you set TeX-parse-self and TeX-auto-save to t, but you can easily ...
giordano's user avatar
  • 3,245

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