0

I am trying to center (vertically and horizontally) the top right cell of my tabularx table but I could only align it horizontally. I have imported the necessary packages in my preamble. This is how Y is defined:

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

and this is my code:

\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
  • Welcome to TeX.SE! Why you define 6 columns when you actually need only two? To make this clear, please extend your code fragment to more rows and then extend it to small but complete small document beginning with \documentclass and ending with \end{document}.
    – Zarko
    Oct 9, 2022 at 23:57

1 Answer 1

2

Too long for the comment ...

That your comment will be more clear, please extend your table code fragment with some more rows and then extend to an MWE (Minimal Working Example, a small but complete document), which show your problem.

So far we can only guess, what is your problem. Let mi show three possible examples using your code fragment:

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

enter image description here

Please, add some context to use of your table, i.e. clarify, what your table should like.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .