I need to create multiple tables of the same width, one of them needs to be a longtable due to spanning multiple pages. I could set the width of all of them to a predefined value. However, I would rather like to take it from the natural width of one of the tables. How could I do this?


Inside the threeparttablex package I use this construction to detect the width from within the table itself

\renewcommand\LT@entry[2]{\global\advance\TPTL@width by ##2}

Then the width is then stored in \TPTL@width globally. It takes a few compilations before it is stable.


Write the longtable into an external file and read it in with \LTXtable:


\begin{tabular}{@{} ccc @{}}\hline
One & Two & Three\\\hline


\begin{longtable}{@{} ccX @{}}\hline
1 & 2 & 3\\\hline



enter image description here


This is a solution without getting the width of one of the table but you may combine it with daleif’s answer.

Short Table:

\begin{tabu} to \mytablen {|XX|}
1 & 2\\
3 & 4\\

Long Table:

\begin{longtabu} to \mytablen {|XX|}
1 & 2\\
3 & 4\\

Note that the {longtabu} is centered by default an that longtable needs to be loaded manually


Similar to daleif's solution, hack into longtable package:



  \def\LT@entry##1##2{\advance#1 by ##2}%


foo & bar \\
1 & 1234567 \\



\getLTwidth gets the last longtable's width and set the variable locally.

  • you don't need threeparttablex in my solution above – daleif Apr 20 '11 at 16:31
  • That's true, I didn't noticed it. The code is still a little different. I use \LT@save@row outside longtable package, and (maybe unnecessary) set the dimension locally. – Leo Liu Apr 20 '11 at 17:21

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.