8

I am trying to create a fairly thin table with wider caption and wider note than the body of the table itself. My aim is not to make the table simply wider, since this makes the table look ugly and the values seem to be lost. Is there a way to solve this problem simple and smooth? Thanks a lot for every comment!

\documentclass[12pt]{article}
\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}


\begin{table}[h]
\centerline{
\begin{threeparttable}
\caption{The is ment to be a very long table caption, which is wider than the table itself.}
\label{table:meanerrorbaseline}

\begin{tabular}{cc}
\toprule
Endowment & Mean error \\ 
\midrule
0         & 1.67       \\
1         & 1.49*      \\
2         & 1.42**     \\
3         & 1.30***    \\
4         & 1.15***    \\
5         & 1.15***    \\
6         & 1.09***    \\
7         & 1.02***    \\
8         & 0.92***    \\
9         & 0.85***    \\
10        & 0.76**     \\
\bottomrule
\end{tabular}

\begin{tablenotes}
  \small
     \item The note is ment to be wider than the table itself, without having to make  the table wider and making it look ugly. 
   \end{tablenotes}
\end{threeparttable}
}
\end{table}
\end{document}
  • I'm having trouble getting your example to compile. Can you make it so that you have \documentclass and \begin/\end{document}? – cslstr Mar 9 '14 at 18:27
  • I have just updated the code and it works now with my compiler. Sry for the mistake! – meierun Mar 9 '14 at 19:07
  • I still had issues with the \centerline command... I changed it over to be a {\centering ...} construct. – cslstr Mar 9 '14 at 19:24
8

I still am having issues with the \centerline command; this isn't the best centering command to use, I'd recommend the \begin{center} environment or {\centering ... } instead.

So the real answer to your question is to use

\renewcommand{\TPTminimum}{\linewidth}

to redefine the minimum amount of space that is used by the caption and the notes in the threeparttable environment. Doing so like this gives a result that, strictly, is what you asked for:

\documentclass[12pt]{article}
\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}


\begin{table}[h]

\begin{threeparttable}
\renewcommand{\TPTminimum}{\linewidth}
\caption{The is ment to be a very long table caption, which is wider than the table itself.}
\label{table:meanerrorbaseline}
{\centering
\begin{tabular}{cc}
\toprule
Endowment & Mean error \\ 
\midrule
0         & 1.67       \\
1         & 1.49*      \\
2         & 1.42**     \\
3         & 1.30***    \\
4         & 1.15***    \\
5         & 1.15***    \\
6         & 1.09***    \\
7         & 1.02***    \\
8         & 0.92***    \\
9         & 0.85***    \\
10        & 0.76**     \\
\bottomrule
\end{tabular}
}
\begin{tablenotes}
  \small
     \item The note is ment to be wider than the table itself, without having to make  the table wider and making it look ugly. 
   \end{tablenotes}
\end{threeparttable}

\end{table}
\end{document}

...it looks like this:

table wide offcenter

Your next logical question would be, "How do I center the table within the caption?" The only recommended solution I could find to this was in Why isn't my table centering with threeparttable?. The answers there either omitted the caption at the top of the table or did not deal with the wide table issue (omitting the \renewcommand{\TPTminimum}{...}). Using the \makebox... solution, we come close to what is desired, but only if the caption is left off, or moved to the bottom:

\documentclass[]{article}

\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}

\begin{table}[h]
\begin{threeparttable}
\renewcommand{\TPTminimum}{\linewidth}
%\caption{The is ment to be a very long table caption, which is wider than the table itself.}
%\label{table:meanerrorbaseline}
\makebox[\linewidth]{%
\begin{tabular}{cc}
\toprule
Endowment & Mean error \\ 
\midrule
0         & 1.67 \\
1         & 1.49*      \\
2         & 1.42**     \\
3         & 1.30***    \\
4         & 1.15***    \\
5         & 1.15***    \\
6         & 1.09***    \\
7         & 1.02***    \\
8         & 0.92***    \\
9         & 0.85***    \\
10        & 0.76**     \\
\bottomrule
\end{tabular}}
\begin{tablenotes}
  \small
  \item The note is meant to be wider than the table itself, without having to make  the table wider and making it look ugly. 
   \end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

Without the caption, this appears as:

wide table, no caption, centered

So how do we get both? The solution I came up with uses extra columns on the sides of the table that pad the table, centering it within the caption. It is a bit of a hack, but it solves the problem in a way that other more elegant solutions cannot.

The code:

\documentclass[]{article}

\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}

\begin{table}[h]
\begin{threeparttable}
%\renewcommand{\TPTminimum}{\linewidth}
\caption{The is ment to be a very long table caption, which is wider than the table itself.}
\label{table:meanerrorbaseline}
\begin{tabular}{cccc}
\cmidrule[\heavyrulewidth]{2-3} % \toprule
~\rule{1in}{0in} & Endowment & Mean error  & \rule{1in}{0in}~ \\ 
\cmidrule[\lightrulewidth]{2-3} % \midrule
& 0         & 1.67 &  \\
& 1         & 1.49*    &   \\
& 2         & 1.42**    &  \\
& 3         & 1.30***  &   \\
& 4         & 1.15***   &  \\
& 5         & 1.15***   &  \\
& 6         & 1.09***   &  \\
& 7         & 1.02***   &  \\
& 8         & 0.92***   &  \\
& 9         & 0.85***   &  \\
& 10        & 0.76**    &  \\
\cmidrule[\heavyrulewidth]{2-3} % \bottomrule
\end{tabular}
\begin{tablenotes}
  \small
  \item The note is meant to be wider than the table itself, without having to make  the table wider and making it look ugly. 
   \end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

