我试图让整个桌子变灰(见图
但我无法让它与 \raisebox 一起工作。
这是我的代码:
\documentclass[a4paper,11pt]{article}
\usepackage{color,amsmath,amsfonts,amssymb}
\usepackage{rotating}
\usepackage{colortbl}
\definecolor{Gray}{gray}{0.9}
\newcolumntype{g}{>{\columncolor{Gray}}c}
\begin{table}[h]
\begin{center} {\footnotesize
\begin{tabular}{lccg}
\hline
& \multicolumn{3}{c}{AFC Window 1} \\
& \multicolumn{1}{c}{gmt} & \multicolumn{1}{c}{jfk} &
\multicolumn{1}{c}{fbi}\\\hline
\rowcolor{Gray}
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\rowcolor{Gray}
\raisebox{2ex}{Constant} & (1.22) & (2.22) & (0.56)\\[0ex]
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\raisebox{2ex}{Constant} & (1.22) & (2.22) & (0.56)\\[0ex]
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\raisebox{2ex}{Log(assets)$^a$} & (1.22) & (2.22) & (0.56)\\[0ex]
\hline
\end{tabular} }
\end{center}
\caption{\footnotesize Number of turns and distance between top and bottom.}
\label{turns}
\end{table}
\end{document}
多谢你们。
答案1
你必须“打破”凸起的盒子,而不是使用负垂直空间
\documentclass[a4paper,11pt]{article}
\usepackage{color,amsmath,amsfonts,amssymb}
\usepackage{rotating}
\usepackage{colortbl}
\definecolor{Gray}{gray}{0.9}
\begin{document}
\begin{table}[h]
\centering\footnotesize
\begin{tabular}{l*{2}{>{$}c<{$}}>{\columncolor{Gray}$}c<{$}}
\hline
& \multicolumn{3}{c}{AFC Window 1} \\
& \multicolumn{1}{c}{gmt} & \multicolumn{1}{c}{jfk} &
\multicolumn{1}{c}{fbi}\\\hline
\rowcolor{Gray}%
& 0.025^* & -0.002 & 1.155^* \\
\rowcolor{Gray}%
\smash{\raisebox{1.5ex}{Constant}}& (1.22) & (2.22) & (0.56)\\
& 0.025^* & -0.002 & 1.155^* \\
\smash{\raisebox{1.5ex}{Constant}}& (1.22) & (2.22) & (0.56)\\
& 0.025^* & -0.002 & 1.155^* \\
\smash{\raisebox{1.5ex}{Log(assets)\textsuperscript{\itshape a}}}& (1.22) & (2.22) & (0.56)\\
\hline
\end{tabular}
\caption{Number of turns and distance between top and bottom.}
\label{turns}
\end{table}
\end{document}
我还做了一些其他改进,以便减号能够正常显示。
答案2
供参考,这里是一种用 构建该表的{NiceTabular}
方法nicematrix
。
\documentclass[a4paper,11pt]{article}
\usepackage{nicematrix}
\usepackage{booktabs}
\begin{document}
\begin{table}[h]
\centering\footnotesize
\begin{NiceTabular}{lccc}
\CodeBefore
\rowcolor[gray]{0.9}{3,4}
\rectanglecolor[gray]{0.9}{3-4}{8-4}
\Body
\toprule
& \Block{1-3}{AFC Window 1} \\
& gmt & jfk & fbi \\
\midrule
\Block{2-1}{Constant} & $0.025^*$ & $-0.002$ & $1.155^*$ \\
& $(1.22)$ & $(2.22)$ & $(0.56)$ \\
\Block{2-1}{Constant} & $0.025^*$ & $-0.002$ & $1.155^*$ \\
& $(1.22)$ & $(2.22)$ & $(0.56)$ \\
\Block{2-1}{Log(assets)\textsuperscript{\itshape a}}
& $0.025^*$ & $-0.002$ & $1.155^*$ \\
& $(1.22)$ & $(2.22)$ & $(0.56)$ \\
\bottomrule
\end{NiceTabular}
\caption{Number of turns and distance between top and bottom.}
\label{turns}
\end{table}
\end{document}
您需要多次编译。