我正在尝试使用 longscape 构建一个表格,就像图中所示的表格(列定义略有不同),但我似乎在代码中犯了一些错误。任何帮助都非常感谢!
\documentclass{article}
\usepackage[margin=0.5in,a4paper]{geometry}
\usepackage{longtable}
\usepackage{array,booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mcseven[1]{\multicolumn{7}{l}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}
%Widows & Orphans & Penalties
\widowpenalty500
\clubpenalty500
\clubpenalty=9996
\exhyphenpenalty=50 %for line-breaking at an explicit hyphen
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602
\floatingpenalty = 20000
\usepackage{siunitx}
\begin{document}
\afterpage{\clearpage}
\thispagestyle{empty}
\begin{landscape}
\centering
\begin{longtable}[ht]{ l*{7}{S[table-format=2.3]}}
\caption{OLS results}
\label{tab:OLS1} \\
\toprule
\thead[b]{Dependent variable\\ log hourly wages} \\
\multicolumn{2}{c}{Male}
& \multicolumn{2}{c}{Female}
& \multicolumn{2}{c}{Pooled}
\cmidrule(lr){1-1}\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
& {coeff} & {SE} & {coeff} & {SE} & {coeff} & {SE} \\
\hdashline \\
\endfirsthead
%%%%
\caption{OLS results} \\
\toprule
\thead[b]{Dependent variable\\ log hourly wages} \\
& \multicolumn{2}{c}{Male}
& \multicolumn{2}{c}{Female}
& \multicolumn{2}{c}{Pooled}
\cmidrule(lr){1-1)\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
& {coeff} & {SE} & {coeff} & {SE} & {coeff} & {SE} \\
\midrule \\
\endhead
\midrule
\multicolumn{7}{r}{\footnotesize\textit{Continue on the next page}}
\endfoot
\endlastfoot
Panel A: 2010-11 \\
{Constant} & 2.162624 & 0.0623814 & 1.847009 & 0.2195808 & 1.891113 & 0.0616229 \\
{Experience} & 0.0293973 & 0.0018267 & 0.0436007 & 0.0044678 & 0.0337108 & 0.0017411 \\
{Experience Square} & -0.0003169 & 0.0000336 & -0.0004819 & 0.0000801 & -0.0003634 & 0.0000319 \\
%further rows omitted
\bottomrule
\end{longtable}
\end{landscape}
\end{document}
答案1
我想这就是你想要的。数字格式与实际数字不符:2.3
表示小数点前有 2 位数字,小数点后有 3 位数字。小数点前有 1(有时还有减号),小数点后有 6 或 7:
\documentclass{article}
\usepackage[margin=0.5in, a4paper]{geometry}
\usepackage{longtable}
\usepackage{array,booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mcseven[1]{\multicolumn{7}{l}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}
%Widows & Orphans & Penalties
\widowpenalty500
\clubpenalty500
\clubpenalty=9996
\exhyphenpenalty=50 %for line-breaking at an explicit hyphen
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602
\floatingpenalty = 20000
\usepackage{siunitx}
\begin{document}
\afterpage{\clearpage}
\thispagestyle{empty}
\begin{landscape}
\centering
\begin{longtable}{ l*{7}{S[table-format=-1.7, table-alignment=center]}}
\caption{OLS results}
\label{tab:OLS1} \\
\toprule
\thead[b]{Dependent variable \\ log hourly wages}
& \multicolumn{2}{c}{Male}
& \multicolumn{2}{c}{Female}
& \multicolumn{2}{c}{Pooled} \\
\cmidrule(lr){1-1}\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
& {coeff} & {SE} & {coeff} & {SE} & {coeff} & {SE} \\
\hdashline \\
\endfirsthead
%%%%
\caption{OLS results} \\
\toprule
\thead[b]{Dependent variable \\ log hourly wages} \\
& \multicolumn{2}{c}{Male}
& \multicolumn{2}{c}{Female}
& \multicolumn{2}{c}{Pooled} \\
\cmidrule(lr){1-1}\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
& {coeff} & {SE} & {coeff} & {SE} & {coeff} & {SE} \\
\midrule \\
\endhead
\midrule
\multicolumn{7}{r}{\footnotesize\textit{Continue on the next page}}
\endfoot
\bottomrule
\endlastfoot
Panel A: 2010-11 \\
{Constant} & 2.162624 & 0.0623814 & 1.847009 & 0.2195808 & 1.891113 & 0.0616229 \\
{Experience} & 0.0293973 & 0.0018267 & 0.0436007 & 0.0044678 & 0.0337108 & 0.0017411 \\
{Experience Square} & -0.0003169 & 0.0000336 & -0.0004819 & 0.0000801 & -0.0003634 & 0.0000319
%further rows omitted
\end{longtable}
\end{landscape}
\end{document}