[Tex/LaTex] How to obtain width of longtable

longtabletableswidth

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?

Best Answer

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

\noalign{\begingroup
\setlength\TPTL@width{0pt}
\renewcommand\LT@entry[2]{\global\advance\TPTL@width by ##2}
\@nameuse{LT@\roman{LT@tables}}
\endgroup}  

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

Related Question