更好地将标题与列对齐

更好地将标题与列对齐

列与标题略有偏移。我尝试了很多方法(这就是为什么代码现在有点乱)。有什么建议可以解决这个问题吗?

\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}

编辑:代码现在是工作示例

答案1

具有和 的解决方案makecellthreeparttablesiunitx

\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} 

在此处输入图片描述

答案2

我不会使用类似的技巧来修复此问题\pbox,而是按照以下方式排版此表。

首先,数字表应该总是使用siunitx设施。其次,重复数据是邪恶的。

\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}

请注意,表格规范指出三个数字列共享以下格式:一个可能的符号-、整数部分的一个数字、小数部分中的四位数字以及一些与 一样宽的附加空间\onepc

标题无需增大\arraystretch或减小字体,通用部分以全局标题形式表述,特殊部分以子标题形式排版。

不要在冒号前留空格。

在此处输入图片描述

答案3

这是因为您将标题设置在\parbox预先指定宽度的 中。由于您在这些 es 中使用了手动换行\parbox,因此您也可以将它们设置在tabular将扩展到内容自然宽度的 中。makecell简化此输入:

在此处输入图片描述

\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}

相关内容