表格中的文本垂直居中

表格中的文本垂直居中

我有下表:

\documentclass[11pt]{article}

\usepackage{rotating}

\usepackage[
    lmargin=1.0in,
    rmargin=1.0in,
    tmargin=2.0cm,
    bmargin=2.0cm
]{geometry}

\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage{multirow}

\begin{document}

\begin{table}
    \centering
    % table caption is to be above the table
    \caption{Table title.}
    \scalebox{0.65}{
    \begin{tabularx}{1.5\textwidth}{ll *{10}{Y}}
    \toprule
      & & \multicolumn{10}{c}{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}\\[2mm]
      & & 0.1 & 0.2 & 0.3 & 0.4 & 0.5 & 0.6 & 0.7 & 0.8 & 0.9 & 1.0\\
    \cmidrule[0.6pt]{3-12}
        \parbox[t]{3mm}{\multirow{20}{*}{\rotatebox[origin=c]{90}{bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}}}
            &\multirow{2}{*}{0.1}
            &40.14 & 29.7 & 23.58 & 19.57 & 16.75 & 14.67 & 13.05 & 11.77 & 10.73 & 9.86\\
            &
            &$(0\%)$ & $(5.18\%)$ & $(14.29\%)$ & $(24.2\%)$ & $(34.18\%)$ & $(44.0\%)$ & $(53.58\%)$ & $(62.89\%)$ & $(71.92\%)$ & $(80.68\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.2}
            &41.93 & 28.24 & 21.01 & 16.67 & 13.81 & 11.79 & 10.3 & 9.14 & 8.23 & 7.49\\
            &
            &$(4.47\%)$ & $(0\%)$ & $(1.87\%)$ & $(5.8\%)$ & $(10.59\%)$ & $(15.78\%)$ & $(21.12\%)$ & $(26.52\%)$ & $(31.89\%)$ & $(37.21\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.3}
            &44.58 & 28.74 & 20.63 & 15.92 & 12.92 & 10.86 & 9.36 & 8.24 & 7.36 & 6.66\\
            &
            & $(11.06\%)$ & $(1.78\%)$ & $(0\%)$ & $(1.03\%)$ & $(3.44\%)$ & $(6.6\%)$ & $(10.17\%)$ & $(13.99\%)$ & $(17.93\%)$ & $(21.93\%)$\\
 \cmidrule{2-12}
            &\multirow{2}{*}{0.4}
            &47.1 & 29.74 & 20.84 & 15.76 & 12.57 & 10.43 & 8.91 & 7.77 & 6.9 & 6.21\\
            &
            & $(17.35\%)$ & $(5.31\%)$ & $(1.05\%)$ & $(0\%)$ & $(0.69\%)$ & $(2.42\%)$ & $(4.77\%)$ & $(7.52\%)$ & $(10.52\%)$ & $(13.67\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.5}
            &49.41 & 30.93 & 21.34 & 15.88 & 12.49 & 10.24 & 8.66 & 7.5 & 6.61 & 5.92\\
            &
            & $(23.09\%)$ & $(9.52\%)$ & $(3.47\%)$ & $(0.74\%)$ & $(0\%)$ & $(0.52\%)$ & $(1.85\%)$ & $(3.73\%)$ & $(5.96\%)$ & $(8.43\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.6}
            &51.51 & 32.2 & 22.01 & 16.17 & 12.56 & 10.18 & 8.53 & 7.34 & 6.43 & 5.73\\
            &
            & $(28.32\%)$ & $(14.05\%)$ & $(6.7\%)$ & $(2.58\%)$ & $(0.58\%)$ & $(0\%)$ & $(0.41\%)$ & $(1.49\%)$ & $(3.03\%)$ & $(4.9\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.7}
            &53.43 & 33.52 & 22.79 & 16.58 & 12.74 & 10.23 & 8.5 & 7.25 & 6.32 & 5.6\\
            &
            & $(33.12\%)$ & $(18.72\%)$ & $(10.46\%)$ & $(5.2\%)$ & $(2.06\%)$ & $(0.47\%)$ & $(0\%)$ & $(0.33\%)$ & $(1.23\%)$ & $(2.54\%)$\\
 \cmidrule{2-12}
            &\multirow{2}{*}{0.8}
            &55.21 & 34.85 & 23.64 & 17.08 & 13.02 & 10.36 & 8.53 & 7.23 & 6.26 & 5.52\\
            &
            & $(37.55\%)$ & $(23.43\%)$ & $(14.6\%)$ & $(8.39\%)$ & $(4.24\%)$ & $(1.7\%)$ & $(0.39\%)$ & $(0\%)$ & $(0.28\%)$ & $(1.04\%)$\\
 \cmidrule{2-12}
            &\multirow{2}{*}{0.9}
            &56.86 & 36.18 & 24.55 & 17.66 & 13.36 & 10.55 & 8.62 & 7.25 & 6.24 & 5.47\\
            &
            & $(41.65\%)$ & $(28.13\%)$ & $(19.01\%)$ & $(12.04\%)$ & $(6.98\%)$ & $(3.56\%)$ & $(1.44\%)$ & $(0.34\%)$ & $(0\%)$ & $(0.23\%)$\\
 \cmidrule{2-12}
              &\multirow{2}{*}{1.0}
            &58.39 & 37.5 & 25.49 & 18.29 & 13.76 & 10.79 & 8.76 & 7.32 & 6.26 & 5.46\\
            &
            & $(45.48\%)$ & $(32.79\%)$ & $(23.59\%)$ & $(16.05\%)$ & $(10.19\%)$ & $(5.94\%)$ & $(3.05\%)$ & $(1.25\%)$ & $(0.3\%)$ & $(0\%)$\\
      \bottomrule
      \end{tabularx}
    } % endof \scalebox
