如何在 Latex 中将文本包装到我 table 的一个特定单元格中?
How can I wrap text into one specific cell of my table in Latex?
我一直在研究这个 table 但是一个单元格的文本拒绝在其中换行,我不明白为什么。
这是代码:
\setlength{\arrayrulewidth}{0.5mm}
\setlength{\tabcolsep}{16pt}
\renewcommand{\arraystretch}{1.5}
\begin{table}[H]
\begin{tabular}{|p{0.35\linewidth}|p{0.6\linewidth}|}
\hline
\multicolumn{1}{|c|}{\textbf{Control Variable}} & \textbf{Use}
\ \hline
Number of COVID-19 cases & \ \cline{1-1}
Number of COVID-19 related deaths & \multirow{-2}{*}{Used as proxies for the level of contagion each country was experiencing.}
\ \hline
Overall Government Response Index & Records how response of governments has varied over all indicators in the database, becoming stronger or weaker over course of the outbreak.
\ \hline
Stringency Index & Records strictness of ‘lockdown style’ policies that restrict behavior
\
\hline
Economic Index & Records measures such as income support and debt relief \
\hline
GDP per capita (current USD) & \cellcolor Used as a proxy for development. \
\hline
Literacy rate, adult total (percentage of people ages 15 and above) & Percentage of people age 15+ who can read and write with understanding a short simple statement about their everyday life.
\
\hline
Physicians (per 1000 people) & \ \cline{1-1}
Hospital beds (per 1000 people) &
\ \cline{1-1}
Nurses and midwives (per 1000 people) & \multirow{-3}{*}{Used as proxies for the strength of the health system.} \
\hline
Critical Fatality Rate & The Critical Fatality Rate (CFR) is the ratio between the total number of cases and the total number of deaths from a determined illness, which in this case is COVID-19. This is a measure of the pandemic’s impact. \
\hline
\end{tabular}
\caption{Table detailing all control variables and the purpose for including them}
\label{table:1}
\end{table}
这是结果:
我无法换行的行是:
\multirow{-2}{*}{Used as proxies for the level of contagion each country was experiencing.}
我该如何解决?
tabularray
包使合并单元格变得轻而易举:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{table}[htbp]
\begin{tblr}{
colspec={|X[valign=h]|X[valign=m]|},
row{1}={font=\bfseries},
cell{1}{1}={halign=c}
}
\hline
Control Variable & Use
\ \hline
Number of COVID-19 cases & \SetCell[r=2]{} Used as proxies for the level of contagion each country was experiencing. \ \cline{1-1}
Number of COVID-19 related deaths &
\ \hline
Overall Government Response Index & Records how response of governments has varied over all indicators in the database, becoming stronger or weaker over course of the outbreak.
\ \hline
Stringency Index & Records strictness of ‘lockdown style’ policies that restrict behavior
\
\hline
Economic Index & Records measures such as income support and debt relief \
\hline
GDP per capita (current USD) & Used as a proxy for development. \
\hline
Literacy rate, adult total (percentage of people ages 15 and above) & Percentage of people age 15+ who can read and write with understanding a short simple statement about their everyday life.
\
\hline
Physicians (per 1000 people) & \SetCell[r=3]{} Used as proxies for the strength of the health system. \ \cline{1-1}
Hospital beds (per 1000 people) &
\ \cline{1-1}
Nurses and midwives (per 1000 people) & \
\hline
Critical Fatality Rate & The Critical Fatality Rate (CFR) is the ratio between the total number of cases and the total number of deaths from a determined illness, which in this case is COVID-19. This is a measure of the pandemic’s impact. \
\hline
\end{tblr}
\caption{Table detailing all control variables and the purpose for including them}
\label{table:1}
\end{table}
\end{document}
我一直在研究这个 table 但是一个单元格的文本拒绝在其中换行,我不明白为什么。
这是代码:
\setlength{\arrayrulewidth}{0.5mm}
\setlength{\tabcolsep}{16pt}
\renewcommand{\arraystretch}{1.5}
\begin{table}[H]
\begin{tabular}{|p{0.35\linewidth}|p{0.6\linewidth}|}
\hline
\multicolumn{1}{|c|}{\textbf{Control Variable}} & \textbf{Use}
\ \hline
Number of COVID-19 cases & \ \cline{1-1}
Number of COVID-19 related deaths & \multirow{-2}{*}{Used as proxies for the level of contagion each country was experiencing.}
\ \hline
Overall Government Response Index & Records how response of governments has varied over all indicators in the database, becoming stronger or weaker over course of the outbreak.
\ \hline
Stringency Index & Records strictness of ‘lockdown style’ policies that restrict behavior
\
\hline
Economic Index & Records measures such as income support and debt relief \
\hline
GDP per capita (current USD) & \cellcolor Used as a proxy for development. \
\hline
Literacy rate, adult total (percentage of people ages 15 and above) & Percentage of people age 15+ who can read and write with understanding a short simple statement about their everyday life.
\
\hline
Physicians (per 1000 people) & \ \cline{1-1}
Hospital beds (per 1000 people) &
\ \cline{1-1}
Nurses and midwives (per 1000 people) & \multirow{-3}{*}{Used as proxies for the strength of the health system.} \
\hline
Critical Fatality Rate & The Critical Fatality Rate (CFR) is the ratio between the total number of cases and the total number of deaths from a determined illness, which in this case is COVID-19. This is a measure of the pandemic’s impact. \
\hline
\end{tabular}
\caption{Table detailing all control variables and the purpose for including them}
\label{table:1}
\end{table}
这是结果:
我无法换行的行是:
\multirow{-2}{*}{Used as proxies for the level of contagion each country was experiencing.}
我该如何解决?
tabularray
包使合并单元格变得轻而易举:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{table}[htbp]
\begin{tblr}{
colspec={|X[valign=h]|X[valign=m]|},
row{1}={font=\bfseries},
cell{1}{1}={halign=c}
}
\hline
Control Variable & Use
\ \hline
Number of COVID-19 cases & \SetCell[r=2]{} Used as proxies for the level of contagion each country was experiencing. \ \cline{1-1}
Number of COVID-19 related deaths &
\ \hline
Overall Government Response Index & Records how response of governments has varied over all indicators in the database, becoming stronger or weaker over course of the outbreak.
\ \hline
Stringency Index & Records strictness of ‘lockdown style’ policies that restrict behavior
\
\hline
Economic Index & Records measures such as income support and debt relief \
\hline
GDP per capita (current USD) & Used as a proxy for development. \
\hline
Literacy rate, adult total (percentage of people ages 15 and above) & Percentage of people age 15+ who can read and write with understanding a short simple statement about their everyday life.
\
\hline
Physicians (per 1000 people) & \SetCell[r=3]{} Used as proxies for the strength of the health system. \ \cline{1-1}
Hospital beds (per 1000 people) &
\ \cline{1-1}
Nurses and midwives (per 1000 people) & \
\hline
Critical Fatality Rate & The Critical Fatality Rate (CFR) is the ratio between the total number of cases and the total number of deaths from a determined illness, which in this case is COVID-19. This is a measure of the pandemic’s impact. \
\hline
\end{tblr}
\caption{Table detailing all control variables and the purpose for including them}
\label{table:1}
\end{table}
\end{document}