Emacs & AUCTeX Integration with latex_it
latex_it has dedicated support for GNU Emacs and the AUCTeX package via the --emacs flag.
Why --emacs?
Standard latex_it formats diagnostics with colored borders, box frames, and source snippets designed for human terminal reading. However, Emacs and AUCTeX parse compilation buffers using regular expressions expecting standard TeX file tracking ((filename.tex ... )) and line anchors (l.<line>).
Passing --emacs automatically:
- Emits parenthesized file stack markers (
(chapters/intro.tex ... )) that AUCTeX tracks. - Formats error continuation blocks so AUCTeX’s parser can extract the exact source lines.
- Suppresses terminal progress indicators, ANSI escapes, and decorative border lines.
- Reports warnings with standard
LaTeX Warning: ... on input line <line>formatting.
AUCTeX Setup (init.el or ~/.emacs)
To add latex_it as a build command in AUCTeX, add the following to your Emacs configuration:
(eval-after-load "tex"
'(add-to-list 'TeX-command-list
'("latex_it" "l --emacs %t" TeX-run-TeX nil (latex-mode)
:help "Build with latex_it and jump to errors") t))
Setting latex_it as the Default Command
If you want AUCTeX to default to latex_it instead of LaTeX:
(setq-default TeX-command-default "latex_it")
Everyday AUCTeX Workflow:
C-c C-c: Chooselatex_itand pressEnterto compile.C-c \(TeX-next-error`): Jump directly to the offending line for each error or warning.C-c C-l(TeX-recenter-output-buffer): View the full compilation log buffer.
Standard Emacs Compilation Mode (M-x compile)
For Emacs’s built-in compilation-mode (M-x compile, next-error C-x \), use the –compile flag instead of –emacs. The –compile flag outputs diagnostics in strict GNU Coding Standards format (file:line:col: severity: message`) in stream encounter order:
;; In ~/.emacs or init.el:
(add-hook 'latex-mode-hook
(lambda ()
(setq-local compile-command "l --compile")))
Colored Compilation Output
By default, latex_it disables ANSI escape sequences under INSIDE_EMACS=...compile so line numbers match standard GNU compilation regexes cleanly. To enable color in compilation-mode:
;; Enable ANSI colors in compilation buffers
(add-hook 'compilation-filter-hook 'ansi-color-compilation-filter)
;; In latex-mode-hook:
(setq-local compile-command "l --compile --color")
Usage:
M-x compile: Runsl --compile.C-x \(next-error`): Jumps directly to the next diagnostic line.M-p/M-n: Navigate previous and next errors in the compilation buffer.
[!NOTE]
--compileand--emacsrepresent different integration paradigms and cannot be combined.--emacsemits raw AUCTeX parenthesis file-tracking blocks (TeX-command-list), while--compileformats output for the GNUcompilecommand (M-x compile). Passing both results in an exit status of 2.