奇怪的“放错 \noalign \end{tabu}}”错误

奇怪的“放错 \noalign \end{tabu}}”错误

我遇到了这个奇怪的错误,我不知道该如何修复它。我使用以下代码:

\documentclass[a4paper, 11pt]{report}
\usepackage{tabu}
\usepackage[version=3]{mhchem}
\usepackage{xcolor,colortbl}
\definecolor{dtured}{RGB}{153,0,0}
\definecolor{dtugray}{RGB}{153,153,153}
\begin{document}
    \begin{table}[h*]
    \resizebox{\textwidth}{!}{\begin{tabu}{cccccccccc}
            \rowcolor{dtured}\rowfont{\color{white}}
        \textbf{m i ton} & $\mathbf{m_{totalt}}$ & \textbf{\ce{SiO2}} & \textbf{\ce{Al2O3}} & \textbf{\ce{Fe2O3}} & \textbf{\ce{MgO}} & \textbf{\ce{CaO}} &\textbf{ \ce{Na2O}} & \textbf{\ce{K2O} }& \textbf{\ce{SO3}} \\
        \textbf{98 menger} & $306.20$ & $202.42$ & $4.69$ & $0.19$ & $5.04$ & $27.54$ & $35.74$ & $0.91$ & $0.83$
    \end{tabu}}
    \captionof{table}{Oxid-indhold i ton af det daglige råvareforbrug bestående af 98 menger.}
\end{table}
\end{document}

答案1

显然,\rowfont必须在之前使用\rowcolor

\documentclass[a4paper, 11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{tabu}
\usepackage[version=3]{mhchem}
\usepackage{xcolor,colortbl}
\definecolor{dtured}{RGB}{153,0,0}
\definecolor{dtugray}{RGB}{153,153,153}

\begin{document}

\begin{table}
\centering

\resizebox{\textwidth}{!}{% <------
  \begin{tabu}{@{}*{10}{c}@{}}
  \rowfont{\color{white}}\rowcolor{dtured}
  \textbf{m i ton} & $\mathbf{m_{totalt}}$ & \textbf{\ce{SiO2}} &
    \textbf{\ce{Al2O3}} & \textbf{\ce{Fe2O3}} & \textbf{\ce{MgO}} &
    \textbf{\ce{CaO}} &\textbf{ \ce{Na2O}} & \textbf{\ce{K2O} }& \textbf{\ce{SO3}} \\
  \textbf{98 menger} & $306.20$ & $202.42$ & $4.69$ & $0.19$ & $5.04$ & $27.54$ & $35.74$ & $0.91$ & $0.83$ \\
  \end{tabu}% <------
}

\caption{Oxid-indhold i ton af det daglige råvareforbrug bestående af 98 menger.}

\end{table}

\end{document}

在此处输入图片描述

\captionof如果您在 内,则无需table。请注意标记的%字符,以避免出现不需要的空格。

相关内容