如何垂直对齐 tabularx 表中的多列单元格?

如何垂直对齐 tabularx 表中的多列单元格?

我试图将tabularx表格的右上单元格(垂直和水平)居中,但只能水平对齐。我在序言中导入了必要的包。Y定义如下:

\newcolumntype{Y}{>{\centering\arraybackslash}X}

这是我的代码:

\begin{table}[H]
    \centering
    \begin{tabularx}{\textwidth}{|*{6}{Y|}}
        \hline
        Concentration of L-Ascorbic Acid in the Reaction Mixture$\;/\;\mathrm{M}$ & \multicolumn{5}{c|}{$\frac{1}{t_{1/2}}\;/\;s^{-1}$} \\
        \hline
    \end{tabularx}
\end{table}

答案1

评论太长了...

为了让您的评论更加清晰,请将您的表格代码片段扩展为更多行,然后扩展到 MWE(最小工作示例,一个小但完整的文档),以显示您的问题。

到目前为止,我们只能猜测你的问题是什么。让我使用你的代码片段展示三个可能的示例:

\documentclass{article}
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{tabularray}

\begin{document}
\begin{table}[ht]
\caption{With your code fragment}
    \centering
\setlength\extrarowheight{2pt}
    \begin{tabularx}{\textwidth}{|*{6}{Y|}}
        \hline
Concentration of L-Ascorbic Acid in the Reaction Mixture$\;/\;\mathrm{M}$ 
    & \multicolumn{5}{c|}{$\frac{1}{t_{1/2}}\;/\;s^{-1}$} \\
        \hline
    \end{tabularx}
\end{table}

\begin{table}[ht]
\caption{With your code fragment when  is added an empty row}
\renewcommand\tabularxcolumn[1]{m{#1}}
    \centering
\setlength\extrarowheight{2pt}
    \begin{tabularx}{\textwidth}{|*{6}{Y|}}
        \hline
Concentration of L-Ascorbic Acid in the Reaction Mixture$\;/\;\mathrm{M}$
    & \multicolumn{5}{c|}{$\frac{1}{t_{1/2}}\;/\;s^{-1}$} \\
        \hline
    &   &   &   &   &   \\
        \hline
    \end{tabularx}
\end{table}


\begin{table}[ht]
    \centering
\caption{You may looking for such table}
    \begin{tblr}{hlines, vlines,
                 colspec={l X[c, mode=dmath]},
                 rowsep={5pt}
                 }
Concentration of L-Ascorbic Acid in the Reaction Mixture/$\mathrm{M}$
    &   \frac{1}{t_{1/2}};s^{-1}        \\
    \end{tblr}
\end{table}
\end{document}

在此处输入图片描述

请添加一些有关表格用途的上下文,即阐明您的表格应该是什么样的。

相关内容