3

The columns are slightly offset from the headers. I've tried playing around with a bunch of things (which is why the code is a bit of a mess now). Any suggestions how to fix this?

\documentclass[11pt]{article}
\usepackage{multicol, booktabs, pbox}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\begin{document}
{
\def\sep{0.5em}
\def\fns{\footnotesize}
\def\onepc{$^{\ast\ast}$} \def\fivepc{$^{\ast}$}
\def\tenpc{$^{\dag}$}
\def\legend{\multicolumn{6}{l}{\footnotesize{Significance levels
:\hspace{1em} $\dag$ : 10\% \hspace{1em}
$\ast$ : 5\% \hspace{1em} $\ast\ast$ : 1\% \normalsize}}}
\begin{table}[!ht]
  \centering
  \ra{1.2}
  \hspace*{-1.5cm}\begin{tabular}{l@{\hspace{1cm}} r @{} l@{\hspace{1cm}} r @{} l@{\hspace{1cm}} r @{} l@{\hspace{1cm}} r @{} l }
    \toprule
    &  \pbox{3cm}{Daily Spending \\ \small (all goods)}& &  \pbox{3cm}{ Daily Spending \\ \small (full tax goods)}& &  \pbox{3.5cm}{ Daily Spending \\ \small (discount tax goods)}&\\[\sep]
    \midrule
    Varvarvarvar  & -0.0168&\onepc & -0.0046& & -0.0191&\onepc \\
    \bottomrule
    \legend
  \end{tabular}\hspace*{-1cm}
\caption{Results for regressions similar to those in Table \ref{regs:Daily}, but at the monthly level rather than daily.   \label{regs:Monthly}}
\end{table}
}
\end{document}

EDIT: code is now working example

Werner
  • 603,163
Craig
  • 155

3 Answers3

3

Rather than fixing the problem with \pbox and similar hacks, here's how I would typeset this table.

First of all, a numeric table should always use siunitx facilities. Second, repeating data is evil.

\documentclass[11pt]{article}
\usepackage{multicol, booktabs, siunitx}

\newcommand\onepc{$^{\ast\ast}$}
\newcommand\fivepc{$^{\ast}$}
\newcommand\tenpc{$^{\dag}$}

\begin{document}


\begin{table}[!ht]
  \centering

\begin{tabular}{ l *{3}{S[table-format=-1.4,table-space-text-post=\onepc]} }
\toprule
  & \multicolumn{3}{c}{Daily Spending on goods} \\
\cmidrule(lr){2-4}
  &  {all} & {full tax} & {discount tax} \\
\midrule
Varvarvarvar  & -0.0168\onepc & -0.0046 & -0.0191\onepc \\
\bottomrule
\multicolumn{4}{l}{\footnotesize
  Significance levels:\quad $\dag$: 10\% \quad $\ast$: 5\% \quad $\ast\ast$: 1\%%
}
\end{tabular}

\caption{Results for regressions similar to those in Table \ref{regs:Daily}, but at the 
monthly level rather than daily.}\label{regs:Monthly}

\end{table}

\end{document}

Note that the table specification says that the three numeric columns share the format: a possible sign -, one digit in the integral part, four in the decimal part and some added space as wide as \onepc.

There is no need to increase \arraystretch, nor to reduce the font size in the headers. The common part is stated as a global header, the specific part typeset as subheaders.

Never leave space in front of colons.

enter image description here

egreg
  • 1,121,712
2

That's because you're setting the heading in a \parbox of pre-specified width. Since you're using a manual line-breaking inside these \parboxes, you might just as well set them in a tabular which will expand to the natural width of the content. makecell simplifies this input:

enter image description here