\end{table}

这就是它产生的结果

LaTeX 输出

“问题”是第一列中的垂直文本 (bbbbbb...) 根据整个表格的高度居中。我想将文本向下拖动一点,以便根据行 0.1 到 1.0 的总高度将其居中,紧挨着第一列。如能得到任何帮助,我将不胜感激。

答案1

您可以使用宏的第二个可选参数\multirow,即fixup。任何负数长度都会将文本放下:

\multirow{nrows}[bigstruts]{width}[fixup]{text}

喜欢

\parbox[t]{3mm}{\multirow{20}{*}[-1.5ex]{\rotatebox[origin=c]{90}
                {bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}}}

进行调整-1.5ex以满足您的需要。

\documentclass[11pt]{article}

\usepackage{rotating}

\usepackage[
    lmargin=1.0in,
    rmargin=1.0in,
    tmargin=2.0cm,
    bmargin=2.0cm
]{geometry}

\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage{multirow}

\begin{document}

\begin{table}
    \centering
    % table caption is to be above the table
    \caption{Table title.}
    \scalebox{0.65}{
    \begin{tabularx}{1.5\textwidth}{ll *{10}{Y}}
    \toprule
      & & \multicolumn{10}{c}{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}\\[2mm]
      & & 0.1 & 0.2 & 0.3 & 0.4 & 0.5 & 0.6 & 0.7 & 0.8 & 0.9 & 1.0\\
    \cmidrule[0.6pt]{3-12}
        \parbox[t]{3mm}{\multirow{20}{*}[-1.5ex]{\rotatebox[origin=c]{90}{bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}}}
            &\multirow{2}{*}{0.1}
            &40.14 & 29.7 & 23.58 & 19.57 & 16.75 & 14.67 & 13.05 & 11.77 & 10.73 & 9.86\\
            &
            &$(0\%)$ & $(5.18\%)$ & $(14.29\%)$ & $(24.2\%)$ & $(34.18\%)$ & $(44.0\%)$ & $(53.58\%)$ & $(62.89\%)$ & $(71.92\%)$ & $(80.68\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.2}
            &41.93 & 28.24 & 21.01 & 16.67 & 13.81 & 11.79 & 10.3 & 9.14 & 8.23 & 7.49\\
            &
            &$(4.47\%)$ & $(0\%)$ & $(1.87\%)$ & $(5.8\%)$ & $(10.59\%)$ & $(15.78\%)$ & $(21.12\%)$ & $(26.52\%)$ & $(31.89\%)$ & $(37.21\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.3}
            &44.58 & 28.74 & 20.63 & 15.92 & 12.92 & 10.86 & 9.36 & 8.24 & 7.36 & 6.66\\
            &
            & $(11.06\%)$ & $(1.78\%)$ & $(0\%)$ & $(1.03\%)$ & $(3.44\%)$ & $(6.6\%)$ & $(10.17\%)$ & $(13.99\%)$ & $(17.93\%)$ & $(21.93\%)$\\
 \cmidrule{2-12}
            &\multirow{2}{*}{0.4}
            &47.1 & 29.74 & 20.84 & 15.76 & 12.57 & 10.43 & 8.91 & 7.77 & 6.9 & 6.21\\
            &
            & $(17.35\%)$ & $(5.31\%)$ & $(1.05\%)$ & $(0\%)$ & $(0.69\%)$ & $(2.42\%)$ & $(4.77\%)$ & $(7.52\%)$ & $(10.52\%)$ & $(13.67\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.5}
            &49.41 & 30.93 & 21.34 & 15.88 & 12.49 & 10.24 & 8.66 & 7.5 & 6.61 & 5.92\\
            &
            & $(23.09\%)$ & $(9.52\%)$ & $(3.47\%)$ & $(0.74\%)$ & $(0\%)$ & $(0.52\%)$ & $(1.85\%)$ & $(3.73\%)$ & $(5.96\%)$ & $(8.43\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.6}
            &51.51 & 32.2 & 22.01 & 16.17 & 12.56 & 10.18 & 8.53 & 7.34 & 6.43 & 5.73\\
            &
            & $(28.32\%)$ & $(14.05\%)$ & $(6.7\%)$ & $(2.58\%)$ & $(0.58\%)$ & $(0\%)$ & $(0.41\%)$ & $(1.49\%)$ & $(3.03\%)$ & $(4.9\%)$\\
\cmidrule{2-12}
            &\multirow{2}{*}{0.7}
            &53.43 & 33.52 & 22.79 & 16.58 & 12.74 & 10.23 & 8.5 & 7.25 & 6.32 & 5.6\\
            &
            & $(33.12\%)$ & $(18.72\%)$ & $(10.46\%)$ & $(5.2\%)$ & $(2.06\%)$ & $(0.47\%)$ & $(0\%)$ & $(0.33\%)$ & $(1.23\%)$ & $(2.54\%)$\\
 \cmidrule{2-12}
            &\multirow{2}{*}{0.8}
            &55.21 & 34.85 & 23.64 & 17.08 & 13.02 & 10.36 & 8.53 & 7.23 & 6.26 & 5.52\\
            &
            & $(37.55\%)$ & $(23.43\%)$ & $(14.6\%)$ & $(8.39\%)$ & $(4.24\%)$ & $(1.7\%)$ & $(0.39\%)$ & $(0\%)$ & $(0.28\%)$ & $(1.04\%)$\\
 \cmidrule{2-12}
            &\multirow{2}{*}{0.9}
            &56.86 & 36.18 & 24.55 & 17.66 & 13.36 & 10.55 & 8.62 & 7.25 & 6.24 & 5.47\\
            &
            & $(41.65\%)$ & $(28.13\%)$ & $(19.01\%)$ & $(12.04\%)$ & $(6.98\%)$ & $(3.56\%)$ & $(1.44\%)$ & $(0.34\%)$ & $(0\%)$ & $(0.23\%)$\\
 \cmidrule{2-12}
              &\multirow{2}{*}{1.0}
            &58.39 & 37.5 & 25.49 & 18.29 & 13.76 & 10.79 & 8.76 & 7.32 & 6.26 & 5.46\\
            &
            & $(45.48\%)$ & $(32.79\%)$ & $(23.59\%)$ & $(16.05\%)$ & $(10.19\%)$ & $(5.94\%)$ & $(3.05\%)$ & $(1.25\%)$ & $(0.3\%)$ & $(0\%)$\\
      \bottomrule
      \end{tabularx}
    } % endof \scalebox
\end{table}
\end{document}

在此处输入图片描述

答案2

我简化了您的代码,并使用了siunitx包,以便将数据与列类型对齐到小数点上S。要使垂直文本垂直居中,只需向环境指示multirow行数的另一个值即可;在本例中,24 而不是 20,再加上一个小的空白,就可以了。此外,\scalebox我没有使用,而是将字体大小设置为\footnotesize和设置\ tabcolsep为 3pt。如果您发现 3pt 不够,您可以将字体大小设置为\scriptsize和 \tabcolsep 设置为5pt

\documentclass[11pt]{article}

\usepackage{rotating}

\usepackage[
 lmargin=1.0in,
 rmargin=1.0in,
 tmargin=2.0cm,
 bmargin=2.0cm
]{geometry}
\usepackage{siunitx}
\usepackage{tabularx, booktabs}
\newcolumntype{Y}{S}%{>{\centering\arraybackslash}X}
\usepackage{geometry}
\usepackage{multirow}
\usepackage{caption}
\geometry{showframe, nomarginpar}

\begin{document}

Text text text text text text text text text text text text text text text text text text text text text text text text text.

\begin{table}[!h]
    \centering
    % table caption is to be above the table
    \caption{Table title.}
\footnotesize\setlength\tabcolsep{3pt}
    \begin{tabularx}{\linewidth}{@{}l@{\quad}l *{10}{Y}@{}}
    \toprule
       & & \multicolumn{10}{c}{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}\\[2mm]
       & & 0.1 & 0.2 & 0.3 & 0.4 & 0.5 & 0.6 & 0.7 & 0.8 & 0.9 & 1.0\\
    \cmidrule[0.6pt]{3-12}%
