我正在努力将每列中的所有数字垂直对齐。现在“收入(人民币)”和“配偶收入(人民币)”行中的数字很突出。谢谢!
我拥有的:
\documentclass{article}
\usepackage{booktabs,dcolumn,caption}
\usepackage[para,flushleft]{threeparttable}
\usepackage{enumitem}
\usepackage{siunitx}
\newlist{myitemize}{itemize}{1}
\setlist[myitemize]{noitemsep,left=0pt,label=--}
\captionsetup{skip=0.333\baselineskip}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} % handy shortcut macro
\begin{document}
\begin{table}
\begin{threeparttable}
\caption*{Table 1 - Summary Statistics}
\centering
\begin{tabular}{@{} l *{4}{d{5}d{5}d{5}d{5}} @{}}
\toprule
Two-Sample T-Test & \multicolumn{2}{c}{Gender} & \multicolumn{2}{c@{}}{Means} \\
\cmidrule(l){2-2} \cmidrule(l){3-3} \cmidrule(l){4-5}
& \multicolumn{1}{c}{Married Men} & \mc{Married Women}
& \multicolumn{1}{c}{Raw Difference} & \mc{T-Stat} \\
\midrule
Earnings \scriptsize (RMB) \tnote{a} & 47743.48 & 32037.77 & 15705.71 & -10.128^{***} \\
\midrule
Education \tnote{b} & 3.435897 & 3.251876 & 0.184021 & -2.9184^{***} \\
Education \scriptsize (years) & 10.151709 & 9.411576 & 0.740133 & -3.8606^{***} \\
Age & 46.20299 & 44.32583 & 1.87716 & -4.9186^{***} \\
Experience \scriptsize (years) \tnote{c} & 30.05128 & 28.91426 & 1.13702 & -2.3852^{**} \\
Work Time \scriptsize (hours) \tnote{d} & 50.90833 & 47.31458 & 3.59375 & -4.1831^{***} \\
HW Time \scriptsize (hours) \tnote{e} & 1.151755 & 2.251799 & -1.100044 & 20.068^{***} \\
Sleep Time \scriptsize (hours) \tnote{f} & 7.553220 & 7.491119 & 0.062101 & -1.1477 \\
Ability Score \tnote{g} & 17.32105 & 16.38853 & 0.93252 & -3.4604^{***} \\
\midrule
Spouse Education \tnote{h} & 3.254274 & 3.411576 & -0.157302 & 2.5134^{**} \\
Spouse Education \scriptsize (years) & 9.42094 & 10.08896 & -0.66802 & 3.5079^{***} \\
Spouse Earnings \scriptsize (RMB) \tnote{i} & 31377.18 & 48106.67 & -16729.49 & 10.346^{***} \\
\midrule
\emph{N} & {936} & {933} & {1869} & {1869} \\
\bottomrule
\end{tabular}
\medskip
\begin{tablenotes}
\footnotesize
\item[a] Total income for all jobs in 2018, in RMB (official currency of the PRC)\\
\item[b] Highest educational degree at the time of survey, on a scale of 1 to 8 (1, illiterate/semi-illiterate; 8, doctoral degree)\\
\item[c] Potential experience (in years), an index created using $\max\{Age-Education(years)-6,0\}$ \\
\item[d] Weekly work time (in hours) \\
\item[e] Daily time (in hours) spent on housework on average, an index created using: \\
$\frac{(Hours \ spent \ on \ housework \ during \ weekdays)*5 + (Hours \ spent \ on \ housework \ during \ weekends)*2}{7}$ \\
\item[f] Daily sleep time (in hours), an index created using: \\
$\frac{(Hours \ of \ sleep \ during \ weekdays)*5 + (Hours \ of \ sleep \ during \ weekends)*2}{7}$ \\
\item[g] An ability index score created using: $\frac{(Math \ test \ score) + (Word \ test \ score)}{2}$ \\
\item[h] Spouse's highest educational degree at the time of survey, on a scale of 1 to 8 (1, illiterate/semi-illiterate; 8, doctoral degree) \\
\item[i] Spouse's total income for all jobs in 2018, in RMB (official currency of the PRC) \\
\end{tablenotes}
\end{threeparttable}
\bigskip\small
Notes:
\begin{myitemize}
\item ***, **, and * indicate significance at the 1\%, 5\%, and 10\% critical level.
\item The above results are based on the 2018 round of CFPS (China Family Panel Studies) survey data.
\item The data cleaning procedure includes: only keeping married people, dropping those spouses who are not financially-connected with the family, dropping spouses who are not living in this family currently, dropping people who reported ``missing values'' and negative values for their earnings, and dropping all other ``missing values'' throughout our variables. There are 37354 subjects in the original survey data. We obtain 1896 subjects in our sample, 936 married men, 933 married women, after applying all necessary filters.
\item Considering our sample includes married couples who live together, socio-geographical characteristics such as ``number of children'', ``rural vs. urban'', and ``coastal, more prosperous provinces vs. distant provinces'' will be elaborated later, as we compare different groups based on these characteristics.
\end{myitemize}
\end{table}
\end{document}
答案1
我知道数字太大并且被推向左边缘,这导致了不受欢迎的尴尬对齐。
S
包中的列类型siunitx
应用数字格式与D
列类型类似。但是,siunitx
如果将单元格内容括在括号中,则可以抑制单个单元格中的数字格式和对齐方式{}
;或应用\multicolumn{}{}{}
。然后,通过添加额外空间进行简单的居中和调整应该可以达到预期的效果
编辑。恐怕我提供了一个不相关的解决方案,因为问题是关于垂直对齐的。
我正在努力垂直对齐每列中的所有数字......
但是,我很难理解你的意思。你的表格在上述行中似乎具有完美的垂直对齐。我猜脱颖而出意味着间距更大,但这就是我们\toprule
要做\midrule
的。您可以使用两种解决方案:\hline
使用标准间距和细线;或者\specialrule{}{}{}
在booktabs
规则周围应用自定义间距,但保持与使用相同的规则宽度\midrule
# \specialrule{<rule width>}{space above}{<space below>}
\specialrule{\lightrulewidth}{0pt}{0pt}
下面的代码尚未应用这些更改。
代码
\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs,caption} % dcolumn removed
\usepackage[para,flushleft]{threeparttable}
\usepackage{enumitem}
\usepackage{siunitx}
\newlist{myitemize}{itemize}{1}
\setlist[myitemize]{noitemsep,left=0pt,label=--}
\captionsetup{skip=0.333\baselineskip}
\newcolumntype{d}[1]{D{.}{.}{5.7}}
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} % handy shortcut macro
\newrobustcmd\Tn[1]{\textsuperscript{#1}} % <--- added
\sisetup{ % <--- added
table-number-alignment = center,
table-text-alignment = center,
table-align-text-after=false,
}
\begin{document}
\begin{table}
\begin{threeparttable}
\caption*{Table 1 - Summary Statistics}
\centering
\begin{tabular}{
@{} l
*2{S[table-format=5.7]}
*2{S[table-format=-5.7]}
@{}
}
\toprule
Two-Sample T-Test & \multicolumn{2}{c}{Gender} & \multicolumn{2}{c@{}}{Means} \\
\cmidrule(l){2-2} \cmidrule(l){3-3} \cmidrule(l){4-5}
& \multicolumn{1}{c}{Married Men} & \mc{Married Women}
& \multicolumn{1}{c}{Raw Difference} & \mc{T-Stat} \\
\midrule
Earnings \scriptsize (RMB) \tnote{a} &
\multicolumn{1}{c}{\(\hspace{1em}47743.48\)} &
\multicolumn{1}{c}{\(\hspace{1em}32037.77\)} &
\multicolumn{1}{c}{\(\hspace{2em}15705.71\)} &
{\(-10.128^{***}\)} \\
\midrule
Education \tnote{b} & 3.435897 & 3.251876 & 0.184021 & -2.9184\Tn{***} \\
Education \scriptsize (years) & 10.151709 & 9.411576 & 0.740133 & -3.8606\Tn{***} \\
Age & 46.20299 & 44.32583 & 1.87716 & -4.9186\Tn{***} \\
Experience \scriptsize (years) \tnote{c} & 30.05128 & 28.91426 & 1.13702 & -2.3852\Tn{**} \\
Work Time \scriptsize (hours) \tnote{d} & 50.90833 & 47.31458 & 3.59375 & -4.1831\Tn{***} \\
HW Time \scriptsize (hours) \tnote{e} & 1.151755 & 2.251799 & -1.100044 & 20.068\Tn{***} \\
Sleep Time \scriptsize (hours) \tnote{f} & 7.553220 & 7.491119 & 0.062101 & -1.1477 \\
Ability Score \tnote{g} & 17.32105 & 16.38853 & 0.93252 & -3.4604\Tn{***} \\
\midrule
Spouse Education \tnote{h} & 3.254274 & 3.411576 & -0.157302 & 2.5134\Tn{***} \\
Spouse Education \scriptsize (years) & 9.42094 & 10.08896 & -0.66802 & 3.5079\Tn{***} \\
Spouse Earnings \scriptsize (RMB) \tnote{i} &
\multicolumn{1}{c}{\(\hspace{1em} 31377.18\)} &
\multicolumn{1}{c}{\(\hspace{1em} 48106.67\)} &
\multicolumn{1}{c}{\(\hspace{1em}-16729.49\)} &
10.346\Tn{***} \\
\midrule
\emph{N} & {936} & {933} & {1869} & {1869} \\
\bottomrule
\end{tabular}
\medskip
\begin{tablenotes}
\footnotesize
\item[a] Total income for all jobs in 2018, in RMB (official currency of the PRC)\\
\item[b] Highest educational degree at the time of survey, on a scale of 1 to 8 (1, illiterate/semi-illiterate; 8, doctoral degree)\\
\item[c] Potential experience (in years), an index created using $\max\{Age-Education(years)-6,0\}$ \\
\item[d] Weekly work time (in hours) \\
\item[e] Daily time (in hours) spent on housework on average, an index created using: \\
$\frac{(Hours \ spent \ on \ housework \ during \ weekdays)*5 + (Hours \ spent \ on \ housework \ during \ weekends)*2}{7}$ \\
\item[f] Daily sleep time (in hours), an index created using: \\
$\frac{(Hours \ of \ sleep \ during \ weekdays)*5 + (Hours \ of \ sleep \ during \ weekends)*2}{7}$ \\
\item[g] An ability index score created using: $\frac{(Math \ test \ score) + (Word \ test \ score)}{2}$ \\
\item[h] Spouse's highest educational degree at the time of survey, on a scale of 1 to 8 (1, illiterate/semi-illiterate; 8, doctoral degree) \\
\item[i] Spouse's total income for all jobs in 2018, in RMB (official currency of the PRC) \\
\end{tablenotes}
\end{threeparttable}
\bigskip\small
Notes:
\begin{myitemize}
\item ***, **, and * indicate significance at the 1\%, 5\%, and 10\% critical level.
\item The above results are based on the 2018 round of CFPS (China Family Panel Studies) survey data.
\item The data cleaning procedure includes: only keeping married people, dropping those spouses who are not financially-connected with the family, dropping spouses who are not living in this family currently, dropping people who reported ``missing values'' and negative values for their earnings, and dropping all other ``missing values'' throughout our variables. There are 37354 subjects in the original survey data. We obtain 1896 subjects in our sample, 936 married men, 933 married women, after applying all necessary filters.
\item Considering our sample includes married couples who live together, socio-geographical characteristics such as ``number of children'', ``rural vs. urban'', and ``coastal, more prosperous provinces vs. distant provinces'' will be elaborated later, as we compare different groups based on these characteristics.
\end{myitemize}
\end{table}
\end{document}