Open weetmuts opened 3 years ago
Thanks for your report, that's ... unexpected. tabularx doesn't really inspect each row at all: it just inspects the column widths chosen by the primitive \halign
for the entire table, and then re-runs if needed. So it's rather surprising that adding a row here makes any difference.
However I can confirm your report I'll need to trace what's happening but I'm currently travelling so may be a few days.
I think it is just unsupported input and not a bug :-) even if tabularx doesn't say so. The problem seems to me that
\multicolumn{2}{X}{...}
makes little sense. As all "X" columns are the same width this makes 2 columns of width X into one column width X. If if puts enough material into "..." you see that it ends up being as wide as the 2 col and the third is empty.
Not tabuluarx sees 48 X initially and it makes some guesses about their width and complains about reaching \maxdimen (there it goes wrong because it doesn't expect the X in the \multicolumn, but as I said I don't think the input makes a lot of sense this way. I would need a different specifier for \multicolumn that kind of says "make me as wide as whatever the spanned columns are and then use a p-column of that width" but not make me an X-column spanning 2 X-columns)
but too late tonight ot think about this further, but in my feeling it is not a bug as such.
After @FrankMittelbach ;s comment you can use
\newcommand{\foo}{%
a & z z z z & w w w w \\ \hline
b & \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep}X|}{x x x x} \\ \hline
}
to make a cell that spans the two X
columns. But it still fails at the same point. Too late to look further now,
Thanks David and Frank! Actually I do know and use the \hsize setting fix, I just simplified the example as much as possible. I found the \hsize setting here: https://tex.stackexchange.com/questions/236155/tabularx-and-multicolumn
As you say, it feels a bit odd to specify an X inside a multicolumn, what happens if it somehow contributes to the calculation of the X column widths.... perhaps there is a way to state the calculated width of the box that will contain the word wrapped cell texts, without using an X?
Here is a more detailed example of what I actually do.
\documentclass[10pt,a4paper]{article}
\usepackage{parskip}
\usepackage{xltabular}
\overfullrule=10pt
\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newcommand*{\spantwo}[1]{\multicolumn{2}{>{\hsize=\dimexpr 2\hsize+2\tabcolsep\relax\raggedright\arraybackslash}X|}{#1}}
\newcommand*{\spanthree}[1]{\multicolumn{3}{|>{\hsize=0.95\textwidth\relax\raggedright\arraybackslash}X|}{#1}}
\newcommand{\foo}{a & $x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0$ & A comment comment comment comment comment. \\ \hline
b & \spantwo{$x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0 \land x>0$} \\ \hline
\spanthree{A comment comment comment comment comment comment comment comment comment comment comment comment.} \\ \hline
}
\begin{document}
\raggedright
\begin{xltabular}{\linewidth}{|l|R|R|} \hline
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
\foo
% \foo % Uncomment this line to break the table.
\end{xltabular}
\end{document}
This issue has been automatically marked as stale because it has not had recent activity.
@FrankMittelbach @davidcarlisle Any luck?
@weetmuts sorry keeping this open haven't had time to analyse this further but there is definitely an issue (I thought the analyse further label stopped the stale bot marking it as stale but apparently not)
This issue has been automatically marked as stale because it has not had recent activity.
@davidcarlisle Thanks! I am still interested in a solution.
This issue has been automatically marked as stale because it has not had recent activity.
I have the same issue when using tabularx in tabularx too many times
\documentclass{book}
\usepackage{tabularx}
\RequirePackage{tabularx}
\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{p{3.5cm}m{1cm}|X|X|X}
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
% uncommenting the following line breaks the table
% a & b & {\begin{tabularx}{0.99\linewidth}[t]{XX} c & d \end{tabularx}} & e & f\\
\end{tabularx}
\end{center}
\end{document}
Interestingly enough, using tabular inside tabularx instead of tabularx inside tabularx results in it working, but then I have problems with alignment
This issue has been automatically marked as stale because it has not had recent activity.
Brief outline of the bug
When using tabularx and having many lines with \multicolumn eventually the rendering breaks down and the cell widths become tiny.
Minimal example showing the bug
Log file (required) and possibly PDF file
Attached files showing the bug and when the final foo is removed, working log and expected pdf output.
WC.show_bug.log WC.show_bug.pdf WC.working.log WC.working.pdf