答案1
我不得不承认,我并不特别喜欢截图中显示的表格布局。这个表格给人一种非常不平衡的感觉,因为最后两列数据比前四列数据宽得多,而且主要采用左对齐方式。
booktabs
无论如何,利用、tabularx
和包的功能来重现这种不平衡的外观是相当简单的siunitx
。
我还展示了 IMNSHO 更好的布局。它仍然使用booktabs
和siunitx
包,但它使用tabular*
环境而不是tabularx
环境,它中心数据列的内容,并为最右侧的标题单元格提供了更多结构。我希望您同意我的观点,最终的外观更出色。
\documentclass{article}
\usepackage[margin=1in,letterpaper]{geometry} % text block parameters
\usepackage{tabularx,siunitx,booktabs}
\usepackage[skip=0.5\baselineskip]{caption}
\usepackage{newtxtext,newtxmath}
\newcommand\mX[1]{\multicolumn{1}{X}{#1}} % handy shortcut macros
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}
\newcommand\mcl[1]{\multicolumn{2}{l}{#1}}
\begin{document}
\begin{table}[t]
\caption{Trying to recreate all questionable layout choices\dots}
\begin{tabularx}{\textwidth}{%
l
S[table-format=3.3,table-number-alignment = left]
*{5}{S[table-format=3.2,table-number-alignment = left]}}
\toprule
& \mcl{\textbf{No policy}}
& \mcl{\textbf{Credit policy}}
& \mcl{\textbf{Macroprudential policy} ($\tau^2=0.0061$)}\\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
& \mX{Low risk} & \mX{High risk} & \mX{Low risk}
& \mX{High risk} & \mX{Low risk} & \mX{High risk} \\
\midrule
Output & 23.821 & 23.53 & 24.18 & 23.85 & 24.04 & 23.83\\
$\vdots$ \\
$K$ & 209.52 & 206.16 & 214.23 & 210.46 & 212.48 & 210.41\\
$\vdots$\\
SD output growth (\%) & 1.09 & 2.53 & 0.81 & 2.43 & 0.80 & 2.29 \\
\bottomrule
\end{tabularx}
\end{table}
\begin{table}[h]
\centering
\setlength\tabcolsep{0pt} % make LaTeX figure out the intercolumn whitespace
\caption{A (hopefully) superior layout\dots}
\begin{tabular*}{0.9\textwidth}{l@{\extracolsep{\fill}}
S[table-format=3.3] *{5}{S[table-format=3.2]}@{}}
\toprule
& \mcc{\textbf{No policy}}
& \mcc{\textbf{Credit policy}}
& \mcc{\textbf{Macropru policy}}\\
& && && \mcc{($\tau^2=0.0061$)}\\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7}
& {Low risk} & {High risk} & {Low risk}
& {High risk} & {Low risk} & {High risk} \\
\midrule
Output & 23.821 & 23.53 & 24.18 & 23.85 & 24.04 & 23.83\\
$\vdots$ \\
$K$ & 209.52 & 206.16 & 214.23 & 210.46 & 212.48 & 210.41\\
$\vdots$\\
SD output growth (\%) & 1.09 & 2.53 & 0.81 & 2.43 & 0.80 & 2.29 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
答案2
使用 ConTeXt MKIV 的部分解决方案。我光学字符识别 (OCR)从图片中删除了数字,因此我不能保证它们是正确的。
\setuppapersize[A4,landscape]
\setupbodyfont[schola,10pt]
\starttext
\startsetups table:numbers
\setupTABLE[frame=off,option=stretch]
\setupTABLE[c][each][alignmentcharacter={.},aligncharacter=yes]
\setupTABLE[r][1][style=bold,aligncharacter=no]
\setupTABLE[r][1,2,3][topframe=on]
\setupTABLE[r][-1][bottomframe=on]
\setupTABLE[1][2][topframe=off]
\stopsetups
\startTABLE[setups=table:numbers]
\NC \NC[nx=2] No policy \NC[nx=2] Credit policy \NC[nx=2] Macroprudential policy {\tf($\tau^s = 0.0061$)} \NC\NR
\NC \NC Low risk \NC High risk \NC Low risk \NC High risk \NC Low risk \NC High risk \NC\NR
\NC Output \NC 23.821 \NC 23.53 \NC 24.18 \NC 23.85 \NC 24.04 \NC 23.83 \NC\NR
\NC $C$ \NC 18.58 \NC 18.37 \NC 18.82 \NC 18.58 \NC 18.73 \NC 18.57 \NC\NR
\NC $L$ \NC 8.16 \NC 8.08 \NC 8.26 \NC 8.16 \NC 8.22 \NC 8.15 \NC\NR
\NC $K$ \NC 209.52 \NC 206.16 \NC 214.34 \NC 210.46 \NC 212.48 \NC 210.41 \NC\NR
\NC $N$ \NC 31.77 \NC 38.02 \NC 30.05 \NC 37.11 \NC 30.85 \NC 37.72 \NC\NR
\NC Risk free rate (\%) \NC 4.08 \NC 3.72 \NC 4.06 \NC 3.68 \NC 4.05 \NC 3.56 \NC\NR
\NC Spread (\%) \NC 0.99 \NC 1.46 \NC 0.89 \NC 1.38 \NC 0.94 \NC 1.48 \NC\NR
\NC $x$ (\%) \NC 10.12 \NC 15.16 \NC 9.63 \NC 13.35 \NC 18.77 \NC 21.98 \NC\NR
\NC $\nu$ \NC 1.63 \NC 1.38 \NC 1.76 \NC 1.42 \NC 1.81 \NC 1.54 \NC\NR
\NC $\mu_e$ \NC 0.05 \NC 0.15 \NC 0.03 \NC 0.12 \NC 0.03 \NC 0.08 \NC\NR
\NC $\mu_s$ \NC 0.29 \NC 0.16 \NC 0.33 \NC 0.19 \NC 0.37 \NC 0.27 \NC\NR
\NC $\phi$ \NC 6.59 \NC 5.42 \NC 7.13 \NC 5.67 \NC 6.89 \NC 5.58 \NC\NR
\NC $QK/*N+xQK)$ \NC 3.95 \NC 2.98 \NC 4.23 \NC 3.23 \NC 3.00 \NC 2.51 \NC\NR
\NC $N/xQK$ \NC 1.50 \NC 1.22 \NC 1.46 \NC 1.32 \NC 0.77 \NC 0.82 \NC\NR
\NC SD shock (\%) \NC 0.69 \NC 2.07 \NC 0.69 \NC 2.07 \NC 0.69 \NC 2.07 \NC\NR
\NC SD output growth (\%) \NC 1.09 \NC 2.53 \NC 0.81 \NC 2.43 \NC 0.80 \NC 2.29 \NC\NR
\stopTABLE
\stoptext