我正在尝试制作一个横向表格,其布局应该与图片中显示的布局类似。但是,我似乎在多列命令和结束文档时做了一些错误。
代码附在下面。
任何帮助是极大的赞赏!
谢谢,
库莎
\documentclass[10.5pt,a4]{article}
\usepackage[margin=0.5in,a4paper]{geometry}
\usepackage{caption}
\usepackage{capt-of}
\usepackage{longtable}
\usepackage{array, booktabs, makecell}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mceight[1]{\multicolumn{13}{l}{#1}}
\usepackage{pdflscape}
\usepackage{afterpage}
\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{table}[ht] \centering
\begin{small}
\begin{tabular}{ l*{13}{S[table-format=2.2]} }
\toprule
\thead[b]{Dependant Variable : log(hourly wages)} & \multicolumn{3}{c}{Percentiles} \\
\cmidrule(lr){1-1}\cmidrule(lr){2-10}
\\
\thead[b]{Independent Variables} & \multicolumn{2}{c}{10th} & & \multicolumn{2}{c}{30th} & & \multicolumn{2}{c}{50th} & & \multicolumn{2}{c}{70th} & & \multicolumn{2}{c}{90th} & & \multicolumn{2}{c}{OLS} \\
\cmidrule(lr){1-1}\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}\cmidrule(lr){8-9}\cmidrule(lr){10-11}\cmidrule(lr){12-13}
& {coeff} & {t-stat} & {coeff} & {t-stat} & {coeff} & {t-stat} & {coeff} & {t-stat} & {coeff} & {t-stat} & {coeff} & {t-stat} \\
Constant & 1.107 & 9.96 & 1.606 & 20.07 & 1.859 & 26.76 & 2.095 & 29.12 & 2.642 & 28.94 & 1.740 & 27.51 \\
Gender & 0.542 & 23.7 & 0.503 & 30.1 & 0.480 & 33.24 & 0.418 & 27.28 & 0.309 & 15.99 & 0.443 & 33.33 \\
Age & 0.007 & 7.22 & 0.013 & 16.91 & 0.015 & 23.98 & 0.017 & 25.24 & 0.016 & 18.71 & 0.017 & 28.26 \\
Urban & 0.232 & 13.07 & 0.196 & 15.13 & 0.168 & 15.01 & 0.168 & 14.18 & 0.168 & 11.23 & 0.211 & 20.5 \\
\end{tabular}
\end{small}
\end{table}
\captionof{table}{Quantile regression results}% Add 'table' caption
\end{landscape}
\clearpage% Flush page
\end{document}
答案1
像这样?
- 根据我对你上一个问题的回答
- 添加包
multirow
small
不是环境而是切换命令,因此只需写\small
- 文档类别
article
无法识别字体大小10.5
- a4 选项无效。您在选项中定义的纸张尺寸
geometry
\documentclass{article}
\usepackage[margin=0.5in,a4paper]{geometry}
\usepackage{caption}
\usepackage{array, booktabs, longtable, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mctwelve[1]{\multicolumn{12}{c}{#1}}% :-)
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{siunitx}
\begin{document}
\afterpage{\clearpage}
\thispagestyle{empty}
\begin{landscape}
\centering
\begin{table}[ht] \centering
\small
\begin{tabular}{ l*{12}{S[table-format=2.3]} }
\toprule
\thead[b]{Dependant Variable:\\ log(hourly wages)}
& \mctwelve{\thead{Percentiles}} \\
\cmidrule(lr){1-1}\cmidrule(lr){2-13}
\multirow{2}{*}{\thead{Independent\\ Variables}}
& \multicolumn{2}{c}{10th}
& \multicolumn{2}{c}{30th}
& \multicolumn{2}{c}{50th}
& \multicolumn{2}{c}{70th}
& \multicolumn{2}{c}{90th}
& \multicolumn{2}{c}{OLS} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
\cmidrule(lr){8-9}\cmidrule(lr){10-11}\cmidrule(lr){12-13}
& {coeff} & {t-stat} & {coeff} & {t-stat} & {coeff} & {t-stat}
& {coeff} & {t-stat} & {coeff} & {t-stat} & {coeff} & {t-stat} \\
\midrule
Constant
& 1.107 & 9.96 & 1.606 & 20.07 & 1.859 & 26.76
& 2.095 & 29.12 & 2.642 & 28.94 & 1.740 & 27.51 \\
Gender
& 0.542 & 23.7 & 0.503 & 30.1 & 0.480 & 33.24
& 0.418 & 27.28 & 0.309 & 15.99 & 0.443 & 33.33 \\
Age & 0.007 & 7.22 & 0.013 & 16.91 & 0.015 & 23.98
& 0.017 & 25.24 & 0.016 & 18.71 & 0.017 & 28.26 \\
Urban
& 0.232 & 13.07 & 0.196 & 15.13 & 0.168 & 15.01
& 0.168 & 14.18 & 0.168 & 11.23 & 0.211 & 20.5 \\
\bottomrule
\end{tabular}
\caption{Quantile regression results}% Add 'table' caption
\label{tab:mylandscapetable}% or whatewer
\end{table}
\end{landscape}
\end{document}