Graphics, Figures & TablesVariable Table Heading Width

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
fpires
Posts: 15
Joined: Wed Dec 23, 2015 7:10 pm

Variable Table Heading Width

Post by fpires »

Hello, everyone!

The question is: how could I set the width of a table heading, in order that it is no longer than the width of the table under it? I would like to use the solution commands in different tabular environments, so each table would have a different width, depending on its contents. I have in mind using \parbox with a given width for the table heading that should be equal to the value of the table width, but how to know the table width? For example:

Code: Select all

\begin{table}
\begin{center}
\parbox{width?}{\caption{Table Heading}}
\begin{tabular}{ccc}
a & b & c 
\end{tabular}
\end{center}
\end{table}


Is it possible to know the value of the table width, in order to set this same value in the {width} field of \parbox?

Thank you all in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply