TeX - LaTeX Asked on February 6, 2021
I have the problem that I get an error when compiling the MWE (which makes not much sense by itself). I follow the solution from David.
documentclass[a4paper,11pt]{article}
usepackage[shorthands=off,bidi=basic,english, ngerman]{babel}
usepackage{enumerate}
usepackage{ltablex}
keepXColumns
usepackage[font=small, format=hang]{caption}
begin{document}
begin{tabularx}{textwidth}{ X X }
multicolumn{2}{>{hsize=dimexpr2hsize+2tabcolsep+arrayrulewidthrelax} X }{
begin{tabularx}{textwidth}{ X X }
A & B
end{tabularx}
}
begin{itemize}
item One item
end{itemize}
& ABD
end{tabularx}
end{document}
When compile the above construct I get TeX capacity exceeded, sorry [input stack size=5000]. end{tabularx}
Any ideas how to solve this issue?
The column specification
>{hsize=dimexpr2hsize+2tabcolsep+arrayrulewidthrelax} X
is fundamentally flawed. (The +arrayrulewidth
part is wrong from a purely computational point of view (since your tables don't feature vertical bars), but it doesn't cause the error exception.) Replace the column specification with
p{dimexprtextwidth-2tabcolseprelax}
Why the claim of fundamental misspecification? The tabularx
package allows users to specify unequal columns widths for columns of type X
. However, several sanity checks have to be satisfied. First and foremost, the sum of the relative column widths has to sum to the number of columns of type X
. E.g., for a tabularx
enviroment with 2 columns of type X
, >{hsize=1.333hsize}X >{hsize=0.667hsize}X
is fine since 1.333+0.667=2
. Observe that your code does not achieve 2hsize
; instead, it achieves 2hsize+2tabcolsep+arrayrulewidth
. This discrepancy alone should tip you off to the fact that something is wrong. The fundamental mistake you're making, then, is that you're trying to use a single column of type X
in the second argument of multicolumn
. Hence my suggestion to use a single column of type p
.
Next, the overall width of the "inner" tabularx
environment is wrong. Replace
begin{tabularx}{textwidth}{ X X }
with
begin{tabularx}{hsize}{XX}
Why? By construction, textwidth
exceeds hsize
by 2tabcolsep
.
Last but not least, don't forget to insert noindent
immediately before the first, or "outer", tabularx
environment -- unless you want to be be bombarded with warning messages that the tabularx
environment is too wide.
The following code compiles. That said, I'm certain that it'll ever win a prize for code beauty. For the life of me, I cannot fathom the purpose of the nested tabularx
environments. I would never code anything like that in my own LaTeX working papers.
documentclass{article}
usepackage{tabularx}
begin{document}
noindent % <-- very important
begin{tabularx}{textwidth}{XX}
multicolumn{2}{ p{dimexprtextwidth-2tabcolseprelax} }{
begin{tabularx}{hsize}{XX}
A & B
end{tabularx}
}
begin{itemize}
item One item
end{itemize}
& ABD
end{tabularx}
end{document}
Answered by Mico on February 6, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP