【问题标题】:latex combining multirow and multicolumn乳胶结合多行和多列
【发布时间】:2017-09-28 15:51:54
【问题描述】:

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

  • head 1.1 应该垂直居中。

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

\multirow\multicolumn 是否有替代解决方案来为 LaTeX 表创建更复杂的标题,或者是否有解决我的问题的方法?

\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}

【问题讨论】:

    标签: latex multirow


    【解决方案1】:

    我建议使用tabular 堆叠您的多级标题/单元格,这自然会使其相对于其他单元格垂直居中。使用makecell 可以轻松实现这种tabular 堆叠:

    \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 对齐时,还存在其他选项。

    【讨论】:

      猜你喜欢
      • 2011-01-12
      • 1970-01-01
      • 2010-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-14
      • 1970-01-01
      • 2012-12-08
      相关资源
      最近更新 更多