pdflatex not an option anymore in TeX-command-list
Table of Contents
Problem: in .tex files the pdflatex compile option was gone
For years I built tex into pdf with pdflatex; I just hit C-c C-c and there it was. But now having just rebuilt my system with Guix, I find that pdflatex isn’t on the list of compilation commands. This is despite the fact that the command pdflatex
works from the commandline. Does anyone know where it went in auctex, and how to get it back?1
Answer: customize tex-command-list with an obscure string
I learned soon that the place the options came from was populated according to the variable TeX-command-list
. It has an antiquated many-args and obscure-replacement-syntax: ("pdflatex" "%(PDF)%(latex) %T -shell-escape" TeX-run-command nil t :help "Run pdflatex")
I started in the customize menu and played around until I got the answer (consulting TeX-expand-list
to find the right %
invocations), then saved it to my :custom in use-package.
The winning command
pdflatex was already installed and worked from command line, so I just needed to teach emacs auctex to use it. This is the line that the customizer produced.
("pdflatex" "%(PDF)%(latex) %T -shell-escape" TeX-run-command nil t :help "Run pdflatex")
My complete tex use-package
I implemented the customize line in my use-package statement, in order to localize my configuration. Now my whole use-package (straight) looks like this (including many defaults, which I should probably clean out):
(use-package tex-mode
:straight auctex
:mode "\\.tex\\'"
:custom
(TeX-parse-all-errors nil)
(TeX-suppress-ignored-warnings t)
(TeX-command-list
'(("pdflatex" "%(PDF)%(latex) %T -shell-escape" TeX-run-command nil t :help "Run pdflatex")
("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t" TeX-run-TeX nil
(plain-tex-mode texinfo-mode ams-tex-mode)
:help "Run plain TeX")
("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil
(latex-mode doctex-mode)
:help "Run LaTeX")
("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile nil
(texinfo-mode)
:help "Run Makeinfo with Info output")
("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" TeX-run-compile nil
(texinfo-mode)
:help "Run Makeinfo with HTML output")
("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t" TeX-run-TeX nil
(ams-tex-mode)
:help "Run AMSTeX")
("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t" TeX-run-TeX nil
(context-mode)
:help "Run ConTeXt once")
("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" TeX-run-TeX nil
(context-mode)
:help "Run ConTeXt until completion")
("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
(plain-tex-mode latex-mode doctex-mode context-mode texinfo-mode ams-tex-mode)
:help "Run BibTeX")
("Biber" "biber %(output-dir) %s" TeX-run-Biber nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run Biber")
("Texindex" "texindex %s.??" TeX-run-command nil
(texinfo-mode)
:help "Run Texindex")
("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil
(texinfo-mode)
:help "Run Texi2dvi or Texi2pdf")
("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
("Print" "%p" TeX-run-command t t :help "Print the file")
("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command)
("File" "%(o?)dvips %d -o %f " TeX-run-dvips t
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Generate PostScript file")
("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Convert DVI file to PostScript")
("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Convert DVI file to PDF with dvipdfmx")
("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Convert PostScript file to PDF")
("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run makeglossaries to create glossary file")
("Index" "makeindex %(O?idx)" TeX-run-index nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run makeindex to create index file")
("upMendex" "upmendex %(O?idx)" TeX-run-index t
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run upmendex to create index file")
("Xindy" "texindy %s" TeX-run-command nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run xindy to create index file")
("Check" "lacheck %s" TeX-run-compile nil
(latex-mode)
:help "Check LaTeX file for correctness")
("ChkTeX" "chktex -v6 %s" TeX-run-compile nil
(latex-mode)
:help "Check LaTeX file for common mistakes")
("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document")
("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files")
("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files")
("Other" "" TeX-run-command t t :help "Run an arbitrary command")))
:config
(setq TeX-PDF-mode t
TeX-global-PDF-mode t
TeX-auto-save t
TeX-parse-self t
TeX-view-program-list '(("Emacs" "emacsclient %o"))
TeX-view-program-selection '((output-pdf "Emacs"))
LaTeX-command-style '(("" "%(PDF)%(latex) -file-line-error %S%(PDFout)")))
(setq-default TeX-master t) ; All master files called "master".
;(setq TeX-master 'shared) ; shared LaTeX: ask for master file
(defadvice ispell-send-string (before kill-quotes activate)
(setq string (replace-regexp-in-string "''" " " string))))
Footnotes
1 I posed my question on Reddit, but worked out the answer with trial-and-error before any responses came. https://www.reddit.com/r/emacs/comments/w0itea/pdflatex_not_an_option_anymore_in_texcommandlist/