4

I am producing lots of tables automatically with Stata (perhaps its useful to know that the top, content and bottom of the table are produced separately and then pasted together into one file I \input}. All of these tables have notes at the bottom which I insert using \multicolumn. In order to get the notes to wrap I need to define a fixed column width which I do in Table 2 below using {p{\linewidth}}. Does anybody have a suggestion how I can limit the width of the second table to the width of the first table?

\documentclass{article}

\usepackage{booktabs}

\begin{document}

% Table 1 
\begin{table}[htbp]
\centering 
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} 
\caption{bla \& table} 
\begin{tabular}{l*{3}{c}} \hline \addlinespace
1 & 2 & 3 \\  
4 & 5 & 6 \\  
7 & 8 & 9 \\  
\addlinespace \hline 
\end{tabular} 
\end{table}



% Table 2 
\begin{table}[htbp]
\centering 
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} 
\caption{bla \& table} 
\begin{tabular}{l*{3}{c}} \hline \addlinespace   
1 & 2 & 3 \\ 
4 & 5 & 6 \\
 7 & 8 & 9 \\ 
\addlinespace \hline \addlinespace 
\multicolumn{3}{p{\linewidth}}{\footnotesize Standard errors in parentheses with
  \sym{*} indicating significance at 10\%, \sym{**} at 5\%, and \sym{***} at 1\%. 
  All reported standard error use the robust or sandwich estimator of variance.} 
\end{tabular} 
\end{table}

\end{document}
  • A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). – Marco Daniel Jun 3 '13 at 17:31
  • Do you mean \multicolumn{3}{@{}p{\linewidth}@{}}{ – Marco Daniel Jun 3 '13 at 17:34
  • Thanks, Daniel. But how does \multicolumn{3}{@{}p{\linewidth}@{}} help me? Doesn't solve the table width problem. – Max Jun 3 '13 at 18:13
  • 1
    The table markup is rather odd, why use \sym rather than a footnote macro and automatic numbering? the table preambles specify 4 columns but they only have 3 columns of data. A package such as threeparttable automates measuring the width of the table and setting table notes to the same width. – David Carlisle Jun 3 '13 at 18:19
  • Wasn't aware of {threeparttable}! Works like magic! Thanks! – Max Jun 3 '13 at 18:36
2

The table markup is rather odd, why use \sym rather than a footnote macro and automatic numbering? the table preambles specify 4 columns but they only have 3 columns of data. A package such as threeparttable automates measuring the width of the table and setting table notes to the same width.

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.