\multirow{24}{*}{\rotatebox{90}{{Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\hskip1.5em}}} & \multirow{2}{*}{0.1}
             & 40.14 & 29.7 & 23.58 & 19.57 & 16.75 & 14.67 & 13.05 & 11.77 & 10.73 & 9.86\\
             &
             & {(0\,\%)} & {(5.18\,\%)} & {(14.29\,\%)} & {(24.2\,\%)} & {(34.18\,\%)} & {(44.0\,\%)} & {(53.58\,\%)} & {(62.89\,\%)} & {(71.92\,\%)} & {(80.68\,\%)}\\
\cmidrule{2-12}
  & \multirow{2}{*}{0.2}
  & 41.93 & 28.24 & 21.01 & 16.67 & 13.81 & 11.79 & 10.3 & 9.14 & 8.23 & 7.49\\
  &
  &{(4.47\,\%)} &{(0\,\%)} &{(1.87\,\%)} &{(5.8\,\%)} &{(10.59\,\%)} &{(15.78\,\%)} &{(21.12\,\%)} &{(26.52\,\%)} &{(31.89\,\%)} &{(37.21\,\%)}\\
\cmidrule{2-12}
  & \multirow{2}{*}{0.3}
  & 44.58 & 28.74 & 20.63 & 15.92 & 12.92 & 10.86 & 9.36 & 8.24 & 7.36 & 6.66\\
  &
  &{(11.06\,\%)} &{(1.78\,\%)} &{(0\,\%)} &{(1.03\,\%)} &{(3.44\,\%)} &{(6.6\,\%)} &{(10.17\,\%)} &{(13.99\,\%)} &{(17.93\,\%)} &{(21.93\,\%)}\\
 \cmidrule{2-12}
  & \multirow{2}{*}{0.4}
  & 47.1 & 29.74 & 20.84 & 15.76 & 12.57 & 10.43 & 8.91 & 7.77 & 6.9 & 6.21\\
  &
  &{(17.35\,\%)} &{(5.31\,\%)} &{(1.05\,\%)} &{(0\,\%)} &{(0.69\,\%)} &{(2.42\,\%)} &{(4.77\,\%)} &{(7.52\,\%)} &{(10.52\,\%)} &{(13.67\,\%)}\\
