0

Actually I need several commands to compile my Latex document:

lualatex -synctex=1 -interaction=nonstopmode -halt-on-error main
biber main
makeindex main
makeindex -s main.ist -t main.alg -o main.acr main.acn
makeindex -s main.ist -t main.glg -o main.gls main.glo
lualatex -synctex=1 -interaction=nonstopmode -halt-on-error main
lualatex -synctex=1 -interaction=nonstopmode -halt-on-error main #not sure if this is really needed

But I noticed that Overleaf can compile the document with a single run... Well, I can't see what Overleaf does in background but I assume it.

Is there a way to compile everything with a single command?

Of cause I can use a Bash script or Makefile. But I'm thinking of a way that also speeds up things. It's very slow to compile the document three times. Maybe there is a single step to build all things in one step.

Michael
  • 195
  • 4
    one word: latexmk (that is what overleaf is using, and me as well on my Linux box) – daleif Oct 17 '19 at 09:54
  • have a look at https://mg.readthedocs.io/latexmk.html – Alessandro Cuttin Oct 17 '19 at 10:34
  • Oh, I remember, I tried it before. But I had issues: ! Package inputenc Error: Unicode char �\lst@EC� (U+9EBC) (inputenc) not set up for use with LaTeX.. I don't have this error when using the bash commands instead. – Michael Oct 17 '19 at 10:50
  • Overleaf has documented its latexmk config: https://de.overleaf.com/learn/how-to/How_does_Overleaf_compile_my_project%3F – Michael Oct 17 '19 at 11:00
  • OK, I tried it again and found the cause. No it's working using latexmk and this config: ```$pdf_mode = 1; @default_files = ('main.tex'); my $texinputs = defined $ENV{'TEXINPUTS'} ? $ENV{'TEXINPUTS'} : ''; $ENV{'TEXINPUTS'}='./tex//:'.$texinputs; $pdflatex = 'lualatex -synctex=1 -interaction=nonstopmode -halt-on-error'; $clean_ext = "acn bbl dvi glo lol upa upb aux synctex.gz run.xml";
    
    
    – Michael Oct 17 '19 at 11:23
  • @daleif latexmk does not work well with makeglossaries. – Foad Jan 24 '24 at 10:09
  • @Foad since when? it works just fine for me. – daleif Jan 24 '24 at 11:35
  • @daleif here is the error message I get Latexmk: Missing input file 'main.acr' (or dependence on it) from following: No file main.acr. when I run latexmk -pdf -outdir=build main.tex – Foad Jan 24 '24 at 12:47
  • @Foad please create your own question with MWE etc instead of highjacking someone elses question. And always test without build dirs, not all programme supports it. – daleif Jan 24 '24 at 13:09
  • @daleif I am not highjacking anything. You left a comment recommending latexmk, and I just pointed out a common issue with this tool for those folks who end up here. For my own work, I have already moved on to ltx2any on WSL2 and have written a small cmd/batch script that runs pdflatex, makeglossaries, and biber consecutively. – Foad Jan 24 '24 at 13:19
  • almost 5 years ago. And as mentioned I have no issues with it. – daleif Jan 24 '24 at 13:30
  • @daleif, could you please run the command latexmk -pdf -outdir=build main.tex on an MWE that includes glossaries and let me know if it still works? – Foad Jan 24 '24 at 13:32
  • @Foad Your earlier comment reads like a new quetion, rather than a comment on daleif's one: I think that's what he's getting at. (And as he says, latexmk is very widely used.) – Joseph Wright Jan 24 '24 at 13:32
  • @Foad Output directory settings are regarded by many experienced (La)TeX users as a disaster – Joseph Wright Jan 24 '24 at 13:33
  • @JosephWright, thanks for the comment. Just for clarification: My comment was not intended to be a new question. I understand that latexmk is a very popular tool, and I know that building folders is widely frowned upon. Yet, coming from a C/C++/CMake background, I can't help but avoid contaminating my project folder with other temporary files. – Foad Jan 24 '24 at 13:38

2 Answers2

2

There are many automation tools which can be split into two categories:

Automatically determine which commands are necessary

  • latexmk
  • ltx2any
  • rubber
  • ...

User gives list of commands

  • arara
  • quick compile from texstudio (user can configure in preferences which commands are run)
  • ...
nuojuk
  • 235
  • But latexmk and ltx2any still run the commands like I'm doing, right? – Michael Oct 17 '19 at 10:57
  • @Michael They will recognise automatically which tools need to be run. If you need any special options for makeindex, see https://tex.stackexchange.com/a/314877/199084 – nuojuk Oct 18 '19 at 15:06
  • AFAIK the only one in this list that can automatically detect what commands must be run is ltx2any. latexmk has lots of issues with makeglossaries. texify does not work with BibLaTeX-biber. With rubber/arara you have to basically program the sequence of the necessary compilers in the headers of your .tex file or a separate configuration file. In that sense, they are no more different than a cmd-batch, PowerShell, or bash script. – Foad Jan 24 '24 at 10:06
1

What you need is arara. Look at documentation:

https://ctan.org/pkg/arara

You can allways put compiling commands into "options" directive. I not entirely sure about the makeindex, but there is a rule to "compile" with it and I am pretty sure that those options you are using will be within arara automatic.