正常餐桌布置

正常餐桌布置
\documentclass{article}
\usepackage{booktabs,rotating,array,dcolumn,caption,amsmath, textcomp}
\usepackage{booktabs,caption}
\usepackage{microtype}
\usepackage{charter}
\newcolumntype{d}[1]{D..{#1}}
\usepackage[margin=2.5cm,a4paper]{geometry}
\begin{document}
    \begin{table}
        \scriptsize % 30% linear reduction in size
        \captionsetup{skip=0.333\baselineskip,font=footnotesize}
        \caption{Add caption}
        \label{tab:addlabel}

        \setlength{\tabcolsep}{0pt} % make LaTeX figure out intercol. space
        \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{10}{d{2.5}r} }
            \toprule
\toprule
Variables & \multicolumn{10}{c}{Decisions} \\
\cmidrule{2-10}
& \multicolumn{2}{c}{Healthcare}
& \multicolumn{2}{c}{Social}
& \multicolumn{2}{c}{Consumption} 
& \multicolumn{2}{c}{Financial} 
& \multicolumn{2}{c}{All} \\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9} \cmidrule{9-10} 
\bottomrule
\end{tabular*}
\begin{tablenotes}
\small
\item Source: Authors'   calculations.\\
Standard errors in parentheses \\
{***} p$<$0.01, {**} p$<$0.05, {*} p$<$0.1
\end{tablenotes}
\end{table}

答案1

  • 您的代码包含的指标组合不太好,表明环境tabular*应该包含 10 或 20 个数据列,总共 11 或 21 列。在下面的代码中,我提供了有关如何修复代码以使其包含 11 或 21 列的建议。

  • 加载threeparttable包并使用其tablenotes环境似乎有点过度,特别是因为您似乎没有使用任何\tnote指令。

  • 不要多次加载包。

开始:

在此处输入图片描述

\documentclass{article}
\usepackage[margin=2.5cm,a4paper]{geometry}
\usepackage{booktabs,rotating,array,dcolumn,caption,
            amsmath,textcomp,microtype,charter}
\newcolumntype{d}[1]{D..{#1}}
\begin{document}

\begin{table}
\captionsetup{skip=0.333\baselineskip, font=footnotesize}
\scriptsize % 30% linear reduction in size
\setlength{\tabcolsep}{0pt} % make LaTeX figure out intercol. space

%%%%%%%%%%%%%%%%%%%%%
%% Possibility 1: 21 columns
\caption{21 columns} \label{tab:21}
%% '*{10}{d{2.5}r}' actually specifies 20, not 10, columns
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{10}{d{2.5}r} }
\toprule %%% please don't ever use double \toprule
Variables & \multicolumn{20}{c}{Decisions} \\
\cmidrule{2-21}
& \multicolumn{4}{c}{Healthcare}
& \multicolumn{4}{c}{Social}
& \multicolumn{4}{c}{Consumption} 
& \multicolumn{4}{c}{Financial} 
& \multicolumn{4}{c}{All} \\
\cmidrule{2-5} \cmidrule{6-9} \cmidrule{10-13} \cmidrule{14-17} \cmidrule{18-21} 
& a & b & c & d 
& a & b & c & d 
& a & b & c & d 
& a & b & c & d 
& a & b & c & d \\
\midrule
\dots \\
\bottomrule
\end{tabular*}

\smallskip
Source: Author's calculations

Standard errors in parentheses

{***} $p<0.01$; {**} $p<0.05$; {*} $p<0.1$

\vspace{1cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Possibility 2: 11 columns

\caption{11 columns} \label{tab:11}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{10}{r} }
\toprule %%% please don't ever use double \toprule!
Variables & \multicolumn{10}{c}{Decisions} \\
\cmidrule{2-11}
& \multicolumn{2}{c}{Healthcare}
& \multicolumn{2}{c}{Social}
& \multicolumn{2}{c}{Consumption} 
& \multicolumn{2}{c}{Financial} 
& \multicolumn{2}{c}{All} \\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9} \cmidrule{10-11} 
& a & b 
& a & b 
& a & b 
& a & b 
& a & b \\
\midrule
\dots \\
\bottomrule
\end{tabular*}

\smallskip
Source: Author's calculations

Standard errors in parentheses

$^{***}$ $p<0.01$; $^{**}$ $p<0.05$; $^{*}$ $p<0.1$
\end{table}
\end{document}

相关内容