I have this table definition as part of a invoice


It worked fine for years until I have a very short word in the X column for the first time. Now my table is very small in width and centered horizontally on the page.

In my expectation the X column should fill up all space until the width of the table reaches the width of the page except the margins.

I have read about workarounds specifying something like 1.2\textwidth, but I don't like that, because the table is a template included via \include, so it would affect all my invoices.

I also tried \linewidth, \hsize and \columnwidth, but everything results in the same layout.

Is there a way to make the only X column expand so that it uses all available space?

Actual and expected output

Complete included table definition (Rechnungstabelle.tex):

vielen Dank für Ihren Auftrag.
\bf{Anzahl} & \bf{Bezeichnung} & \bf{Einzelpreis} & \bf{Gesamtpreis} \\%
& \bf{Rechnungsbetrag}  & & \bf{\EUR{#2}} \\%
\ifthenelse{\equal{#3}{}}{}{& Enthaltene MwSt. 19\% & & \EUR{#3} \\}%
\ifthenelse{\equal{#4}{}}{}{& * Enthaltene MwSt. 7\% & & \EUR{#4} \\}%

Changing the table header row to

\bf{Anzahl} & \bf{Bezeichnung} \hspace{\textwidth} & \bf{Einzelpreis} & \bf{Gesamtpreis} \\%

is a workaround, but I don't think that would be good TeX style.

Minimum example for reproducing:

\documentclass[ fontsize=12pt, 


    1,0 h & Do something & \EUR{99,00} & \EUR{99,00} \\ 

2 Answers 2


ltablex is the culprit here, as it modifies the tabularx environment. If you're not using it, remove it, or consider ltxtable which provides similar functionality using a different environment.

You may be interested in the following definition of \Rechnungstabelle (note the paragraph break before \noindent):

% https://tex.stackexchange.com/a/58638/5764
  \if\relax\detokenize{#1}\relax % H. Oberdiek

  vielen Dank für Ihren Auftrag.

    \textbf{Anzahl} & \textbf{Bezeichnung} & \textbf{Einzelpreis} & \textbf{Gesamtpreis} \\%
    & \textbf{Rechnungsbetrag}  & & \textbf{\EUR{#2}} \\%
    \ifemptyarg{#3}{}{& Enthaltene MwSt. 19\% & & \EUR{#3} \\}%
    \ifemptyarg{#4}{}{& * Enthaltene MwSt. 7\% & & \EUR{#4}}%

I've dropped the use of \ifthenelse (see Why is the ifthen package obsolete?) and used \ifemptyarg from Different command definitions with and without optional argument.

  • Also \par should be added before \noindent.
    – egreg
    Commented Apr 24, 2014 at 23:30
  • More detailed answer than I expected. Thanks for all the additional tipps and obsolete hints. Commented Apr 25, 2014 at 5:54

You can fix it with the \keepXColumns command provided by ltablex itself (rtfm ;-) )

Another feature that has been added is to treat the X columns like l columns if the table contents would allow that to happen without exceeding the specified width of the table. In other words, the specified width is treated as the maximum allowed and not the exact width of the table. This feature is the default but can be disabled (or enabled) with \keepXColumns (or \convertXColumns).

Best, Chris


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .