如何垂直對齊 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(最小工作範例,一個小但完整的文件),它顯示您的問題。

到目前為止我們只能猜測,你的問題是什麼。讓 mi 使用您的程式碼片段展示三個可能的範例:

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

在此輸入影像描述

請添加一些使用您的表格的上下文,即澄清您的表格應該是什麼樣的。

相關內容