Tags: /
tex tools
/
I have a tex file (input.tex
) which I need to apply with 6 commands to get the proper pdf output that I need. Here are those commands:
pdflatex -shell-escape input.tex
bibtex input.aux
pdflatex --shell-escape input.tex
pdflatex --shell-escape input.tex
makeglossaries input
pdflatex -shell-escape input.tex
That's a lot of commands to run. Could write a shell script for that. But then you got to manage a shell script for each tex file. That sounds like some extra work.
Found two tools that help avoid the extra work: latexmk and arara.
(Came across both for the first time while reading Dr. Nicola L. C. Talbot's Using LaTeX to Write a PhD Thesis which I found quite helpful.)
In my case,
-shell-escape
is needed in pdflatex
commands for minted
environments.bibtex
for managing cross-references.makeglossaries
for handling glossary entries.latexmk means complete automation. We needn't do anything. Needn't even give any hints to let the tool know which all commands need be run. latexmk
will figure out the dependencies and act accordingly by making use of information available in log files.
We can use configure files to change the default behaviour of latexmk
by making a latexmkrc
or .latexmkrc
file whose contents essentially seem to be Perl. This is because latexmk
is written in Perl (and hence needs a system with Perl installed to run).
In my case, default configuration would suffice. All that needs to be done is
latexmk -shell-escape input.tex
That's it. Down to a single command from 6 different ones!
latexmk
, like make
, can also figure out when the build is upto date so that it won't run the commands if the source files haven't changed after the last build.
latexmk
might run more commands than needed sometimes, as mentioned by the creator of latexmk
himself in this post. But that doesn't affect the output. And that's probably a small price to pay for the kind of automation latexmk
offers.
Unlike latexmk, arara doesn't do 'full' automation. It does as the user tells it to do.
In my case, I need to put the following 'magic comments' at the beginning of the input tex file (even before the preamble):
% arara: pdflatex: { shell: yes}
% arara: bibtex
% arara: pdflatex: { shell: yes}
% arara: pdflatex: { shell: yes}
% arara: makeglossaries
% arara: pdflatex: { shell: yes}
% Now the 'real' source
\documentclass{report}
\usepackage{minted}
... ...
and then we can use
arara input.tex
and we get a description of what happened as output:
__ _ _ __ __ _ _ __ __ _
/ _` | '__/ _` | '__/ _` |
| (_| | | | (_| | | | (_| |
__,_|_| \__,_|_| \__,_|
\
Processing 'input.tex' (size: 45.2 kB, last modified:
12/23/2021 21:58:14), please wait.
(PDFLaTeX) PDFLaTeX engine .............................. SUCCESS
(BibTeX) The BibTeX reference management software ....... SUCCESS
(PDFLaTeX) PDFLaTeX engine .............................. SUCCESS
(PDFLaTeX) PDFLaTeX engine .............................. SUCCESS
(MakeGlossaries) The MakeGlossaries software ............ SUCCESS
(PDFLaTeX) PDFLaTeX engine .............................. SUCCESS
We inform arara
about the commands that need be run by means of comments placed within the source tex file and arara
does that. Nothing more, nothing less. User has complete control over the commands being done. arara
does no guesswork.
In this example, I only needed rules which are available in arara
by default (stuff like pdflatex
, makeglossaries
in the 'magic comments' are the rule names for arara
). We can also make our own rules as needed. See here for an example.
arara
uses JVM (Java Virtual Machine) and needs Java runtime environment installed to run.
—-