我正在用乳膠寫一些表格。我的 MWE 是:
\documentclass{article}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{longtable}
\usepackage[labelfont=bf]{caption}
\usepackage[utf8]{inputenc}
\usepackage{caption, booktabs, makecell, siunitx}
\usepackage{eqparbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\usepackage[referable,para]{threeparttablex}
\usepackage[textheight=27cm, textwidth=15cm]{geometry}
\usepackage{multirow}
\usepackage{pdflscape}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***,
table-number-alignment =center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}
\begin{document}
\begin{sidewaystable}[htbp]\centering\normalsize{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Baseline model \label{table3}}
\begin{tabular}{l*{5}{c}}
\hline\hline
&\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}&\multicolumn{1}{c}{(5)}\\
\hline
lwlnyw &.984\sym{***}& .674\sym{***}& & .519\sym{***}& .957\sym{***}\\
& (.007) & (.043) & & (.128) & (.013) \\
pc & -.029\sym{**} & -.045\sym{***}& -.033\sym{***}& -.103\sym{***}& -.107\sym{***}\\
& (.015) & (.013) & (.013) & (.039) & (.036) \\
pc2 & .003\sym{**} & .004\sym{***}& .003\sym{***}& .010\sym{***}& .011\sym{***}\\
& (.001) & (.001) & (.001) & (.004) & (.003) \\
lnsnda2 & & & & & \\
& & & & & \\
\hline
Observations & 681 & 681 & 681 & 553 & 681 \\
N. of Observations & & 119 & 119 & 119 & 119 \\
Overall-R$^2$ & & .988 & & & \\
R$^2$ & .989 & .723 & & & \\
F-test & 5531.466 & 85.460 & & & \\
log(likelihood) & 401.638 & 621.943 & & & \\
\hline\hline
\multicolumn{6}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{6}{l}{\footnotesize \sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\
\end{tabular}}
\end{sidewaystable}
\end{document}
如果你看一下 pdf,你會發現:
1) 表示列的數字附在上面的雙線上。我嘗試使用\\
or \vspace
after\hline\hline
來獲得更多空間。然而,碰巧在數字下方而不是上方創建了更多空間。我怎樣才能搭乘這個?
2)我希望柱子之間有更多的空間。在 Excel 中,我習慣新增一個長度非常小的額外欄位。我怎樣才能在乳膠中做同樣的事情?
謝謝,達裡奧
答案1
我建議您進行以下更改:
要獲得間距較好的水平線,請勿使用
\hline
和\cline
。相反,請使用booktabs
套件(您已經載入的)的畫線巨集:\toprule
、\midrule
、\bottomrule
、\cmidrule
和\addlinespace
。若要增加列間空白的數量,請增加 length 參數的值
\tabcolsep
。它的預設值是6pt
;在下面的程式碼中,我使用9pt
.請隨意設定此參數以滿足您的需求。由於您正在載入
siunitx
包,因此您不妨將其S
列類型用於五個資料列。
\documentclass{article}
% I've reduced the preamble to the bare minimum needed to get the code to compile
\usepackage[labelfont=bf,skip=0.333\baselineskip]{caption}
\usepackage[utf8]{inputenc}
\usepackage{booktabs, siunitx}
\usepackage[textheight=27cm, textwidth=15cm]{geometry}
\sisetup{group-separator={},
table-format=-1.3,
input-symbols={()},
table-space-text-post=***}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\pagenumbering{gobble}
\begin{document}
\begin{table}[htbp] % no need to use a 'sidewaystable' here, right?
\setlength{\tabcolsep}{9pt} % default: 6pt
\normalsize
\centering
\caption{Baseline model \label{table3}}
\begin{tabular}{@{} l *{5}{S} @{}}
\toprule
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)}\\
\midrule
lwlnyw & .984\sym{***}& .674\sym{***}& & .519\sym{***} & .957\sym{***}\\
& (.007) & (.043) & & (.128) & (.013) \\
pc & -.029\sym{**} & -.045\sym{***}& -.033\sym{***}& -.103\sym{***} & -.107\sym{***}\\
& (.015) & (.013) & (.013) & (.039) & (.036) \\
pc2 & .003\sym{**} & .004\sym{***}& .003\sym{***}& .010\sym{***}& .011\sym{***}\\
& (.001) & (.001) & (.001) & (.004) & (.003) \\
lnsnda2 \\
\\
\midrule
Observations & {681} & {681} & {681} & {553} & {681} \\
N.\ of Obs. & & {119} & {119} & {119} & {119} \\
Overall $R^2$ & & .988 \\
$R^2$ & .989 & .723 \\
F-test & {5531.5} & {85.5} \\
Log-likelihood & {401.6} & {621.9} \\
\bottomrule
\addlinespace % a bit of (vertical) whitespace
\multicolumn{6}{@{}l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{6}{@{}l}{\footnotesize $\sym{*}\ p<0.10$; $\sym{**}\ p<0.05$; $\sym{***}\ p<0.01$}\\
\end{tabular}
\end{table}
\end{document}