Como definir texto centralizado verticalmente em tabelas e adicionar entradas ao usar tabularx?

Como definir texto centralizado verticalmente em tabelas e adicionar entradas ao usar tabularx?

Como centralizo verticalmente o texto nas tabelas, como "Autor 1 (Ano)" e como adiciono entradas entre palavras nas tabelas para que o texto fique um abaixo do outro, como acontece com as palavras Guerra, Revolução e Desordens civis?

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

insira a descrição da imagem aqui

Responder1

Dentro de uma Xcoluna de tipo você pode usar \linebreakpara inserir quebras de linha. Dentro de uma célula normal, você pode usar uma \begin{tabular}{@{} <col> @{}}<content>\end{tabular}construção para inserir quebras de linha (ou usar \makecelldo makecellpacote, que faz o mesmo).

Se você quiser usar a definição de \\como seria dentro de um \centeringambiente, você também pode usar >{\centering\let\mynewline\\\arraybackslash}Xem seu preâmbulo e em sua tabela \mynewlineem vez de \linebreak.

Quanto ao alinhamento vertical das Xcélulas de tipo: Você pode alterar a definição para \tabularxcolumnusar mem vez de pcolunas de tipo para conteúdo centralizado 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}

insira a descrição da imagem aqui

informação relacionada