TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer

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

share|improve this answer

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

share|improve this answer

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.

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.