\cmidrule{2-12}
  & \multirow{2}{*}{0.5}
  & 49.41 & 30.93 & 21.34 & 15.88 & 12.49 & 10.24 & 8.66 & 7.5 & 6.61 & 5.92\\
  &
  &{(23.09\,\%)} &{(9.52\,\%)} &{(3.47\,\%)} &{(0.74\,\%)} &{(0\,\%)} &{(0.52\,\%)} &{(1.85\,\%)} &{(3.73\,\%)} &{(5.96\,\%)} &{(8.43\,\%)}\\
\cmidrule{2-12}
  & \multirow{2}{*}{0.6}
  & 51.51 & 32.2 & 22.01 & 16.17 & 12.56 & 10.18 & 8.53 & 7.34 & 6.43 & 5.73\\
  &
  &{(28.32\,\%)} &{(14.05\,\%)} &{(6.7\,\%)} &{(2.58\,\%)} &{(0.58\,\%)} &{(0\,\%)} &{(0.41\,\%)} &{(1.49\,\%)} &{(3.03\,\%)} &{(4.9\,\%)}\\
\cmidrule{2-12}
  & \multirow{2}{*}{0.7}
  & 53.43 & 33.52 & 22.79 & 16.58 & 12.74 & 10.23 & 8.5 & 7.25 & 6.32 & 5.6\\
  &
  &{(33.12\,\%)} &{(18.72\,\%)} &{(10.46\,\%)} &{(5.2\,\%)} &{(2.06\,\%)} &{(0.47\,\%)} &{(0\,\%)} &{(0.33\,\%)} &{(1.23\,\%)} &{(2.54\,\%)}\\
 \cmidrule{2-12}
  & \multirow{2}{*}{0.8}
  & 55.21 & 34.85 & 23.64 & 17.08 & 13.02 & 10.36 & 8.53 & 7.23 & 6.26 & 5.52\\
  &
  &{(37.55\,\%)} &{(23.43\,\%)} &{(14.6\,\%)} &{(8.39\,\%)} &{(4.24\,\%)} &{(1.7\,\%)} &{(0.39\,\%)} &{(0\,\%)} &{(0.28\,\%)} &{(1.04\,\%)}\\
 \cmidrule{2-12}
  & \multirow{2}{*}{0.9}
  & 56.86 & 36.18 & 24.55 & 17.66 & 13.36 & 10.55 & 8.62 & 7.25 & 6.24 & 5.47\\
  &
  &{(41.65\,\%)} &{(28.13\,\%)} &{(19.01\,\%)} &{(12.04\,\%)} &{(6.98\,\%)} &{(3.56\,\%)} &{(1.44\,\%)} &{(0.34\,\%)} &{(0\,\%)} &{(0.23\,\%)}\\
 \cmidrule{2-12}
  & \multirow{2}{*}{1.0}
  & 58.39 & 37.5 & 25.49 & 18.29 & 13.76 & 10.79 & 8.76 & 7.32 & 6.26 & 5.46\\
  &
  &{(45.48\,\%)} &{(32.79\,\%)} &{(23.59\,\%)} &{(16.05\,\%)} &{(10.19\,\%)} &{(5.94\,\%)} &{(3.05\,\%)} &{(1.25\,\%)} &{(0.3\,\%)} &{(0\,\%)}\\
      \bottomrule
      \end{tabularx}
\end{table}
\noindent Text text text text text text text text text text text text text text text text text text text text text text text text text.
\end{document} 

在此处输入图片描述

相关内容