reddit / emacs

Setting AuXTeX to run latexmk

FranekW · 2022-06-26 12:02
Hi, I am trying to make AuCTeX to run `latexmk` as a default engine. I configured `.latexmkrc` in a home folder, so `lamtexmk <file>` in command line compiles everything as expected. After short consulting with AuCTeX website, I added the following lines in to `~/.emacs` ;; AUCTEX (eval-after-load "tex" '(add-to-list 'TeX-command-list '("LaTeXmk" "latexmk %s" TeX-run-command t t :help "Run LaTeXmk") t)) which let me choose `LaTeXmk` from other alternative rules. Everything would work but I want `latexmk` to be the default program. Not sure about it but it seems `TeX-command-default` should be set to one of the entries from `TeX-command-list` which I did in the following line (setq TeX-command-default "LaTeXmk") It doesn't seem to work. Now, the default rule is not even `LaTeX` when I press C-c C-c but `View`. What am I doing wrong? Thanks for any help.
idspispopd0 · 2022-06-26 18:03
Apparently `M-x TeX-command-run-all` or the shortcut `C-c C-a` (the shortcut doesn't work for me) repeats commands as necessary like `latexmk`: https://tex.stackexchange.com/a/426233 https://www.gnu.org/software/auctex/manual/auctex.html#One-Command-for-LaTeX_002c-helpers_002c-viewers_002c-and-printing Do you have particular customizations in your `.latexmkrc` that `TeX-command-run-all` doesn't cover?
kunht · 2022-06-26 22:45
`TeX-command-default` should be set in the mode hook, i.e., (add-hook 'LaTeX-mode-hook (lambda () (setq TeX-command-default "LaTeXmk"))) (*edit: add the missing parenthesis at the end.*) because of this line: http://git.savannah.gnu.org/cgit/auctex.git/tree/latex.el#n7261. You got `View` probably because the document was up to date. AUCTeX does some smart things to pick the "next" command. When the document is up to date, the next thing you want to do probably is to view it -- that is what AUCTeX thinks. ----- FWIW, you may want to check https://github.com/tom-tan/auctex-latexmk. It integrates better with AUCTeX in some aspects, e.g., error reporting.
FranekW · 2022-06-27 10:09
I tried to use auctex-latexmk before. After installing from MELPA and following the instruction to add the two lines from website you linked, Emacs complains with the warning Warning (initialization): An error occurred while loading '~/.emacs’: File is missing: Cannot open load file, No such file or directory, tex-buf There is the [open issue](https://github.com/tom-tan/auctex-latexmk/issues/44) about it. Someone has suggested an issue but I don't know where to make the changes. EDIT.Your snippet is working. Thanks! However, it has a missing bracket. I managed to figure out that one ;) I was also wondering if I need to add a hook for a viewer because PDFs are placed in a subfolder \`out/\`, so are all auxiliary files. I configured \`latexmk\` to do so. Thanks
FranekW · 2022-06-27 10:32
Neither \`C-c C-a\` nor \`TeX-command-run-all\` works for me. I am quite a novice in terms of Eamcs, although had a couple of attempts. I am in the middle of learning Lisp etc. but that answer is still hard to comprehend. I guess in a couple of weeks I'll be better. So, later I'll come back to this answer. Thanks.
kunht · 2022-06-27 14:31
Uh yes, `auctex-latexmk` has an unresolved issue with the latest AUCTeX. Before the proposed patch is applied it may not work. For the snippet, thanks for catching the missing parenthesis. I have added it. For the output directory, there is a variable `TeX-output-dir` for this. You may set it as a [file local variable](https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html).
[deleted] · 2022-07-08 22:06
[removed]