
¿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}
Respuesta1
Dentro de una X
columna de tipo puede utilizarla \linebreak
para 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 \makecell
del makecell
paquete, que hace lo mismo).
Si desea utilizar la definición de \\
como sería dentro de un \centering
entorno, también puede utilizarla >{\centering\let\mynewline\\\arraybackslash}X
en su preámbulo y en su tabla \mynewline
en lugar de \linebreak
.
En cuanto a la alineación vertical de X
las celdas de tipo: puede cambiar la definición para \tabularxcolumn
usar m
en lugar de p
columnas 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}