This appears as:

wide captions, centered table

5

I would like to follow up on the solution 2/3 from cslstr.

If you put the caption outside the threeparttable- but within the table-environment, than both centering and caption work together without the "hack" from solution 3/3.

The code:

\documentclass[]{article}

\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}

\begin{table}[h]
\caption{The is ment to be a very long table caption, which is wider than the table itself.}
\label{table:meanerrorbaseline}
\begin{threeparttable}
\renewcommand{\TPTminimum}{\linewidth}
\makebox[\linewidth]{%
\begin{tabular}{cc}
\toprule
Endowment & Mean error \\ 
\midrule
0         & 1.67 \\
1         & 1.49*      \\
2         & 1.42**     \\
3         & 1.30***    \\
4         & 1.15***    \\
5         & 1.15***    \\
6         & 1.09***    \\
7         & 1.02***    \\
8         & 0.92***    \\
9         & 0.85***    \\
10        & 0.76**     \\
\bottomrule
\end{tabular}}
\begin{tablenotes}
  \small
  \item The note is meant to be wider than the table itself, without having to make  the table wider and making it look ugly. 
   \end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

Result:

Result

4

The use of threeparttable is no more useful is this case because:

  • it cannot manage correctly wider Notes by default (redefining \TPTminimum is not meant to do that)
  • it Breaks the centering when you hack it to do so.
  • it does not build enumerated note directly (need to add manually reference char for each note)

My own simple solution based on \parbox is:

\documentclass[]{article}
\usepackage{booktabs}
\begin{document}

\begin{table}[h]
\centering
\caption{The is meant to be a very long table caption, which is wider than the table itself.}
\label{table:meanerrorbaseline}
\begin{tabular}{cc}
\toprule
Endowment & Mean error \\ 
\midrule
0         & 1.67       \\
1         & 1.49*      \\
2         & 1.42**     \\
3         & 1.30***    \\
4         & 1.15***    \\
5         & 1.15***    \\
6         & 1.09***    \\
7         & 1.02***    \\
8         & 0.92***    \\
9         & 0.85***    \\
10        & 0.76**     \\
\bottomrule
\end{tabular}
\parbox{\textwidth}{\small%
\vspace{1eX} % If wanted space after the bottomrule
The note is meant to be wider than the table itself, without having to make the table wider and making it look ugly.}
\end{table}

\end{document}

Result:

Code result

remarks:

  • The tabular is not changed.
  • The \parbox width may be adjusted to any wanted values (use \textwidth or \linewidth for better results)
  • Vertical spacing after \bottomrule is set to one 'X' size using \vspace (so it is related to font size). Another solution for spacing after the tabular and before the note may be to use \setlength{\belowbottomsep}{1eX} to change the \bottomrule spacing (warning: active on all figures !)
  • Itemize environnement works fine within parbox, so multiple notes is no issue (but spacing may be removed as itemize start with extra spacing).
  • Just add manually the reference Char (* in the example, but works fine also with upperscripts letters/numbers if needed)
  • 1
    Welcome to TeX.sx! Can you clarify your argument why threeparttable should not be used in your eyes? You can also edit your answer later so there is no need to write "Coming soon". – strpeter Sep 22 '16 at 8:43
0

In this answer, Ulrike Fisher says threeparttable hooks into tabular to get the width of the caption and the notes.

She solved the problem using a surrounding tabular with \parboxes.

Her solution can be applied also here. In your case, it is even more simple to use a surrounding tabularx of the width you like.

For the caption, put it outside the threeparttable as in M. Duck's answer.

\documentclass[12pt]{article}
\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}
\begin{table}[h]\centering
\caption{\label{table:meanerrorbaseline}
The is ment to be a very long table caption, which is wider than the table itself.}
\begin{threeparttable}
\begin{tabularx}{\linewidth}{@{}Y@{}}
\begin{tabular}{cc}
\toprule
Endowment & Mean error\tnote{a}\\ 
\midrule
0         & 1.67       \\
1         & 1.49*      \\
2         & 1.42**     \\
3         & 1.30***    \\
4         & 1.15***    \\
5         & 1.15***    \\
6         & 1.09***    \\
7         & 1.02***    \\
8         & 0.92***    \\
9         & 0.85***    \\
10        & 0.76**     \\
\bottomrule
\end{tabular}
\end{tabularx}
\begin{tablenotes}[flushleft]
  \small\item[a] The note is ment to be wider than the table itself, without having to make  the table wider and making it look ugly. 
   \end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}

enter image description here

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.