Cómo alinear verticalmente el texto en una tabla

Cómo alinear verticalmente el texto en una tabla

Tengo problemas para alinear verticalmente el texto en mi tabla.

Defino un nuevo tipo de columna como este:

\newcolumntype{M}{>{\centering\arraybackslash}m{\dimexpr.25\linewidth-2\tabcolsep}}

Y esto funciona para todas las columnas excepto la última. ¿Alguna idea de por qué no funciona para el último?

La segunda pregunta: ¿cómo alinear verticalmente el texto en filas de varias columnas?

Aquí está el ejemplo completo de mi código.

\documentclass[aps,pre,superscriptaddress,unsortedaddress,twocolumn,showpacs]{revtex4}

\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{threeparttable} 
\usepackage{array}% http://ctan.org/pkg/array
\newcolumntype{M}{>{\centering\arraybackslash}m{\dimexpr.25\linewidth-2\tabcolsep}}



\begin{document}
\begin{table}[!htp]
\begin{threeparttable}
\caption{Summary.} {\small\label{table:S2}}\centering 
\small
\begin{tabularx}{\textwidth}{ |X|M|M| }


\multicolumn{3}{M}{LONG TEXT}\\[4ex]\hline
      &  text         &   text \\\hline
text  &  complex text & complex text \\[6ex]\hline
text  &  complex text &  complex text   \\[6ex]\hline
text  & complex text  & complex text  \\[6ex]\hline

\multicolumn{3}{M}{LONG TEXT}  \\[4ex]\hline
     & text            &  text  \\\hline
text &  complex text   & complex text \\[6ex]\hline
text & complex text    & complex text   \\[6ex]\hline
text &   complex text  & complex text \\[6ex]\hline


  \hline
  \end{tabularx}
    \end{threeparttable}
\end{table}

\end{document}

¡¡¡Muchas gracias por tu ayuda!!!

Respuesta1

Creo que puedes simplificar tu código usando tabularray:

\documentclass[aps,pre,superscriptaddress,unsortedaddress,twocolumn,showpacs]{revtex4}

\usepackage{tabularray}

\begin{document}
\begin{table}[!htp]
    \caption{Summary.}\label{table:S2}
    \begin{tblr}{
        width=\linewidth,
        colspec={X[2]X[c]X[c]},
        hline{2-Z}={solid},
        vline{1-Z}={2-5, 7-Z}{solid},
        row{1,6}={ht=4ex},
        row{3-5,8-Z}={ht=6ex},
        row{2,7}={abovesep=1ex},
        row{1,6}={abovesep=2ex},
        }
        \SetCell[c=3]{c} LONG TEXT & & \\     
        & text & text \\
        text & complex text & complex text \\
        text & complex text & complex text \\
        text & complex text & complex text \\
        \SetCell[c=3]{c} LONG TEXT & & \\
        & text & text \\
        text & complex text & complex text \\
        text & complex text & complex text \\
        text & complex text & complex text 
    \end{tblr}
\end{table}
\end{document}

ingrese la descripción de la imagen aquí

información relacionada