我的文档中有大约 10 个彩色表格,但当我创建以下表格时出现错误(如图所示)。我应用了论坛上可用的解决方案,但没有用。请指导我如何修复此问题。
\documentclass[review]{elsarticle}
\usepackage{float}
\usepackage{flafter}
\usepackage{multirow}
\usepackage{amsthm}
\usepackage[section]{placeins}
\usepackage{graphicx}
\usepackage{changepage}
\usepackage{url}
\usepackage{amssymb}
\usepackage{ulem}
%\usepackage[table,xcdraw]{xcolor}
\usepackage{array}
\usepackage{booktabs}
\usepackage[table,x11names]{xcolor}
\usepackage{wasysym}
%\usepackage[nointegrals]{wasysym}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{adjustbox}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\usepackage[toc,page]{appendix}
\usepackage{textcomp}
\usepackage{epstopdf}
\usepackage{csquotes}
\usepackage[utf8]{inputenc}
\usepackage{dirtytalk}
\usepackage[document]{ragged2e}
\usepackage{parskip}
\usepackage{amssymb}
\usepackage[document]{ragged2e}
\usepackage[fleqn]{amsmath}
\usepackage{url}
\usepackage{pgfplots}
\usepackage[colorinlistoftodos,prependcaption,textsize=tiny]{todonotes}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{geometry}
\usepackage{pgf-pie}
\usepackage{tikz,lipsum,lmodern}
\usepackage[most]{tcolorbox}
\pgfplotsset{compat=1.9}
\geometry{a4paper, margin=1.3in}
\usepackage{pdflscape}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1.5mm}
\renewcommand{\baselinestretch}{1.0}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
Table Code is here
\begin{table}[]
\caption{Testing my Table}
\label{tab:my-table}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|c|c|c|c|c|}
\hline
\multicolumn{1}{|c|}{\textbf{ID}} &
\multicolumn{1}{c|}{\textbf{Pattern}} &
Very often &
Often &
Rarely &
Sometimes &
Never \\ \hline
1 &
\cellcolor[HTML]{FFF}A &
\cellcolor[HTML]{A9D08E}38.0 &
\cellcolor[HTML]{70AD47}55.0 &
\cellcolor[HTML]{E2EFDA}21.0 &
\cellcolor[HTML]{E2EFDA}22.0 &
\cellcolor[HTML]{E2EFDA}20.0 \\ \hline
2 &
\cellcolor[HTML]{FFF}B &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{70AD47}48.0 &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{E2EFDA}26.0 &
\cellcolor[HTML]{E2EFDA}24.0 \\ \hline
3 &
\cellcolor[HTML]{FFF}C &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{70AD47}47.0 &
\cellcolor[HTML]{E2EFDA}28.0 &
\cellcolor[HTML]{E2EFDA}27.0 &
\cellcolor[HTML]{E2EFDA}25.0 \\ \hline
4 &
\cellcolor[HTML]{FFF}D &
\cellcolor[HTML]{E2EFDA}27.0 &
\cellcolor[HTML]{70AD47}42.0 &
\cellcolor[HTML]{E2EFDA}26.0 &
\cellcolor[HTML]{E2EFDA}36.0 &
\cellcolor[HTML]{E2EFDA}25.0 \\ \hline
5 &
\cellcolor[HTML]{FFF}E &
\cellcolor[HTML]{E2EFDA}27.0 &
\cellcolor[HTML]{70AD47}41.0 &
\cellcolor[HTML]{E2EFDA}23.0 &
\cellcolor[HTML]{E2EFDA}35.0 &
\cellcolor[HTML]{E2EFDA}30.0 \\ \hline
6 &
\cellcolor[HTML]{FFF}F &
\cellcolor[HTML]{E2EFDA}25.0 &
\cellcolor[HTML]{70AD47}45.0 &
\cellcolor[HTML]{E2EFDA}21.0 &
\cellcolor[HTML]{E2EFDA}48.0 &
\cellcolor[HTML]{E2EFDA}17.0 \\ \hline
7 &
\cellcolor[HTML]{FFF}G &
\cellcolor[HTML]{E2EFDA}25.0 &
\cellcolor[HTML]{70AD47}44.0 &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{E2EFDA}36.0 &
\cellcolor[HTML]{E2EFDA}22.0 \\ \hline
8 &
\cellcolor[HTML]{FFF}H &
\cellcolor[HTML]{E2EFDA}24.0 &
\cellcolor[HTML]{70AD47}44.0 &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{E2EFDA}28.0 &
\cellcolor[HTML]{E2EFDA}31.0 \\ \hline
9 &
\cellcolor[HTML]{FFF}I &
\cellcolor[HTML]{E2EFDA}23.0 &
\cellcolor[HTML]{70AD47}49.0 &
\cellcolor[HTML]{A9D08E}29.0 &
\cellcolor[HTML]{A9D08E}33.0 &
\cellcolor[HTML]{E2EFDA}22.0 \\ \hline
10 &
\cellcolor[HTML]{FFF}J &
\cellcolor[HTML]{E2EFDA}22.0 &
\cellcolor[HTML]{70AD47}42.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{E2EFDA}31.0 \\ \hline
11 &
\cellcolor[HTML]{FFF}K &
\cellcolor[HTML]{E2EFDA}21.0 &
\cellcolor[HTML]{70AD47}47.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{E2EFDA}26.0 \\ \hline
12 &
\cellcolor[HTML]{FFF}L &
\cellcolor[HTML]{E2EFDA}21.0 &
\cellcolor[HTML]{70AD47}36.0 &
\cellcolor[HTML]{A9D08E}29.0 &
\cellcolor[HTML]{A9D08E}40.0 &
\cellcolor[HTML]{E2EFDA}30.0 \\ \hline
13 &
\cellcolor[HTML]{FFF}M &
\cellcolor[HTML]{E2EFDA}20.0 &
\cellcolor[HTML]{70AD47}37.0 &
\cellcolor[HTML]{A9D08E}29.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{E2EFDA}40.0 \\ \hline
14 &
\cellcolor[HTML]{FFF}N &
\cellcolor[HTML]{E2EFDA}19.0 &
\cellcolor[HTML]{70AD47}41.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{A9D08E}36.0 &
\cellcolor[HTML]{E2EFDA}30.0 \\ \hline
15 &
\cellcolor[HTML]{FFF}O &
\cellcolor[HTML]{E2EFDA}19.0 &
\cellcolor[HTML]{70AD47}37.0 &
\cellcolor[HTML]{A9D08E}32.0 &
\cellcolor[HTML]{A9D08E}34.0 &
\cellcolor[HTML]{E2EFDA}34.0 \\ \hline
16 &
\cellcolor[HTML]{FFF}P &
\cellcolor[HTML]{E2EFDA}19.0 &
\cellcolor[HTML]{70AD47}29.0 &
\cellcolor[HTML]{A9D08E}27.0 &
\cellcolor[HTML]{A9D08E}41.0 &
\cellcolor[HTML]{E2EFDA}40.0 \\ \hline
17 &
\cellcolor[HTML]{FFF}Q &
\cellcolor[HTML]{E2EFDA}18.0 &
\cellcolor[HTML]{70AD47}42.0 &
\cellcolor[HTML]{A9D08E}28.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{E2EFDA}38.0 \\ \hline
18 &
\cellcolor[HTML]{FFF}R &
\cellcolor[HTML]{E2EFDA}18.0 &
\cellcolor[HTML]{70AD47}36.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{A9D08E}45.0 &
\cellcolor[HTML]{E2EFDA}27.0 \\ \hline
19 &
\cellcolor[HTML]{FFF}S &
\cellcolor[HTML]{E2EFDA}18.0 &
\cellcolor[HTML]{70AD47}36.0 &
\cellcolor[HTML]{A9D08E}25.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{E2EFDA}46.0 \\ \hline
20 &
\cellcolor[HTML]{FFF}T &
\cellcolor[HTML]{E2EFDA}17.0 &
\cellcolor[HTML]{70AD47}44.0 &
\cellcolor[HTML]{A9D08E}28.0 &
\cellcolor[HTML]{A9D08E}35.0 &
\cellcolor[HTML]{E2EFDA}32.0 \\ \hline
21 &
\cellcolor[HTML]{FFF}U &
\cellcolor[HTML]{E2EFDA}17.0 &
\cellcolor[HTML]{70AD47}43.0 &
\cellcolor[HTML]{A9D08E}36.0 &
\cellcolor[HTML]{A9D08E}34.0 &
\cellcolor[HTML]{E2EFDA}26.0 \\ \hline
22 &
\cellcolor[HTML]{FFF}V &
\cellcolor[HTML]{E2EFDA}17.0 &
\cellcolor[HTML]{E2EFDA}43.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{A9D08E}39.0 &
\cellcolor[HTML]{E2EFDA}26.0 \\ \hline
23 &
\cellcolor[HTML]{FFF}W &
\cellcolor[HTML]{E2EFDA}16.0 &
\cellcolor[HTML]{E2EFDA}32.0 &
\cellcolor[HTML]{A9D08E}33.0 &
\cellcolor[HTML]{A9D08E}40.0 &
\cellcolor[HTML]{E2EFDA}35.0 \\ \hline
24 &
\cellcolor[HTML]{FFF}X &
\cellcolor[HTML]{E2EFDA}16.0 &
\cellcolor[HTML]{E2EFDA}28.0 &
\cellcolor[HTML]{E2EFDA}32.0 &
\cellcolor[HTML]{E2EFDA}44.0 &
\cellcolor[HTML]{E2EFDA}36.0 \\ \hline
25 &
\cellcolor[HTML]{FFF}Y &
\cellcolor[HTML]{E2EFDA}15.0 &
\cellcolor[HTML]{E2EFDA}42.0 &
\cellcolor[HTML]{E2EFDA}36.0 &
\cellcolor[HTML]{E2EFDA}31.0 &
\cellcolor[HTML]{E2EFDA}32.0 \\ \hline
26 &
\cellcolor[HTML]{FFF}Z &
\cellcolor[HTML]{E2EFDA}14.0 &
\cellcolor[HTML]{E2EFDA}45.0 &
\cellcolor[HTML]{E2EFDA}35.0 &
\cellcolor[HTML]{E2EFDA}30.0 &
\cellcolor[HTML]{E2EFDA}32.0 \\ \hline
\end{tabular}%
}
\end{table}
答案1
具体问题是您需要amsmath
在 之前加载amsthm
。如果您这样做,编译将会告诉您您遗漏了\begin{document}
和\end{document}
。然后它会给您一个非常令人困惑的错误,提示\@@scl
您未定义,结果会追溯到给出xcolor
无效的 HTML 颜色代码。
更大的问题是,你似乎在做很多初学者都会做的事情:从大量现有文档中复制和粘贴代码。不幸的是,你以一种没有意义的方式将它们的序言粘贴在一起。例如,你几乎肯定不需要lipsum
插入“Lorem ipsum”虚拟文本,或重新定义geometry
期刊文章的。你不再需要textcomp
或inputenc
,因为 LaTeX 内核现在默认加载它们。你加载的某些包是多余的、过时的或重复的。
我将清除包列表,然后逐个添加回您的文档实际需要的包。
编辑
如果我添加\begin{document}
和\end{document}
,然后替换无效的 HTML 颜色名称,则以下文档将在 TeX Live 2020 上编译:
\documentclass[review]{elsarticle}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[fleqn]{amsmath}
\usepackage{amsthm, amssymb}
\usepackage{wasysym}
\usepackage{longtable}
\usepackage[table, HTML]{xcolor}
\begin{document}
Table Code is here
\begin{table}[]
\caption{Testing my Table}
\label{tab:my-table}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|c|c|c|c|c|}
\hline
\multicolumn{1}{|c|}{\textbf{ID}} &
\multicolumn{1}{c|}{\textbf{Pattern}} &
Very often &
Often &
Rarely &
Sometimes &
Never \\ \hline
1 &
\cellcolor[HTML]{FFFFFF}A &
\cellcolor[HTML]{A9D08E}38.0 &
\cellcolor[HTML]{70AD47}55.0 &
\cellcolor[HTML]{E2EFDA}21.0 &
\cellcolor[HTML]{E2EFDA}22.0 &
\cellcolor[HTML]{E2EFDA}20.0 \\ \hline
2 &
\cellcolor[HTML]{FFFFFF}B &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{70AD47}48.0 &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{E2EFDA}26.0 &
\cellcolor[HTML]{E2EFDA}24.0 \\ \hline
3 &
\cellcolor[HTML]{FFFFFF}C &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{70AD47}47.0 &
\cellcolor[HTML]{E2EFDA}28.0 &
\cellcolor[HTML]{E2EFDA}27.0 &
\cellcolor[HTML]{E2EFDA}25.0 \\ \hline
4 &
\cellcolor[HTML]{FFFFFF}D &
\cellcolor[HTML]{E2EFDA}27.0 &
\cellcolor[HTML]{70AD47}42.0 &
\cellcolor[HTML]{E2EFDA}26.0 &
\cellcolor[HTML]{E2EFDA}36.0 &
\cellcolor[HTML]{E2EFDA}25.0 \\ \hline
5 &
\cellcolor[HTML]{FFFFFF}E &
\cellcolor[HTML]{E2EFDA}27.0 &
\cellcolor[HTML]{70AD47}41.0 &
\cellcolor[HTML]{E2EFDA}23.0 &
\cellcolor[HTML]{E2EFDA}35.0 &
\cellcolor[HTML]{E2EFDA}30.0 \\ \hline
6 &
\cellcolor[HTML]{FFFFFF}F &
\cellcolor[HTML]{E2EFDA}25.0 &
\cellcolor[HTML]{70AD47}45.0 &
\cellcolor[HTML]{E2EFDA}21.0 &
\cellcolor[HTML]{E2EFDA}48.0 &
\cellcolor[HTML]{E2EFDA}17.0 \\ \hline
7 &
\cellcolor[HTML]{FFFFFF}G &
\cellcolor[HTML]{E2EFDA}25.0 &
\cellcolor[HTML]{70AD47}44.0 &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{E2EFDA}36.0 &
\cellcolor[HTML]{E2EFDA}22.0 \\ \hline
8 &
\cellcolor[HTML]{FFFFFF}H &
\cellcolor[HTML]{E2EFDA}24.0 &
\cellcolor[HTML]{70AD47}44.0 &
\cellcolor[HTML]{E2EFDA}29.0 &
\cellcolor[HTML]{E2EFDA}28.0 &
\cellcolor[HTML]{E2EFDA}31.0 \\ \hline
9 &
\cellcolor[HTML]{FFFFFF}I &
\cellcolor[HTML]{E2EFDA}23.0 &
\cellcolor[HTML]{70AD47}49.0 &
\cellcolor[HTML]{A9D08E}29.0 &
\cellcolor[HTML]{A9D08E}33.0 &
\cellcolor[HTML]{E2EFDA}22.0 \\ \hline
10 &
\cellcolor[HTML]{FFFFFF}J &
\cellcolor[HTML]{E2EFDA}22.0 &
\cellcolor[HTML]{70AD47}42.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{E2EFDA}31.0 \\ \hline
11 &
\cellcolor[HTML]{FFFFFF}K &
\cellcolor[HTML]{E2EFDA}21.0 &
\cellcolor[HTML]{70AD47}47.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{E2EFDA}26.0 \\ \hline
12 &
\cellcolor[HTML]{FFFFFF}L &
\cellcolor[HTML]{E2EFDA}21.0 &
\cellcolor[HTML]{70AD47}36.0 &
\cellcolor[HTML]{A9D08E}29.0 &
\cellcolor[HTML]{A9D08E}40.0 &
\cellcolor[HTML]{E2EFDA}30.0 \\ \hline
13 &
\cellcolor[HTML]{FFFFFF}M &
\cellcolor[HTML]{E2EFDA}20.0 &
\cellcolor[HTML]{70AD47}37.0 &
\cellcolor[HTML]{A9D08E}29.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{E2EFDA}40.0 \\ \hline
14 &
\cellcolor[HTML]{FFFFFF}N &
\cellcolor[HTML]{E2EFDA}19.0 &
\cellcolor[HTML]{70AD47}41.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{A9D08E}36.0 &
\cellcolor[HTML]{E2EFDA}30.0 \\ \hline
15 &
\cellcolor[HTML]{FFFFFF}O &
\cellcolor[HTML]{E2EFDA}19.0 &
\cellcolor[HTML]{70AD47}37.0 &
\cellcolor[HTML]{A9D08E}32.0 &
\cellcolor[HTML]{A9D08E}34.0 &
\cellcolor[HTML]{E2EFDA}34.0 \\ \hline
16 &
\cellcolor[HTML]{FFFFFF}P &
\cellcolor[HTML]{E2EFDA}19.0 &
\cellcolor[HTML]{70AD47}29.0 &
\cellcolor[HTML]{A9D08E}27.0 &
\cellcolor[HTML]{A9D08E}41.0 &
\cellcolor[HTML]{E2EFDA}40.0 \\ \hline
17 &
\cellcolor[HTML]{FFFFFF}Q &
\cellcolor[HTML]{E2EFDA}18.0 &
\cellcolor[HTML]{70AD47}42.0 &
\cellcolor[HTML]{A9D08E}28.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{E2EFDA}38.0 \\ \hline
18 &
\cellcolor[HTML]{FFFFFF}R &
\cellcolor[HTML]{E2EFDA}18.0 &
\cellcolor[HTML]{70AD47}36.0 &
\cellcolor[HTML]{A9D08E}30.0 &
\cellcolor[HTML]{A9D08E}45.0 &
\cellcolor[HTML]{E2EFDA}27.0 \\ \hline
19 &
\cellcolor[HTML]{FFFFFF}S &
\cellcolor[HTML]{E2EFDA}18.0 &
\cellcolor[HTML]{70AD47}36.0 &
\cellcolor[HTML]{A9D08E}25.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{E2EFDA}46.0 \\ \hline
20 &
\cellcolor[HTML]{FFFFFF}T &
\cellcolor[HTML]{E2EFDA}17.0 &
\cellcolor[HTML]{70AD47}44.0 &
\cellcolor[HTML]{A9D08E}28.0 &
\cellcolor[HTML]{A9D08E}35.0 &
\cellcolor[HTML]{E2EFDA}32.0 \\ \hline
21 &
\cellcolor[HTML]{FFFFFF}U &
\cellcolor[HTML]{E2EFDA}17.0 &
\cellcolor[HTML]{70AD47}43.0 &
\cellcolor[HTML]{A9D08E}36.0 &
\cellcolor[HTML]{A9D08E}34.0 &
\cellcolor[HTML]{E2EFDA}26.0 \\ \hline
22 &
\cellcolor[HTML]{FFFFFF}V &
\cellcolor[HTML]{E2EFDA}17.0 &
\cellcolor[HTML]{E2EFDA}43.0 &
\cellcolor[HTML]{A9D08E}31.0 &
\cellcolor[HTML]{A9D08E}39.0 &
\cellcolor[HTML]{E2EFDA}26.0 \\ \hline
23 &
\cellcolor[HTML]{FFFFFF}W &
\cellcolor[HTML]{E2EFDA}16.0 &
\cellcolor[HTML]{E2EFDA}32.0 &
\cellcolor[HTML]{A9D08E}33.0 &
\cellcolor[HTML]{A9D08E}40.0 &
\cellcolor[HTML]{E2EFDA}35.0 \\ \hline
24 &
\cellcolor[HTML]{FFFFFF}X &
\cellcolor[HTML]{E2EFDA}16.0 &
\cellcolor[HTML]{E2EFDA}28.0 &
\cellcolor[HTML]{E2EFDA}32.0 &
\cellcolor[HTML]{E2EFDA}44.0 &
\cellcolor[HTML]{E2EFDA}36.0 \\ \hline
25 &
\cellcolor[HTML]{FFFFFF}Y &
\cellcolor[HTML]{E2EFDA}15.0 &
\cellcolor[HTML]{E2EFDA}42.0 &
\cellcolor[HTML]{E2EFDA}36.0 &
\cellcolor[HTML]{E2EFDA}31.0 &
\cellcolor[HTML]{E2EFDA}32.0 \\ \hline
26 &
\cellcolor[HTML]{FFFFFF}Z &
\cellcolor[HTML]{E2EFDA}14.0 &
\cellcolor[HTML]{E2EFDA}45.0 &
\cellcolor[HTML]{E2EFDA}35.0 &
\cellcolor[HTML]{E2EFDA}30.0 &
\cellcolor[HTML]{E2EFDA}32.0 \\ \hline
\end{tabular}%
}
\end{table}
\end{document}
该问题与 无关wasysym
。
当您写了一些无效的 HTML 颜色值时,我尽力猜测您真正想要的颜色,但请考虑使用svgnames
W3C 的标准。