병합된 셀, 다중 인덱스 및 텍스트 줄바꿈이 포함된 표

병합된 셀, 다중 인덱스 및 텍스트 줄바꿈이 포함된 표

이런 테이블이 있었으면 좋겠습니다.여기다른 탭에서 이미지를 열 수 있는 링크.

테이블

나에게 중요한 것은 구조다. 서식은 단지 어떤 방식으로든 나머지 부분과 비교하여 눈에 띄고 싶은 내용을 보여주기 위한 것입니다.

내가 어떻게 할:

  1. 데이터가 특정 길이를 초과하면 텍스트가 줄바꿈되는지 확인하세요.
  2. 이미지에 따라 오른쪽 하단 셀에 여러 열을 사용하시겠습니까?

내가 가진 것은 다음과 같습니다.

\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
 % Text data placeholder. May be long enough that it needs to be wrapped.
\begin{table}[ht]
    \begin{center}
        \begin{tabular}{cccc}
            \hline
            \multirow{2}{*}{Outer index 1} & Inner index 1.1 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            & Inner index 1.2 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\ 
            \hline
            \multirow{2}{*}{Outer index 2} & Inner index 2.1 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            & Inner index 2.2 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            \hline
            \multirow{6}{*}{Outer index 3} &  Inner index 3.1 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            &Inner index 3.2 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            &Inner index 3.3 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            &Inner index 3.4 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            &Inner index 3.5 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            &Inner index 3.5 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            &Inner index 3.6 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            \hline
        \end{tabular}
    \end{center}
\end{table}

\end{document}

더 나은 형식을 환영합니다. 자신만의 터치를 자유롭게 추가해보세요.

답변1

다음은 다음을 포함합니다:

  • tabularxX유형 열 및 텍스트 너비에 맞는 테이블 의 경우
  • \multicolumn 2개 열에 걸쳐 있는 셀의 경우
  • \multirow첫 번째 열의 텍스트를 세로 중앙에 배치하기 위해 값을 조정했습니다.
  • 전자가 테이블 주위에 추가 공백을 추가하므로 center환경을 다음으로 대체했습니다 .\centering
  • 간격 개선을 위해 패키지 의 수평선을 사용했습니다 booktabs.

    \documentclass[11pt]{article}
    
    \usepackage{multirow}
    \usepackage{geometry}
    \usepackage{tabularx}
    \usepackage{booktabs}
    \usepackage{ragged2e}
    \begin{document}
    
    \begin{table}[ht]
        \centering
            \begin{tabularx}{\textwidth}{cc>{\RaggedRight\arraybackslash}X>{\RaggedRight\arraybackslash}X}
                \toprule
                \multirow{6}{*}{Outer index 1} & Inner index 1.1 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
                & Inner index 1.2 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\ 
                \midrule
                \multirow{6}{*}{Outer index 2} & Inner index 2.1 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
                & Inner index 2.2 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
                \midrule
                \multirow{9}{*}{Outer index 3} &  Inner index 3.1 & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
                &Inner index 3.2 & \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax\RaggedRight\arraybackslash}X}{Text data placeholder. May be long enough that it needs to be wrapped.  Text data placeholder. May be long enough that it needs to be wrapped.}\\
                &Inner index 3.3 & \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax\RaggedRight\arraybackslash}X}{ Text data placeholder. May be long enough that it needs to be wrapped.  Text data placeholder. May be long enough that it needs to be wrapped.}\\
                \bottomrule
            \end{tabularx}
    \end{table}
    
    \end{document}
    

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


multirow여기서는 두 번째 열의 내용에도 사용했습니다 .

\documentclass[11pt]{article}

\usepackage{multirow}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{ragged2e}
\begin{document}

\begin{table}[ht]
    \centering
        \begin{tabularx}{\textwidth}{cc>{\RaggedRight\arraybackslash}X>{\RaggedRight\arraybackslash}X}
            \toprule
            \multirow{6}{*}{Outer index 1} & \multirow{3}{*}{Inner index 1.1} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            & \multirow{3}{*}{Inner index 1.2} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\ 
            \midrule
            \multirow{6}{*}{Outer index 2} & \multirow{3}{*}{Inner index 2.1} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            & \multirow{3}{*}{Inner index 2.2} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            \midrule
            \multirow{9}{*}{Outer index 3} &  \multirow{3}{*}{Inner index 3.1} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            & \multirow{3}{*}{Inner index 3.2} & \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax\RaggedRight\arraybackslash}X}{Text data placeholder. May be long enough that it needs to be wrapped.  Text data placeholder. May be long enough that it needs to be wrapped.}\\
            & \multirow{3}{*}{Inner index 3.3} & \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax\RaggedRight\arraybackslash}X}{ Text data placeholder. May be long enough that it needs to be wrapped.  Text data placeholder. May be long enough that it needs to be wrapped.}\\
            \bottomrule
        \end{tabularx}
\end{table}

\end{document}

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


두 번째 열의 텍스트를 수직 중앙에 배치하기 위해 다음 MWE에 표시된 것처럼 makecell수직 중앙 유형 열과 함께 패키지를 사용할 수도 있습니다.X

\documentclass[11pt]{article}

\usepackage{multirow}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage{makecell}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{document}

\begin{table}[ht]
    \centering
        \begin{tabularx}{\textwidth}{cc>{\RaggedRight\arraybackslash}X>{\RaggedRight\arraybackslash}X}
            \toprule
            \multirow{6}{*}{Outer index 1} & \makecell[cc]{Inner index 1.1} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            & \makecell[cc]{Inner index 1.2} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\ 
            \midrule
            \multirow{6}{*}{Outer index 2} & \makecell[cc]{Inner index 2.1} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            & \makecell[cc]{Inner index 2.2} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            \midrule
            \multirow{9}{*}{Outer index 3} &  \makecell[cc]{Inner index 3.1} & Text data placeholder. May be long enough that it needs to be wrapped. & Text data placeholder. May be long enough that it needs to be wrapped.\\
            & \makecell[cc]{Inner index 3.2} & \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax\RaggedRight\arraybackslash}X}{Text data placeholder. May be long enough that it needs to be wrapped.  Text data placeholder. May be long enough that it needs to be wrapped.}\\
            & \makecell[cc]{Inner index 3.3} & \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax\RaggedRight\arraybackslash}X}{ Text data placeholder. May be long enough that it needs to be wrapped.  Text data placeholder. May be long enough that it needs to be wrapped.}\\
            \bottomrule
        \end{tabularx}
\end{table}

\end{document}

관련 정보