표의 텍스트를 세로로 정렬하는 방법

표의 텍스트를 세로로 정렬하는 방법

테이블의 텍스트를 세로로 정렬하는 데 문제가 있습니다.

다음과 같이 새 열 유형을 정의합니다.

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

그리고 이것은 마지막 열을 제외한 모든 열에 적용됩니다. 마지막 항목에서는 왜 작동하지 않는지 아시나요?

두 번째 질문: 여러 열로 구성된 행에서 텍스트를 수직으로 정렬하는 방법은 무엇입니까?

다음은 내 코드의 전체 예입니다.

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

도와 주셔서 정말로 고맙습니다!!!

답변1

다음을 사용하여 코드를 단순화할 수 있다고 생각합니다 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}

여기에 이미지 설명을 입력하세요

관련 정보