我正在尝试创建一个表格,例如这里展示的表格,但前两列中的文本应该垂直居中。但是,我无法实现它。我做错了什么?我收到“bad \vbox”警告,我猜是它导致了问题,但我不知道如何解决它。
妇女权利委员会:
\documentclass[
ngerman,
accentcolor=9c,% Farbe für Hervorhebungen auf Basis der Deklarationen in den
type=intern,
marginpar=false
]{tudapub}
\usepackage[english, main=ngerman]{babel}
\usepackage[autostyle]{csquotes}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{mwe}
\begin{document}
\begin{table}[!h]
\centering
\begin{tabular}{ccccccc}
\toprule
&%
& Central Layer%
& \multicolumn{4}{c}{Top Layer}%
\\
\cmidrule(lr){3-3}
\cmidrule(lr){4-7}
&%
& X = 0 \& Z = -2b%
& X = 0 \& Z = 0%
& X = 0 \& Z = 2b%
& X = 0 \& Z = -2b%
& X = ann \& Z = 0%
\\%
\midrule
\multirow{2}{*}{\rotatebox[origin=c]{90}{Resonance frequency, $f_\mathrm{0}$ = 81.3 GHz}}%
& \rotatebox[origin=c]{90}{E-field}%
& \includegraphics[width=3cm,height=4cm]{example-image}%
& 2%
& 3%
& 4%
& 5%
\\%
&\rotatebox[origin=c]{90}{H-field}%
& \includegraphics[width=3cm,height=4cm]{example-image}%
& 2%
& 3%
& 4%
& 5%
\\%
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
借助valign=c
from adjustbox
、\Block
from and :NiceTabular
nicematrix
\makebox[0pt]
\documentclass[
ngerman,
accentcolor=9c,% Farbe für Hervorhebungen auf Basis der Deklarationen in den
type=intern,
marginpar=false
]{tudapub}
\usepackage[english, main=ngerman]{babel}
\usepackage[autostyle]{csquotes}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage[export]{adjustbox}
\begin{document}
\begin{table}[!h]
\centering
\begin{NiceTabular}{ccccccc}
\toprule
&%
& Central Layer%
& \Block{1-4}{Top Layer}%
\\
\cmidrule(lr){3-3}
\cmidrule(lr){4-7}
&%
& X = 0 \& Z = -2b%
& X = 0 \& Z = 0%
& X = 0 \& Z = 2b%
& X = 0 \& Z = -2b%
& X = ann \& Z = 0%
\\%
\midrule
\Block{2-1}{\rotate Resonance frequency, $f_\mathrm{0}$ = 81.3 GHz}%
& \Block{1-1}{\rotate \makebox[0pt]{E-field}}
& \includegraphics[width=3cm,height=4cm, valign=c]{example-image}%
& 2%
& 3%
& 4%
& 5%
\\%
& \Block{1-1}{\rotate \makebox[0pt]{H-field}}
& \includegraphics[width=3cm,height=4cm, valign=c]{example-image}%
& 2%
& 3%
& 4%
& 5%
\\%
\bottomrule
\end{NiceTabular}
\end{table}
\end{document}