Tabla con celdas fusionadas, índice múltiple y ajuste de texto

Tabla con celdas fusionadas, índice múltiple y ajuste de texto

Me gustaría tener una mesa como esta.Aquí estáun enlace para abrir la imagen en otra pestaña.

mesa

Lo que me importa es la estructura. El formato es sólo para mostrar lo que me gustaría destacar del resto de alguna manera.

Cómo puedo:

  1. Asegúrese de que el texto esté ajustado cuando los datos tengan más de una longitud específica.
  2. ¿Utilizar varias columnas para las celdas inferiores derechas, según la imagen?

Esto es lo que tengo:

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

Un mejor formato es bienvenido. Siéntete libre de añadir tu propio toque.

Respuesta1

Lo siguiente incluye:

  • tabularxpara Xescribir columnas y una tabla que se ajuste al ancho del texto
  • \multicolumn para las celdas que abarcan 2 columnas
  • valores ajustados de \multirowpara centrar verticalmente el texto en la primera columna
  • centerambiente reemplazado por \centeringya que el primero agrega espacio en blanco adicional alrededor de la mesa
  • Usé líneas horizontales del booktabspaquete para mejorar el espaciado.

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

ingrese la descripción de la imagen aquí


Aquí también he usado multirowpara el contenido de la segunda columna:

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

ingrese la descripción de la imagen aquí


Para centrar verticalmente el texto en la segunda columna, también puede usar el makecellpaquete en combinación con Xcolumnas de tipo centradas verticalmente como se muestra en el siguiente MWE:

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

información relacionada