我是 Latex 新手,想制作一个有 6 列的表格,但下面的代码不起作用。有什么建议吗

我是 Latex 新手,想制作一个有 6 列的表格,但下面的代码不起作用。有什么建议吗
\documentclass{article}

\begin{document}

\centering
\begin{table}[h]
\caption {Annual average concentrations of air pollutants and traffic indicators and corresponding Spearman correlation coefficients (N = 2,944). Current European air quality standards (1 year average): 40 μg/m3 (PM10); 25 μg/m3 (PM2.5); 40 μg/m3 (NO2). WHO recommendations (1 year average): 20 μg/m³ (PM10); 10 μg/m³ (PM2.5); 40 μg/m3 (NO2).}
\centering
\label {aggiungi}
\begin{tabular}{l*{6}{c}}

\hline
$Descriptives$&                   & $Spearman correlation coefficients$   \\\hline 
$Exposure$&     & $Mean$     & $SD$ & $5th centile$  & $Median$  & $95th centile$\\\hline

$PM10(µg\m3)$    & 20.38    & 2.42  & 16.45 & 20.49 & 24.32 \\
$PMCoarse(µg\m3)$& 6.24   & 1.08    & 4.84  & 6.07  & 8.44   \\
$PM25(µg\m3)$    & 13.55    & 0.85  & 12.5  & 13.4  & 15.29   \\ 
$PM25abs(µg\m3)$ & 1.69   & 0.17    & 1.46  & 1.67  & 1.99     \\
$NOX(µg\m3)$     & 32.7   & 7.28    & 23.83 & 31.34 & 46.66     \\
$NO2(µg\m3)$     & 18.77    & 3.83  & 13.76 & 18.28 & 25.62      \\\hline
\end{tabular}
\end{table}
\end{document} 

答案1

列有点乱。据我所见,只有六列,而不是七列。此外,数学模式不应被误用于排版纯文本。

修复示例

  • 制定booktabs更完善的规则,
  • 包装caption以便更好地在表格上方留出表格标题的间距,
  • siunitx用于排版单位和将表格数字与小数点对齐的包,
  • lmodern更好的标准字体包,
  • ...

示例文件:

\documentclass{article}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{siunitx}
\sisetup{
  per-mode=symbol,
  group-separator={,},
  group-four-digits,
  % The input with the comma as group separator,
  % \num{2,944} (almost three thousand), can be supported by options:
  % input-decimal-markers={.},
  % input-ignore={,},
}

\DeclareSIUnit{\ugpcm}{\micro\gram\per\cubic\meter}
% u for micro (\ug is an abbreviation in package siunit for micro gram)
% g for gram
% p for per
% c for cubic
% m for meter

\begin{document}

\begin{table}
  \centering
  % The optional argument with a shorter version (it's still quite long)
  % for the list of tables
  \caption[Annual average concentrations of the air pollutants
    and traffic indicators and corresponding Spearman correlation
    coefficients]
  {Annual average concentrations of air pollutants and traffic
    indicators and corresponding Spearman correlation coefficients
    (N = \num{2944}).
    Current European air quality standards (1~year average):
    \SI{40}{\ugpcm} (PM10);
    \SI{25}{\ugpcm} (PM2.5);
    \SI{40}{\ugpcm} (NO2).
    WHO recommendations (1~year average):
    \SI{20}{\ugpcm} (PM10);
    \SI{10}{\ugpcm} (PM2.5);
    \SI{40}{\ugpcm} (NO2).}
  \label{aggiungi}
  \begin{tabular}{
    l
    S[table-format=2.2]
    S[table-format=1.2]
    *{3}{S[table-format=2.2]}
  }
    \toprule
    Descriptives & \multicolumn{5}{c}{Spearman correlation coefficients} \\
    \cmidrule{2-6}
    Exposure & {Mean} & {SD} & {5th centile}  & {Median}  & {95th centile} \\
    \midrule
    PM10 (\si{\ugpcm}) &
      20.38    & 2.42  & 16.45 & 20.49 & 24.32 \\
    PMCoarse (\si{\ugpcm}) &
      6.24   & 1.08    & 4.84  & 6.07  & 8.44  \\
    PM25 (\si{\ugpcm}) &
      13.55    & 0.85  & 12.5  & 13.4  & 15.29 \\ 
    PM25abs (\si{\ugpcm}) &
      1.69   & 0.17    & 1.46  & 1.67  & 1.99  \\
    NOX (\si{\ugpcm}) &
      32.7   & 7.28    & 23.83 & 31.34 & 46.66 \\
    NO2 (\si{\ugpcm}) &
      18.77    & 3.83  & 13.76 & 18.28 & 25.62 \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document} 

结果

相关内容