¿Cómo configurar el texto central vertical en las tablas y agregar entradas cuando se usa tabularx?

¿Cómo configurar el texto central vertical en las tablas y agregar entradas cuando se usa tabularx?

¿Cómo centro verticalmente el texto en las tablas, como "Autor 1 (año)" y cómo agrego entradas entre palabras en las tablas para que el texto quede uno debajo del otro, como con las palabras Guerra, Revolución y Desórdenes civiles?

\begin{table}[H]
\caption{Three levels of political risks} 
\label{tab:rcpol}
\footnotesize
\begin{tabularx}{\linewidth}{@{} c *{3}{>{\centering\arraybackslash}X} @{}}
\toprule 
\textbf{References} & \textbf{Macro risks} & \textbf{Meso risks} & \textbf{Micro risks}  \\
\midrule
Author 1 (Year)       
    &  Corruption   
        &  Government intervention
             &  Expropriation; 
                Nationalisation of assets
    \\ \midrule
Author 2 (Year)     
    &  War; Revolution; Civil disorders
        &   \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth
                          \centering\arraybackslash}X}{%
        Inconsistent government policies } 
    \\ 

\bottomrule
\end{tabularx}
\end{table}

ingrese la descripción de la imagen aquí

Respuesta1

Dentro de una Xcolumna de tipo puede utilizarla \linebreakpara insertar saltos de línea. Dentro de una celda normal, puede usar una \begin{tabular}{@{} <col> @{}}<content>\end{tabular}construcción para insertar saltos de línea (o usarla \makecelldel makecellpaquete, que hace lo mismo).

Si desea utilizar la definición de \\como sería dentro de un \centeringentorno, también puede utilizarla >{\centering\let\mynewline\\\arraybackslash}Xen su preámbulo y en su tabla \mynewlineen lugar de \linebreak.

En cuanto a la alineación vertical de Xlas celdas de tipo: puede cambiar la definición para \tabularxcolumnusar men lugar de pcolumnas de tipo para contenido centrado verticalmente.

\documentclass[]{article}

\usepackage{tabularx}
\usepackage{booktabs}

% change the column type of tabularx to use `m` instead of `p` for the vertical
% centering:
\renewcommand\tabularxcolumn[1]{m{#1}}

\begin{document}
\begin{table}
\caption{Three levels of political risks} 
\label{tab:rcpol}
\footnotesize
\begin{tabularx}{\linewidth}{@{} c *{3}{>{\centering\arraybackslash}X} @{}}
\toprule 
\textbf{References} & \textbf{Macro risks} & \textbf{Meso risks} & \textbf{Micro risks}  \\
\midrule
Author 1 (Year)       
    &  Corruption   
        &  Government intervention
             &  Expropriation; 
                Nationalisation of assets
    \\ \midrule
Author 2 (Year)     
    &  War; Revolution; Civil disorders
        &   \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth
                          \centering\arraybackslash}X}{%
        Inconsistent government policies } 
    \\ 
    author & En-\linebreak forcing\linebreak line\linebreak breaks 
    \\
    \begin{tabular}[]{@{}c@{}}
      line\\breaks\\in\\a\\normal\\cell
    \end{tabular}
    & other cell & other cell
    \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

ingrese la descripción de la imagen aquí

información relacionada