帮助格式化表格

帮助格式化表格

我想将此表添加到乳胶文档中,但在格式化它时遇到了问题...您能告诉我如何开始吗?

我尝试了以下操作,但出现了错误:

Misplaced \noalign.
\toprule ->\noalign 
                    {\ifnum 0=`}\fi \@aboverulesep =\abovetopsep \global \@b...
l.190 \toprule


\begin{tabular}{cccc}
% \caption{Subject Group Characteristics}
\label{tab:one}
\toprule
 & All COPD* & Matching healthy & Matching COPD**\\
\midrule
 & n = 1059 & n = 66 & n = 66\\
\midrule
Male/Female (n) & 689/370 & 30/36 & 30/36\\
\midrule
Age (years) & 66 [61–72] & 65 [61–70] & 65 [61–70]\\
\midrule
BMI ($kg/m^{2}$) & 25.9 [22.5–29.6] & 25.2 [23–27.3] & 25 [22.5–27.8]\\
\midrule
$FEV_1 (\% predicted)$ & 49 [34–64] & 107 [97–117] & 42 [29–63]\\
\midrule
GOLD 1–2–3–4 (n) & 93–419–354–193 & - & 8–16–23–19\\
\midrule
MMRC 0-1-2-3-4 (n) & 145-279-228-195-67 & 44-1-0-1-0 & 6-15-18-15-5\\
\midrule
Assessed nights (n) & 6446 & 404 & 411\\
\midrule
Weekdays (\%) & 67.3 & 69 & 65\\
\midrule
Nights per subject & 6 [6–6] & 6 [6–6] & 6 [6–6]\\
\bottomrule
% Data are summarized as absolute amount (n), relative amount (\%), or median and quartiles [Q1–Q3]. *MMRC data for 914 subjects. **MMRC data for 59 subjects.
\end{tabular}

在此处输入图片描述

答案1

下面看起来好一点,并且允许你想要的标题。表格不太容易阅读,因为大多数条目都是整数,所以它们肯定应该按其相应的数字对齐,但不同条目中的整数数量不同。我不知道该怎么办。另一方面,其他条目是百分比。必须有更好的方法来呈现您的信息,但问题与 TeX 无关。

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\caption{\textbf{Subject Group Characteristics.} Data are summarized as absolute amount (n), relative amount (\%), or median and quartiles [Q1–Q3]. *MMRC data for 914 subjects. **MMRC data for 59 subjects.}
\label{tab:one}
\begin{tabular}{cccc}
\toprule
 & All COPD* & Matching healthy & Matching COPD**\\
 & n = 1059 & n = 66 & n = 66\\
\midrule
Male/Female (n) & 689/370 & 30/36 & 30/36\\
Age (years) & 66 [61–72] & 65 [61–70] & 65 [61–70]\\
BMI ($kg/m^{2}$) & 25.9 [22.5–29.6] & 25.2 [23–27.3] & 25 [22.5–27.8]\\
$FEV_1$ (\% predicted) & 49 [34–64] & 107 [97–117] & 42 [29–63]\\
GOLD 1–2–3–4 (n) & 93–419–354–193 & - & 8–16–23–19\\
MMRC 0-1-2-3-4 (n) & 145-279-228-195-67 & 44-1-0-1-0 & 6-15-18-15-5\\
Assessed nights (n) & 6446 & 404 & 411\\
Weekdays (\%) & 67.3 & 69 & 65\\
Nights per subject & 6 [6–6] & 6 [6–6] & 6 [6–6]\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

答案2

只需删除标签\label{tab:one},您的代码就可以正常工作,请参阅下文:

\documentclass{book}
\usepackage{booktabs}
\begin{document}

\begin{table}\label{tab:one}
\begin{tabular}{cccc}
% \caption{Subject Group Characteristics}
\toprule
 & All COPD* & Matching healthy & Matching COPD**\\
\midrule
 & n = 1059 & n = 66 & n = 66\\
\midrule
Male/Female (n) & 689/370 & 30/36 & 30/36\\
\midrule
Age (years) & 66 [61–72] & 65 [61–70] & 65 [61–70]\\
\midrule
BMI ($kg/m^{2}$) & 25.9 [22.5–29.6] & 25.2 [23–27.3] & 25 [22.5–27.8]\\
\midrule
$FEV_1 (\% predicted)$ & 49 [34–64] & 107 [97–117] & 42 [29–63]\\
\midrule
GOLD 1–2–3–4 (n) & 93–419–354–193 & - & 8–16–23–19\\
\midrule
MMRC 0-1-2-3-4 (n) & 145-279-228-195-67 & 44-1-0-1-0 & 6-15-18-15-5\\
\midrule
Assessed nights (n) & 6446 & 404 & 411\\
\midrule
Weekdays (\%) & 67.3 & 69 & 65\\
\midrule
Nights per subject & 6 [6–6] & 6 [6–6] & 6 [6–6]\\
\bottomrule
% Data are summarized as absolute amount (n), relative amount (\%), or median and quartiles [Q1–Q3]. *MMRC data for 914 subjects. **MMRC data for 59 subjects.
\end{tabular}
\end{table}
\end{document}

相关内容