3

My problem is almost identical to the one in question 74681, but with a notable exception: I can run latex for a 1000 times or more, it will still say "Table widths have changed. Rerun LaTeX". A minimum test case to reproduce this is here:

\documentclass{letter}

\usepackage[T1]{fontenc}
\usepackage{ltxtable}
\usepackage{filecontents}

\begin{filecontents}{\jobname.ltxtable.tex}
\begin{longtable}[c]{r|r|l|l|X|r|r}
    pos. &
    date &
    \multicolumn{2}{|l|}{quantity} &
    description &
    item price &
    net price
\endhead
\endlastfoot
    1 &
    02.10. &
    1 &
    piece &
    testitem testitem &
    50,00 E per piece &
    50,00 E
\end{longtable}
\end{filecontents}

\begin{document}

\LTXtable{17cm}{\jobname.ltxtable.tex}

\end{document}

Please note that the problem is gone if I change the word "quantity" to either something shorter (e.g. "qty.") or to something longer (e.g. "quantity quantity"), but this is of course not a solution for the generic case (actually files like this are processed automatically and the message "Rerun LaTeX" should trigger a rerun of LaTeX which would trigger an endless loop right now).

I hope this can't be simply bad luck - but what did I miss?

Edit: Unfortunately, the problem still persists. Today it hit me within a document I could reduce to

\documentclass{letter}

\usepackage{ltxtable}
\usepackage{filecontents}

\usepackage{dcolumn}
\newcolumntype{d}[1]{D{,}{\mathord\mathcomma}{#1} }

\begin{filecontents}{\jobname.ltxtable.tex}
\begin{longtable}[c]{r|r@{\,}l|X}
    date            & \multicolumn{2}{l|}{quanti}   & description           \\      
                    &               &               &                       \kill   
\endhead
\endlastfoot
                    & 2             & units         & some descriptive text \\ 
\end{longtable}
\end{filecontents}

\begin{document}

\LTXtable{13cm}{\jobname.ltxtable.tex}

\end{document}

Note the kill-ed line in the header as suggested - but the columns still don't match (with the difference being much bigger in the original). What to do now?

8
  • Why do you have an extra column specified which you don't use? And why is d applied to a column which only contains a single integer?
    – cfr
    Oct 2 '16 at 15:34
  • Real bad luck, I'd say.
    – egreg
    Oct 2 '16 at 15:37
  • @cfr these were remainders of the (by far more complex) original, sorry. I removed them now.
    – SlowFox
    Oct 2 '16 at 15:44
  • 17cm is wider than textwidth so this table can not work (it would be better if it didn't loop forever but what output do you want for this input) Oct 2 '16 at 15:51
  • @DavidCarlisle I added \usepackage[a2paper]{geometry} so the textwidth is much wider than 17cm, the problem remains.
    – egreg
    Oct 2 '16 at 15:52
2

er it's a hidden feature sorry. A simple workaround is to make sure that your headings don't end with a multicolumn row (for example by adding a \kill row)

enter image description here

\documentclass{letter}

\usepackage[T1]{fontenc}
\usepackage{ltxtable}
\usepackage{filecontents}
\usepackage{icomma}
\usepackage[a2paper]{geometry}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{,}{\mathord\mathcomma}{#1} }

\begin{filecontents}{\jobname.ltxtable.tex}
\begin{longtable}[c]{r|r|d{1}|l|X|r|r|r}
    pos. &
    date &
    \multicolumn{2}{l|}{quantity} &
    description &
    item price &
    net price
    \\
&&&&&&\kill
\endhead
    1 &
    02.10. &
    1 &
    piece &
    testitem testitem &
    50,00 E per piece &
    50,00 E
     \\

\end{longtable}
\end{filecontents}

\begin{document}

\begin{center}\rule{17cm}{1cm}\end{center}

\LTXtable{17cm}{\jobname.ltxtable.tex}

\end{document}
6
  • I don't really understand what I am doing here... but it works. Thanks.
    – SlowFox
    Oct 2 '16 at 16:18
  • An update to the documentation that unhides the bug, er, feature is needed.
    – egreg
    Oct 2 '16 at 16:23
  • @egreg no point in documenting it, if I do anything I'll remove the feature. Oct 2 '16 at 16:30
  • @DavidCarlisle unfortunately, the problem popped up again (like shown in the second example)
    – SlowFox
    Nov 16 '16 at 19:19
  • @SlowFox hmm need to think about that, seems like a fundamental flaw in ltxtable's logic;-) mostly around the code documented with the not very encouraging comment % |\multicolum| A sad tale, For now just stop |longtable| messing with it, so that |tabularx| can mess with it. If you add more text the problem may just go on its own accord, or you could try ltablex package instead (a different merger of tabularx and longtable) or to be honest in a hand written document (as opposed to automated database dumps) I would just use longtable with fixed size p columns that I choose by hand. Nov 16 '16 at 19:52

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.