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:


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:


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:

[!NOTE] --compile and --emacs represent different integration paradigms and cannot be combined. --emacs emits raw AUCTeX parenthesis file-tracking blocks (TeX-command-list), while --compile formats output for the GNU compile command (M-x compile). Passing both results in an exit status of 2.