0

\multirow结合使用时,我注意到一些奇怪的行为\multicolumn

以下代码的pdf输出

  • 头部 1.1 应垂直居中。

  • head 1.2 应该是垂直和水平居中的

是否有替代解决方案可以\multirow\multicolumnLaTeX 表创建更复杂的标题,或者是否有解决我的问题的方法?

\documentclass{article}
\usepackage{multirow}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}

\begin{document}

\begin{table}[ht]
\centering
\begin{tabular}{|r|r|r|r|}
\multicolumn{1}{|C{2cm}}{\multirow{3}{*}{head 1.1}} &
\multicolumn{2}{|C{2cm}}{\multirow{2}{*}{head 1.2}} &
\multicolumn{1}{|C{2cm}}{head 1.3 which is longer than expected} \\ \hline
& & & \multicolumn{1}{|C{2cm}}{head 2.3} \\
& \multicolumn{1}{|C{2cm}}{head 2.2.1} & 
\multicolumn{1}{|C{2cm}}{head 2.2.2} &
\multicolumn{1}{|C{2cm}}{head 3.3}
\end{tabular}
\end{table}

\end{document}
4

1 回答 1

2

我建议使用 堆叠您的多级标题/单元格tabular,这自然会相对于其他单元格垂直居中。这种tabular堆叠很容易使用makecell

在此处输入图像描述

\documentclass{article}

\usepackage{makecell}

\begin{document}

\begin{tabular}{|r|r|r|r|}
  head 1.1 & 
    \multicolumn{2}{c|}{head 1.2} & 
    \makecell{head 1.3 \\ which is \\ longer than \\ expected} \\
  \hline
    & head 2.2.1 & head 2.2.2 & \makecell{head 2.3 \\ head 3.3}
\end{tabular}

\end{document}

[t]在将单元格与op 或[b]ottom对齐时也存在其他选项。

于 2017-09-28T17:25:48.653 回答