![持续错误“未定义控制序列。\cellcolor”与“colortbl”LaTeX 包](https://linux22.com/image/425684/%E6%8C%81%E7%BB%AD%E9%94%99%E8%AF%AF%E2%80%9C%E6%9C%AA%E5%AE%9A%E4%B9%89%E6%8E%A7%E5%88%B6%E5%BA%8F%E5%88%97%E3%80%82%5Ccellcolor%E2%80%9D%E4%B8%8E%E2%80%9Ccolortbl%E2%80%9DLaTeX%20%E5%8C%85.png)
我遇到了一个持续性错误,该错误出现在以下 MWE 中(使用 TablesGenerator.com 生成并使用 Texpad 测试)。错误“未定义控制序列。\cellcolor”不是似乎是由于 TablesGenerator.com,但使用“彩色表格' LaTeX 包。StackExchange 等网站上的几篇帖子指出,使用过时的版本的'彩色表格' 包。我有三重检查我正在使用最新版本的“colortbl”包[2020/01/04 v1.0e 颜色表列(DPC)]大卫·卡莱尔。然而,错误‘未定义控制序列。\cellcolor’仍然存在。如能帮助辨别导致错误的原因,我们将不胜感激。
\documentclass{memoir}
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{longtable}
\usepackage{booktabs}
\begin{document}
\begin{longtable}[c]{
>{\columncolor[HTML]{FDD}}l
>{\columncolor[HTML]{FDD}}l
>{\columncolor[HTML]{C5C5C5}}l ll}
\hline
\cellcolor[HTML]{FDD} & \multicolumn{2}{l}{\cellcolor[HTML]{FDD}\textbf{Amount (Gt carbon; 1 Gt = 1015 g)}} & & \\ \cline{2-5}
\multirow{-2}{*}{\cellcolor[HTML]{FDD}\textbf{Region}} & \textbf{Before anthropogenic change} & \textbf{After anthropogenic change} & & \\ \cline{1-1}
\endfirsthead
%
\multicolumn{5}{c}%
{{\bfseries Table \thetable\ continued from previous page}} \\
\hline
\cellcolor[HTML]{FDD} & \multicolumn{2}{l}{\cellcolor[HTML]{FDD}\textbf{Amount (Gt carbon; 1 Gt = 1015 g)}} & & \\ \cline{2-5}
\multirow{-2}{*}{\cellcolor[HTML]{FDD}\textbf{Region}} & \textbf{Before anthropogenic change} & \textbf{After anthropogenic change} & & \\ \cline{1-1}
\endhead
%
\hline
\endfoot
%
\endlastfoot
%
land plants & 610 & 550 & & \\
soil and humus & 1,500 & \cellcolor[HTML]{FDD}no change & & \\
atmosphere & 600 & 750 (+3.4 per annum) & & \\
upper ocean & 1,000 & 1,020 (+0.4 per annum) & & \\
marine life & 3 & \cellcolor[HTML]{FDD}no change & & \\
dissolved organic carbon & 700 & \cellcolor[HTML]{FDD}no change & & \\
mid-depth and deep ocean & 38,000 & 38,100 (+1.6 per annum) & & \\ \hline
\caption{The separation between the fast-carbon and slow-carbon timescales has been significantly disturbed through the burning of fossil fuel. The following tables give some current estimates for the carbon budget and the carbon flux budget.}
\label{tab:The-carbon-budget-table}\\
\end{longtable}
\end{document}
答案1
错误不是未定义\cellcolor
,而是\@@scl
! Undefined control sequence.
<argument> \@@scl
\XC@cnv@HTML ...TML@ \@@tmp \edef \@@scl {\@cclv }
来自 xcolor 的 HTML 颜色模型转换
一个更简单的例子(优点是不使用我的任何包)
\documentclass{article}
\usepackage{xcolor}
\definecolor{zzz}{HTML}{FDD}
\begin{document}
\end{document}
生产
! Undefined control sequence.
<argument> \@@scl
l.4 \definecolor{zzz}{HTML}{FDD}
?
xcolor 手册说
HTML 接受字符 0–9、A–F、a–f 的任意组合,只要字符串长度正好为 6 个字符。
即不支持 3 位数字形式,FFDDDD
则不会出现错误。