我正在努力格式化使用 Excel2Latex 宏创建的表格。下面您可以看到 Excel 输出的屏幕截图:
使用Excel2Latex宏,Latex中的表格如下所示:
因此,我的问题是,在我用红色圆圈标记的区域中,我将文本旋转了 90 度,而在 Excel 中,我将文本写入了合并单元格中。然而,在 Latex 中,文本仅位于 Excel 垂直合并单元格的第一个单元格中,导致相应的 Latex 第一行增加了很多。您能否帮助我在 Latex 中垂直合并这些单元格?此外,我想将文本置于垂直合并单元格的高度的中心。我还附上了我的代码。
非常感谢您的帮助,非常感谢!
最好的,蒂姆
\begin{landscape}
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{rrrrlccclccclcccrrr}
\toprule
\multicolumn{3}{c}{\textbf{Statistics}} & & \multicolumn{3}{c}{\textbf{Huge}} & & \multicolumn{3}{c}{\textbf{Large}} & & \multicolumn{3}{c}{\textbf{Medium}} & & \multicolumn{3}{c}{\textbf{Small }} \\
\cmidrule{1-3}\cmidrule{5-7}\cmidrule{9-11}\cmidrule{13-15}\cmidrule{17-19} & \multicolumn{1}{c}{\textbf{N}} & \multicolumn{1}{c}{\textbf{Mu}} & &
\multicolumn{1}{c}{\textbf{Test }} & \textbf{Stat.} & \textbf{Sig.} & & \multicolumn{1}{c}{\textbf{Test }} & \textbf{Stat.} & \textbf{Sig.} & &
\multicolumn{1}{c}{\textbf{Test }} & \textbf{Stat.} & \textbf{Sig.} & & \multicolumn{1}{c}{\textbf{Test }} & \multicolumn{1}{c}{\textbf{Stat.}} &
\multicolumn{1}{c}{\textbf{Sig.}} \\
\cmidrule{1-3}\cmidrule{5-11}\cmidrule{13-15}\cmidrule{17-19}
\multicolumn{1}{c}{\multirow{\begin{sideways}\textbf{Huge}\end{sideways}}} &
\multicolumn{1}{c}{\multirow{\begin{sideways}13.500\end{sideways}}} &
\multicolumn{1}{c}{\multirow{\begin{sideways}19,1\%\end{sideways}}} & & & & & & Diff. & 1.000,00 & *** & & Diff. & 1.000,00 & *** & & \multicolumn{1}{l}{Diff.} & \multicolumn{1}{c}{1.000,00} & \multicolumn{1}{c}{***} \\
& & & & & & & & T & 1.000,00 & *** & & T & 1.000,00 & *** & & \multicolumn{1}{l}{T} & \multicolumn{1}{c}{1.000,00} & \multicolumn{1}{c}{***} \\
& & & & & & & & MWU & 1.000,00 & *** & & MWU & 1.000,00 & *** & & \multicolumn{1}{l}{MWU} & \multicolumn{1}{c}{1.000,00} & \multicolumn{1}{c}{***} \\
& & & & & & & & KS & 1.000,00 & *** & & KS & 1.000,00 & *** & & \multicolumn{1}{l}{KS } & \multicolumn{1}{c}{1.000,00} & \multicolumn{1}{c}{***} \\
& & & & & & & & AD & 1.000,00 & *** & & AD & 1.000,00 & *** & & \multicolumn{1}{l}{AD} & \multicolumn{1}{c}{1.000,00} & \multicolumn{1}{c}{***} \\
\bottomrule
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
\end{landscape}
答案1
您只是忘记了它\multirow
有 3 个参数:它必须包含的行数、它的宽度和它的内容。
我借此机会简化了代码,并提出了一种不需要landscape
模式的替代布局:我只使用一test
列,而您发布的代码中重复了三次。当然,这可能与您的实际代码无关。此外,也许实际代码需要列S
类型(from siunitx
)才能很好地对齐数字列。
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{lscape}
\usepackage{array, multirow, rotating, makecell, caption, booktabs}
\renewcommand\theadfont{\normalsize\bfseries}
\usepackage{ltablex}
\begin{document}
\begin{landscape}
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{rrrc*{8}{lc}}
\toprule
\multicolumn{3}{c}{\textbf{Statistics}} & & \multicolumn{3}{c}{\textbf{Huge}} & & \multicolumn{3}{c}{\textbf{Large}} & & \multicolumn{3}{c}{\textbf{Medium}} & & \multicolumn{3}{c}{\textbf{Small }} \\
\cmidrule{1-3}\cmidrule{5-7}\cmidrule{9-11}\cmidrule{13-15}\cmidrule{17-19}%
& \thead{N} & \thead{Mu} & & \thead{Test } & \thead{Stat.} & \thead{Sig.} & & \thead{Test } & \thead{Stat.} & \thead{Sig.} & & \thead{Test } & \thead{Stat.} & \thead{Sig.} & & \thead{Test} & \thead{Stat.} & \thead{Sig.} \\
\cmidrule{1-3}\cmidrule{5-7}\cmidrule{9-11}\cmidrule{13-15}\cmidrule{17-19}%
\multirow{5}{*}{\begin{sideways}\textbf{Huge}\end{sideways}}
& \multirow{5}{*}{\begin{sideways}13.500\end{sideways}}
& \multirow{5}{*}{\begin{sideways}19,1\%\end{sideways}}
& & & & & & Diff. & 1.000,00 & *** & & Diff. & 1.000,00 & *** & &Diff. & 1.000,00 & *** \\
& & & & & & & & T & 1.000,00 & *** & & T & 1.000,00 & *** & & T & 1.000,00 & *** \\
& & & & & & & & MWU & 1.000,00 & *** & & MWU & 1.000,00 & *** & & MWU & 1.000,00 & *** \\
& & & & & & & & KS & 1.000,00 & *** & & KS & 1.000,00 & *** & & KS & 1.000,00 & *** \\
& & & & & & & & AD & 1.000,00 & *** & & AD & 1.000,00 & *** & & AD & 1.000,00 & *** \\
\bottomrule
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
%
\end{landscape}
\begin{table}[htbp]
\centering\setlength\tabcolsep{4.5pt}
\caption{Add caption}
\begin{tabular}{rrrc>{\bfseries}r*{4}{ccl}}
\toprule
\multicolumn{3}{c}{\textbf{Statistics}} & & & & \multicolumn{2}{c}{\textbf{Huge}} & & \multicolumn{2}{c}{\textbf{Large}} & & \multicolumn{2}{c}{\textbf{Medium}} & & \multicolumn{2}{c}{\textbf{Small }}
\\
\cmidrule{1-3}\cmidrule{7-8}\cmidrule{10-11}\cmidrule{13-14}\cmidrule{16-17}%%\cmidrule{9-11}\cmidrule{13-15}%\cmidrule{17-19}%
& \thead{N} & \thead{Mu} & & \thead{Test } & & \thead{Stat.} & \thead{Sig.} & & \thead{Stat.} & \thead{Sig.} & & \thead{Stat.} & \thead{Sig.} & & \thead{Stat.} & \thead{Sig.} \\
\cmidrule{1-3}\cmidrule{5-5}\cmidrule{7-8}\cmidrule{10-11}\cmidrule{13-14}\cmidrule{16-17}%
\multirow{5}{*}{\begin{sideways}\textbf{Huge}\end{sideways}}
& \multirow{5}{*}{\begin{sideways}13.500\end{sideways}}
& \multirow{5}{*}{\begin{sideways}19,1\%\end{sideways}}
& & Diff. & & & & & 1.000,00 & *** & & 1.000,00 & *** & & 1.000,00 & *** \\
& & & & T & & & & & 1.000,00 & *** & & 1.000,00 & *** & & 1.000,00 & *** \\
& & & & MWU & & & & & 1.000,00 & *** & & 1.000,00 & *** & & 1.000,00 & *** \\
& & & & KS & & & & & 1.000,00 & *** & & 1.000,00 & *** & & 1.000,00 & *** \\
& & & & AD & & & & & 1.000,00 & *** & & 1.000,00 & *** & & 1.000,00 & *** \\
\bottomrule
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}
\end{document}