我需要使用 xltabular,因为我有长表格(长度超过一页),其中包含长文本。但是,当我使用 xltabular 中的命令(如 \makecell、\multirow 或 \textcolor)时,xltabular 会崩溃。对于适合一页的部分表格,我可以使用 tabularx,使用这些命令没有任何问题。当我向表格中添加新行并将其从 tabularx 转换为 xltabular 时,它不起作用。有没有办法在 xltabular 中使用这些命令?
作为示例,我展示了相同的表格(适合一页),仅将其从 tabularx 转换为 xltabular。
这有效:
\documentclass[11pt, a4paper, oneside]{report}
\usepackage{tabularx}
\usepackage{ltxtable} % long tabularx
\newcolumntype{s}{>{\hsize=.6\hsize}X} % For narrower columns of indicators
\newcolumntype{S}{>{\hsize=1.1\hsize}X} % For narrower columns
\begin{document}
\begin{table}[H]
\centering
\caption{Characteristics of the indicators 'Total population' and 'Average household size' from DRC.}
\label{indicator:Numberofhouseholds}
\small
\begin{tabularx}{\textwidth}{sSSSS}
\hline
\multicolumn{5}{c}{Total population} \\ \hline
Measure \newline \makecell[r]{\textit{Base}} & \multirow{2}{\linewidth}{\centering NSP} & \multirow{2}{\linewidth}{\centering PR} & \multirow{2}{\linewidth}{\centering MF} & \multirow{2}{\linewidth}{\centering FW} \\
\hline
\textcolor{white}{.} \newline Million \newline \begin{flushright}\textit{61.8 (2009 base)}\end{flushright} & \makecell[c]{$\Downarrow$} \newline Total UK population decreases by 11\% as compared to 2010 values (UK: 55,002k). Assuming a growth rate of -0.1\% per annum from 2010 to 2025 and -0.4\% per annum from 2025 to 2050. & \makecell[c]{$\Leftrightarrow$} \newline Total UK population in 2050 reduces by 1\% as compared to 2010 values (UK: 61,184k). Assuming a growth rate of 0.1\% per annum from 2010 to 2025 and -0.1\% per annum from 2025 to 2050. & \makecell[c]{$\Leftrightarrow$} \newline Total UK population in 2050 reduces by 1\% as compared to 2010 values (UK: 61,184k). Assuming a growth rate of 0.1\% per annum from 2010 to 2025 and -0.1\% per annum from 2025 to 2050. & \makecell[c]{$\Uparrow$ | $\Uparrow$} \newline Total UK population increases by 3.0\% (UK: 63,680k). The ratio of rich to poor is 35:65 (22,288k:41,392k). Assuming a growth rate of 0.2\% per annum from 2010 to 2025 and 0.0\% per annum from 2025 to 2050.\\
\hline
\multicolumn{5}{c}{Average household size} \\ \hline
\textcolor{white}{.} \newline People per household \newline \begin{flushright}\textit{2.4}\end{flushright} & \makecell[c]{$\Uparrow$} \newline Although population is ageing, strong social and environmental drivers mean co-housing and living with extended family or in multiple family units is commonplace. & \makecell[c]{$\Leftrightarrow$} \newline Trend towards smaller household sizes continues (exacerbated by ageing population). Core values of individualism mean people do not want to share accommodation. & \makecell[c]{$\Downarrow$} \newline Trend towards smaller household sizes continues (exacerbated by ageing population). Core values of individualism mean people do not want to share accommodation. & \makecell[c]{$\Downarrow$ | $\Uparrow$} \newline Average household size may increase for the poor out of necessity, and decrease for the rich out of choice.\\
\hline
\end{tabularx}
\end{table}
\end{document}
但事实并非如此:
\documentclass[11pt, a4paper, oneside]{report}
\usepackage{tabularx}
\usepackage{ltxtable} % long tabularx
\newcolumntype{s}{>{\hsize=.6\hsize}X} % For narrower columns of indicators
\newcolumntype{S}{>{\hsize=1.1\hsize}X} % For narrower columns
\begin{document}
\begin{xltabular}{\linewidth}{ssSSSS}
\caption{Characteristics of the indicators developed.\label{indicator:Numberofhouseholds}}\\
\small
\hline
\multicolumn{5}{c}{Total population} \\ \hline
Measure \newline \makecell[r]{\textit{Base}} & \multirow{2}{\linewidth}{\centering NSP} & \multirow{2}{\linewidth}{\centering PR} & \multirow{2}{\linewidth}{\centering MF} & \multirow{2}{\linewidth}{\centering FW} \\
\hline
\textcolor{white}{.} \newline Million \newline \begin{flushright}\textit{61.8 (2009 base)}\end{flushright} & \makecell[c]{$\Downarrow$} \newline Total UK population decreases by 11\% as compared to 2010 values (UK: 55,002k). Assuming a growth rate of -0.1\% per annum from 2010 to 2025 and -0.4\% per annum from 2025 to 2050. & \makecell[c]{$\Leftrightarrow$} \newline Total UK population in 2050 reduces by 1\% as compared to 2010 values (UK: 61,184k). Assuming a growth rate of 0.1\% per annum from 2010 to 2025 and -0.1\% per annum from 2025 to 2050. & \makecell[c]{$\Leftrightarrow$} \newline Total UK population in 2050 reduces by 1\% as compared to 2010 values (UK: 61,184k). Assuming a growth rate of 0.1\% per annum from 2010 to 2025 and -0.1\% per annum from 2025 to 2050. & \makecell[c]{$\Uparrow$ | $\Uparrow$} \newline Total UK population increases by 3.0\% (UK: 63,680k). The ratio of rich to poor is 35:65 (22,288k:41,392k). Assuming a growth rate of 0.2\% per annum from 2010 to 2025 and 0.0\% per annum from 2025 to 2050.\\
\hline
\multicolumn{5}{c}{Average household size} \\ \hline
\textcolor{white}{.} \newline People per household \newline \begin{flushright}\textit{2.4}\end{flushright} & \makecell[c]{$\Uparrow$} \newline Although population is ageing, strong social and environmental drivers mean co-housing and living with extended family or in multiple family units is commonplace. & \makecell[c]{$\Leftrightarrow$} \newline Trend towards smaller household sizes continues (exacerbated by ageing population). Core values of individualism mean people do not want to share accommodation. & \makecell[c]{$\Downarrow$} \newline Trend towards smaller household sizes continues (exacerbated by ageing population). Core values of individualism mean people do not want to share accommodation. & \makecell[c]{$\Downarrow$ | $\Uparrow$} \newline Average household size may increase for the poor out of necessity, and decrease for the rich out of choice.\\
\hline
\end{tabularx}
\end{document}