6

I have an application which stores LaTeX documents, and then (when the user clicks on a link) renders them into PDF files to be downloaded or viewed.

This works well in general, but I'm running into a small problem. Sometimes (it's not totally clear to me under what circumstances this happens), when a file is rendered with pdflatex, a warning will be issued:

Table widths have changed. Rerun LaTeX.

And the resulting PDF, although rendered, will be incorrect (namely, column headers seem to be mis-aligned relative to the actual body columns of the table. Doing as the warning instructs, and running pdflatex a second time on the input file, renders the PDF completely correctly (everything aligned properly), with no warnings.

As an example, here is a table which exhibits this problem:

\begin{longtabu}{ r r r r r }
\multicolumn{1}{c}{\textbf{Description}} &
    \multicolumn{1}{c}{\textbf{Available}} &
    \multicolumn{1}{c}{\textbf{Billed}} &
    \multicolumn{1}{c}{\textbf{Current}} &
    \multicolumn{1}{c}{\textbf{Remaining}} \\
\endhead
1 - Foo & \$1,791.04 & \$0.00 &
    \$1,567.16 & \$223.88 \\
2 - Bar & \$58,730.01 & \$0.00 &
    \$19,579.01 & \$39,151.00 \\
Baz & \$6,839.00 & \$0.00 &
    \$0.00 & \$6,839.00 \\
\hline
\textbf{Profit} & \textbf{\$14,255.48} & \textbf{\$0.00} &
    \textbf{\$2,581.85} & \textbf{\$11,673.63} \\
\textbf{Total} & \textbf{\$145,055.13} &
    \textbf{\$0.00} & \textbf{\$25,032.69} & \textbf{\$120,022.44} \\
\end{longtabu}

I suppose there are two ways to answer my question:

  • Am I causing this warning by giving pdflatex some "smelly" input? If so, how should I adjust my code to avoid this issue?

  • Is there some way to tell pdflatex, "just re-run yourself if needed, don't tell me about it"? The naive solution to this issue would be to just detect this warning and then re-run pdflatex, but this seems like a very messy way to solve my problem.

It seems that, from e.g. this question, these repeated runs may simply be necessary. In this case, I'd like to make pdflatex do it automatically, rather than having to run it by hand two or more times.

3
  • 4
    that's all standard behaviour of the longtable package. If you use a controlling application such as make or latexmk or arara or emacs or... then it can read the log file for you and re-run latex but latex itself can't Mar 4 '14 at 19:51
  • That's the impression I was getting from reading other questions, but I figured it was worth confirming it before I alter my controlling application to try to detect this situation. Thanks! :) You should add this as an answer.
    – CmdrMoozy
    Mar 4 '14 at 19:59
  • note there is nothing really special about longtable, tables of contents, cross references with \ref, indexes, all require latex to be run more than once. Mar 4 '14 at 21:28
6

That's all standard behaviour of the longtable package. If you use a controlling application such as make or latexmk or arara or emacs or... then it can read the log file for you and re-run latex but latex itself can't.

Note there is nothing really special about longtable, tables of contents, cross references with \ref, indexes, all require latex to be run more than once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.