11

This might be a simple or out of place question, but I have run into so many subtleties of document compilation, that I really just need to understand this from the ground up.

Could someone please explain to me what a standard LaTeX compile chain / chain of events / latex make works? I'd also like to know where font-loading fits in, when tikz gets run, labels get assigned, why pdflatex vs latex etc.

I've seen some online references to 2 * latex, 1 * bibtex, 1 * latex, but I'm looking for a diagram to explain to me how this works, or a reference that explains this in-depth, so I can debug this myself on the command line, instead of being annoyed by an editor with insufficient error message (Process started,Process exited with error(s))

This may sound like a very basic question, but I need an answer - as trying to fix this caused almost a day of writing downtime that could hopefully be avoided in future, if I had a causal chain I could check. My apologies for not doing everything through the CLI to begin with.

6
  • 2
    Are you running just 'LaTeX' or some 'build script' (there are several, for example latexmk, rubber, ...)
    – Joseph Wright
    Commented Jun 27, 2013 at 14:46
  • Currently using TexMaker with default F1 quickbuild. The thing is, everything worked until this morning. Then bibtex just broke. On deleting all temp files and running it on a 'clean' folder, I still get the same problem. I've tried rubber (last half hour) and now the document compiles and the references work, I still want to know what broke, as nothing in my lubuntu system changed as far as I know. Understanding the compile chain better, I can access the logs or aux files myself and debug this if a situation like this ever comes up again. Commented Jun 27, 2013 at 14:53
  • So it looks like rubber runs bibtex once, and then latex twice on my clean doc, I still have no idea why this doesn't work in TexMaker anymore. Commented Jun 27, 2013 at 14:54
  • 1
    Perhaps see Understanding how references and labels work (for \label-\ref) and Question mark instead of citation number (for citations/bibliographic references).
    – Werner
    Commented Jun 27, 2013 at 19:22
  • delete all temp files, run latex once or twice then run bibtex from the terminal. texmaker sadly does not deliver the complete output from bibtex. after that you should see where the problem is. might just be that you use a citation style which does not cover the type of document you are trying to cite. Not all styles will handle patents and websites ect.
    – nonsense
    Commented Jun 27, 2013 at 21:42

1 Answer 1

11

The standard LaTeX 'recipe':

  1. latex <filename>
  2. bibtex <filename>
  3. latex <filename>
  4. latex <filename>

comes about as follows. During the first run, there is only the .tex file. During the run, LaTeX writes any citation keys and \label information to the .aux file. BibTeX then reads the .aux file and extracts the citations, looks those up in the .bib file(s) and writes the formatted references as a .bbl file. The second LaTeX run reads the .aux file as well as the .tex file, and is able to use this to resolve cross-refs. It also reads the .bbl file, which inserts the references into the output and also sets up the necessary information for the final LaTeX run to put the citation labels (numbers, author-date, ...) into the output.

Life gets more complex in some cases, as it's possible that additional LaTeX or BibTeX runs are needed, for example if there are multiple bibliographies, citations inside references, etc. Thus there are a number of ways support tools try to detect whether more runs are needed. These are broadly either (1) a fixed 'recipe' or (2) looking for changes in the .aux and other 'derived' files.

If your editor is failing to pick up the need to run BibTeX, and it normally does, then either the 'recipe' is corrupted or the scripts it uses are missing something in the auxiliary files. The detail will depend on the exact tool you use.

3
  • 1
    With the insertion of (say) [123] for a citation in run 3 or 4 (as opposed to [??] during run 1 could also lead to a change in the paragraph layout, possibly causing a (completely) different page layout which, in turn, affect (page) references, which requires a recompile (see Document requiring infinitely many compiler passes? for some reference).
    – Werner
    Commented Jun 28, 2013 at 18:52
  • I've run into the 'infinite passes' problem once doing a 45 degree slanted 'draft' watermark. Thanks for the reference. Commented Jul 1, 2013 at 10:26
  • I'm using rubber with custom build scripts that tie in git data and knitr now.It's interesting to think how much there is still to learn about LaTeX Commented Sep 3, 2013 at 10:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .