GarenSidonius / ASU-Dissertation-Template

LaTeX Template for Typesetting Arizona State University Dissertations and Theses
73 stars 35 forks source link

fix: First build requires `-f` option #40

Open thehale opened 1 year ago

thehale commented 1 year ago

The README.md states the following:

(Don't use the -f option all the time; it seems to be necessary to get the first run to complete successfully at the moment.)

The issue appears to be the use of \tottab and \totfig which are only defined on the second and subsequent runs of latexmk. This undesirable behavior is discussed on a TeX StackExchange question where the accepted answer uses a substantially similar block of code for counting tables/figures.

A later answer recommends the use of the newer totalcount package which counts the tables/figures as expected on the first pass of latexmk.

Here are the key commands from the totalcount documentation:

\usepackage[figure,table,xspace]{totalcount}

% The following commands are added to the project
\totalfigures  % The number of figures in the document
\totaltables % The number of tables in the document

\iftotalfigures
  % Macros placed here only execute if there is at least one
  % figure in the document
\fi

\iftotaltables
  % Macros placed here only execute if there is at least one
  % table in the document
\fi

Replacing \totfig and \tottab with their totalcount counterparts in my local copy of the dissertation template has enabled latexmk to compile the document in a clean workspace without the need for the -f option.