为什么“\makecell”没有为这一特定行提供正确的垂直对齐?

为什么“\makecell”没有为这一特定行提供正确的垂直对齐?

我正在尝试使用 对齐表格单元格内容\makecell。令我感到很奇怪的是(在同一个表格中),一行按预期垂直对齐,而另一行却没有。我希望单词“组件”和“阻抗”与“电压-电流关系”底部对齐。[b]我认为这应该使用选项来完成。

在此处输入图片描述

这是我的 MWE:

\documentclass{article}

\usepackage{makecell}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}
    
    \begin{tabularx}{\textwidth}{X X X X X}
        
        \makecell[b]{Component} & \makecell[b]{Voltage-Current \\ Relationship} & \makecell[b]{Component} & \makecell[b]{Voltage-Current \\ Relationship} & \makecell[b]{Impedance}
        \\
        
        \makecell[b]{top \\ center \\ bottom} & \makecell[t]{top \\ center \\ bottom} & \makecell[c]{top \\ center \\ bottom} & \makecell[t]{top \\ center \\ bottom} & \makecell[c]{top \\ center \\ bottom}
        \\
        
    \end{tabularx}
    
\end{document}

答案1

重新定义X列并仅使用一个X。A

\documentclass{article}

\usepackage{makecell}
\usepackage{tabularx}
\usepackage{booktabs}


\begin{document}
    
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{c c c c X}
    \hline
    \makecell[b]{Component} & \makecell[b]{Voltage-Current \\ Relationship} & \makecell[b]{Component} & \makecell[b]{Voltage-Current \\ Relationship} & \makecell[b]{Impedance}
    \\\hline
    
    \makecell[t]{Component} & \makecell[t]{Voltage-Current \\ Relationship} & \makecell[t]{Component} & \makecell[t]{Voltage-Current \\ Relationship} & \makecell[t]{Impedance}
    \\\hline
    
    \makecell[c]{Component} & \makecell[c]{Voltage-Current \\ Relationship} & \makecell[c]{Component} & \makecell[c]{Voltage-Current \\ Relationship} & \makecell[c]{Impedance}
    \\\hline

\end{tabularx}

\end{document}

使用新包装非常容易tabularray

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{tblr}{%
    colspec = {ccccX},
    width = \linewidth,
    row{1}={valign=b},
    row{2}={valign=t},
    row{3}={valign=m},
      }
    \hline
    Component & {Voltage-Current \\ Relationship} & Component &{Voltage-Current \\ Relationship} & Impedance\\ \hline
    Component & {Voltage-Current \\ Relationship} & Component &{Voltage-Current \\ Relationship} & Impedance\\ \hline
    Component & {Voltage-Current \\ Relationship} & Component &{Voltage-Current \\ Relationship} & Impedance\\
    \hline  
\end{tblr}
    
\end{document}

括号\\可以在单元格内使用。请注意,行也是垂直居中的。

是

相关内容