如何使我的初学者表格中的换行/多行功能起作用?

如何使我的初学者表格中的换行/多行功能起作用?

我似乎无法让multirowpbox给我一个换行符(“自动”宽度)。以下内容无法成功编译:请注意“TOTALLY”行中的两个变体。我该如何修复它?

\documentclass{article}
\usepackage{tabulary}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{pbox}
\usepackage{lipsum}

\renewcommand{\arraystretch}{1.2}
\sisetup{round-mode=places,round-precision=1, add-decimal-zero=true, add-integer-zero=true, round-integer-to-decimal}

\begin{document}

\lipsum[1]


\begin{table}
\begin{threeparttable}
\caption{this is my first table's captive caption}
\begin{tabulary}{\textwidth}{@{}*{2}{L}*{6}{S[table-format=3.2]}@{}} \toprule
× & TOTALLY bla percentage of bla & {1000} & {2000} & {3000} & \pbox[t]{1.5cm}{Bonjour monde!} & {5000} & {6000\tnote{1}}\\ \midrule
% × & TOTALLY bla percentage of bla & {1000} & {2000} & {3000} & \multirow{2}*{4000 apples and pears \\ and whatnot} & {5000} & {6000\tnote{1}}\\ \midrule
DDD 1 & 47.6 & 29.1 & 1.0 & 0.2 & 1.9 & 15.2 & 0.0\\
UUU & 24.8 & 10.8 & 6.4 & 0.0 & 3.2 & 4.5 & 0.0\\
× & × & × & × & × & × & × & ×\\
Unweighted average: & × & × & × & × & × & × & ×\\
BBB & 33.8 & 11.3 & 9.1 & 0.4 & 1.8 & 11.0 & 0.2\\
GGG & 32.9904 & 8.60325 & 9.3845 & 0.0495 & 1.43225 & 10.79525 & 0.119\\
DDD & 39.4545 & 9.8695 & 15.3365 & 0.6915 & 2.246 & 10.6705 & 0.5105\\ \bottomrule
\end{tabulary}

\begin{tablenotes}
\item [1] the first note ...
\end{tablenotes}

\end{threeparttable}
\end{table}

\lipsum[2]

\end{document}

相关(但还没有帮助我):

所以这个问题可能只是另一个初学者绝望的重复...请原谅!

编辑

只是为了提供一个工作示例(为了快速比较,请注意我删除了\\未注释的“TOTALLY”行):

\documentclass{article}
\usepackage{tabulary}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{pbox}
\usepackage{lipsum}

\renewcommand{\arraystretch}{1.2}
\sisetup{round-mode=places,round-precision=1, add-decimal-zero=true, add-integer-zero=true, round-integer-to-decimal}

\begin{document}

\lipsum[1]


\begin{table}
\begin{threeparttable}
\caption{this is my first table's captive caption}
\begin{tabulary}{\textwidth}{@{}*{2}{L}*{6}{S[table-format=3.2]}@{}} \toprule
× & TOTALLY bla percentage of bla & {1000} & {2000} & {3000} & {4000 apples and pears and whatnot} & {5000} & {6000\tnote{1}}\\ \midrule
%× & TOTALLY bla percentage of bla & {1000} & {2000} & {3000} & {4000 apples and pears \\ and whatnot} & {5000} & {6000\tnote{1}}\\ \midrule
% × & TOTALLY bla percentage of bla & {1000} & {2000} & {3000} & \pbox[t]{1.5cm}{Bonjour monde!} & {5000} & {6000\tnote{1}}\\ \midrule
% × & TOTALLY bla percentage of bla & {1000} & {2000} & {3000} & {\multirow{2}*{\pbox[t]{1.5cm}{Bonjour monde!}}} & {5000} & {6000\tnote{1}}\\ \midrule
DDD 1 & 47.6 & 29.1 & 1.0 & 0.2 & 1.9 & 15.2 & 0.0\\
UUU & 24.8 & 10.8 & 6.4 & 0.0 & 3.2 & 4.5 & 0.0\\
× & × & × & × & × & × & × & ×\\
Unweighted average: & × & × & × & × & × & × & ×\\
BBB & 33.8 & 11.3 & 9.1 & 0.4 & 1.8 & 11.0 & 0.2\\
GGG & 32.9904 & 8.60325 & 9.3845 & 0.0495 & 1.43225 & 10.79525 & 0.119\\
DDD & 39.4545 & 9.8695 & 15.3365 & 0.6915 & 2.246 & 10.6705 & 0.5105\\ \bottomrule
\end{tabulary}

\begin{tablenotes}
\item [1] the first note ...
\end{tablenotes}

\end{threeparttable}
\end{table}

\lipsum[2]

\end{document}

答案1

在此处输入图片描述

您在第一行中出现了 utf08 次,但未声明任何编码,因此它被默默地删除了,我补充道

\usepackage[utf8]{inputenc}\usepackage{textcomp}

所以它起作用了,那么获得多行标题的最简单方法是使用\multicolumn{1}退出S然后嵌套tabular(我可能应该使用\begin{tabular}[t]但图像显示默认的垂直居中排列。

\documentclass{article}
\usepackage{tabulary}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{pbox}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}\usepackage{textcomp}
\renewcommand{\arraystretch}{1.2}
\sisetup{round-mode=places,round-precision=1, add-decimal-zero=true, add-integer-zero=true, round-integer-to-decimal}

\begin{document}

\lipsum[1]


\begin{table}
\begin{threeparttable}
\caption{this is my first table's captive caption}
\begin{tabulary}{\textwidth}{@{}*{2}{L}*{6}{S[table-format=3.2]}@{}} \toprule
× & TOTALLY bla percentage of bla & {1000} & {2000} & {3000} & 
\multicolumn{1}{c}{\begin{tabular}{@{}c@{}}Bonjour\tabularnewline monde!\end{tabular}} &
 {5000} & {6000\tnote{1}}\\ \midrule
% × & TOTALLY bla percentage of bla & {1000} & {2000} & {3000} & \multirow{2}*{4000 apples and pears \\ and whatnot} & {5000} & {6000\tnote{1}}\\ \midrule
DDD 1 & 47.6 & 29.1 & 1.0 & 0.2 & 1.9 & 15.2 & 0.0\\
UUU & 24.8 & 10.8 & 6.4 & 0.0 & 3.2 & 4.5 & 0.0\\
× & × & × & × & × & × & × & ×\\
Unweighted average: & × & × & × & × & × & × & ×\\
BBB & 33.8 & 11.3 & 9.1 & 0.4 & 1.8 & 11.0 & 0.2\\
GGG & 32.9904 & 8.60325 & 9.3845 & 0.0495 & 1.43225 & 10.79525 & 0.119\\
DDD & 39.4545 & 9.8695 & 15.3365 & 0.6915 & 2.246 & 10.6705 & 0.5105\\ \bottomrule
\end{tabulary}

\begin{tablenotes}
\item [1] the first note ...
\end{tablenotes}

\end{threeparttable}
\end{table}

\lipsum[2]

\end{document}

相关内容