\documentclass{article}
\usepackage{booktabs,makecell}
\newcommand\ra{\renewcommand{\arraystretch}}
\newcommand\sep{0.5em}
\newcommand\fns{\footnotesize}
\newcommand\onepc{$^{\ast\ast}$} \def\fivepc{$^{\ast}$}
\newcommand\tenpc{$^{\dag}$}
\newcommand\legend{\multicolumn{6}{l}{\footnotesize{Significance levels
:\hspace{1em} $\dag$ : 10\% \hspace{1em}
$\ast$ : 5\% \hspace{1em} $\ast\ast$ : 1\% \normalsize}}}
\begin{document}

\begin{table}[!ht]
  \centering
  \ra{1.2}%
  \makebox[\textwidth]{% http://tex.stackexchange.com/q/39435/5764
    \begin{tabular}{ *{4}{l @{\hspace{1cm}} r @{}} l }
      \toprule
      & \makecell[l]{Daily Spending \\ \small (all goods)} & 
        & \makecell[l]{Daily Spending \\ \small (full tax goods)} & 
        & \makecell[l]{Daily Spending \\ \small (discount tax goods)} & \\[\sep]
      \midrule
      Varvarvarvar  & -0.0168&\onepc & -0.0046& & -0.0191&\onepc \\
      \bottomrule
      \legend
    \end{tabular}}
  \caption{Results for regressions similar to those in Table XX, but at the monthly level rather than daily.}
\end{table}
\end{document}
Werner
  • 603,163
2

A solution with makecell, threeparttable and siunitx:

\documentclass[11pt]{article}
\usepackage{multicol, booktabs, pbox}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\usepackage{makecell, threeparttable}
\usepackage{siunitx}
\sisetup{table-format = -1.4, table-space-text-post = **}

\begin{document}
%
%\def\sep{0.5em}
%\def\fns{\footnotesize}
\def\onepc{$^{\ast\ast}$} \def\fivepc{$^{\ast}$}
\def\tenpc{$^{\dag}$}
%\def\legend{\multicolumn{6}{l}{\footnotesize{Significance levels
%:\hspace{1em} $\dag$ : 10\% \hspace{1em}
%$\ast$ : 5\% \hspace{1em} $\ast\ast$ : 1\% \normalsize}}}
%\begin{table}[!ht]
% \centering
% \ra{1.2}
% \hspace*{-1.5cm}\begin{tabular}{l@{\hspace{1cm}} r @{} l@{\hspace{1cm}} r @{} l@{\hspace{1cm}} r @{} l@{\hspace{1cm}} r @{} l }
% \toprule
% & \pbox{3cm}{Daily Spending \\ \small (all goods)}& & \pbox{3cm}{ Daily Spending \\ \small (full tax goods)}& & \pbox{3.5cm}{ Daily Spending \\ \small (discount tax goods)}&\\[\sep]
% \midrule
% Varvarvarvar & -0.0168&\onepc & -0.0046& & -0.0191&\onepc \\
% \bottomrule
% \legend
% \end{tabular}\hspace*{-1cm}
%\caption{Results for regressions similar to those in Table \ref{regs:Daily}, but at the monthly level rather than daily. \label{regs:Monthly}}
%\end{table}


\begin{table}[!ht]
  \centering\setlength\tabcolsep{1.2em}
  \ra{1.2}
  \begin{threeparttable}
    \begin{tabular}{@{\,}l SSS@{\,}}
      \toprule
                   & {\makecell{Daily Spending & & \\ \small (all goods)}}& {\makecell{ Daily Spending \\ \small (full tax goods)}} & {\makecell{ Daily Spending \\ \small (discount tax goods)}} \\[0.5em]
      \midrule
      Varvarvarvar & -0.0168\onepc & -0.0046 & -0.0191\onepc \\
      \bottomrule
    \end{tabular}
    \smallskip
    \begin{tablenotes}[online, para]\footnotesize
      \item[]Significance levels
      \item[$\dag$] : 10\,\%
      \item[$\ast$] : 5\,\% \
      \item[$\ast\ast$] : 1\,\%
    \end{tablenotes}
    \caption{Results for regressions similar to those in Table \ref{regs:Daily}, but at the monthly level rather than daily. \label{regs:Monthly}}
  \end{threeparttable}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350