表格中的彩色单元格不起作用

表格中的彩色单元格不起作用

我正在使用以下documentclass内容preamble

\documentclass[runningheads]{llncs}
%
\usepackage[table,xcdraw]{xcolor}
\usepackage{graphicx}
\usepackage{svg}
\usepackage{subfig}

我正在用这个网站在乳胶中生成如下表:

在此处输入图片描述

我得到以下转换:

% Please add the following required packages to your document preamble:
% \usepackage[table,xcdraw]{xcolor}
% If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer}
\begin{table}[]
\begin{tabular}{
>{\columncolor[HTML]{FFF}}r 
>{\columncolor[HTML]{FFF7F3}}r rr
>{\columncolor[HTML]{FFF7F3}}r 
>{\columncolor[HTML]{FFF7F3}}r rrr}
\textbf{}   & \cellcolor[HTML]{FFF}\textbf{LT}                    & \cellcolor[HTML]{FFF}\textbf{LD}                    & \cellcolor[HTML]{FFF}\textbf{FK}                    & \cellcolor[HTML]{FFF}\textbf{BD}                    & \cellcolor[HTML]{FFF}\textbf{AZ}                    & \cellcolor[HTML]{FFF}\textbf{BF}                    & \cellcolor[HTML]{FFF}\textbf{BK}                    & \cellcolor[HTML]{FFF}\textbf{OB}                    \\
\textbf{AG} & 0.01                                                & \cellcolor[HTML]{FCC8C3}0.2                         & \cellcolor[HTML]{E23E99}{\color[HTML]{F1F1F1} 0.05} & 0.02                                                & nan                                                 & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.04} & \cellcolor[HTML]{F994B1}0.04                        & \cellcolor[HTML]{F767A1}0.05                        \\
\textbf{KZ} & 0.01                                                & \cellcolor[HTML]{F873A5}0.25                        & \cellcolor[HTML]{99017B}{\color[HTML]{F1F1F1} 0.06} & \cellcolor[HTML]{FCC5C0}0.03                        & 0.01                                                & \cellcolor[HTML]{F769A1}0.03                        & \cellcolor[HTML]{99017B}{\color[HTML]{F1F1F1} 0.06} & \cellcolor[HTML]{FFF7F3}0.04                        \\
\textbf{AZ} & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.02} & \cellcolor[HTML]{F25D9F}0.26                        & \cellcolor[HTML]{99017B}{\color[HTML]{F1F1F1} 0.06} & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.06} & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.07} & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.04} & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.07} & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.06} \\
\textbf{FT} & 0.01                                                & \cellcolor[HTML]{FBBABD}0.21                        & \cellcolor[HTML]{E23E99}{\color[HTML]{F1F1F1} 0.05} & 0.02                                                & nan                                                 & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.04} & \cellcolor[HTML]{F994B1}0.04                        & \cellcolor[HTML]{F767A1}0.05                        \\
\textbf{BK} & 0.01                                                & \cellcolor[HTML]{FCC8C3}0.2                         & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.07} & \cellcolor[HTML]{F767A1}0.04                        & nan                                                 & \cellcolor[HTML]{F769A1}0.03                        & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.07} & \cellcolor[HTML]{FFF7F3}0.04                        \\
\textbf{OB} & 0.01                                                & \cellcolor[HTML]{FFF7F3}0.15                        & \cellcolor[HTML]{E23E99}{\color[HTML]{F1F1F1} 0.05} & 0.02                                                & nan                                                 & \cellcolor[HTML]{FFF7F3}0.02                        & \cellcolor[HTML]{E23E99}{\color[HTML]{F1F1F1} 0.05} & \cellcolor[HTML]{F767A1}0.05                        \\
\textbf{HL} & 0.01                                                & \cellcolor[HTML]{E84A9B}0.27                        & \cellcolor[HTML]{FFF7F3}0.02                        & 0.02                                                & nan                                                 & \cellcolor[HTML]{F769A1}0.03                        & \cellcolor[HTML]{FFF7F3}0.02                        & \cellcolor[HTML]{FFF7F3}0.04                        \\
\textbf{SD} & 0.01                                                & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.36} & \cellcolor[HTML]{99017B}{\color[HTML]{F1F1F1} 0.06} & 0.02                                                & nan                                                 & \cellcolor[HTML]{49006A}{\color[HTML]{F1F1F1} 0.04} & \cellcolor[HTML]{99017B}{\color[HTML]{F1F1F1} 0.06} & \cellcolor[HTML]{F767A1}0.05                       
\end{tabular}
\end{table}

我收到类似以下的错误:

<argument> \@@scl 
                  
l.144 \textbf{}   &
                    \cellcolor[HTML]{FFF}\textbf{LT}                    & \c...
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Missing number, treated as zero.
<to be read again> 
                   \@cclv 
l.144 \textbf{}   &
                    \cellcolor[HTML]{FFF}\textbf{LT}                    & \c...
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

答案1

FFF在颜色模型中不是有效颜色HTML。要获得白色单元格,请使用FFFFFF。为了提高代码的可读性,也为了使颜色更改更加容易,我在前言中定义了一组使用的颜色,并通过它们的名称在表中访问它们。如果您以后想要更改颜色,所有共享相同颜色的单元格将自动适应,而无需更改每个\cellcolor命令。

附注:有些颜色非常相似,很难区分。这是故意的吗?

在此处输入图片描述

\documentclass[runningheads]{llncs}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{svg}
\usepackage{subfig}
\usepackage{array}

\definecolor{mybeige}{HTML}{FFF7F3}
\definecolor{myoffwhite}{HTML}{F1F1F1}
\definecolor{mydarkpurple}{HTML}{49006A}
\definecolor{mypurple}{HTML}{99017B}
\definecolor{mydarkpink}{HTML}{E23E99}
\definecolor{mypink}{HTML}{F767A1}
\definecolor{mypink2}{HTML}{F769A1}
\definecolor{mylightpink}{HTML}{F994B1}
\definecolor{mysalmon}{HTML}{FCC8C3}
\definecolor{mylightsalmon}{HTML}{FBBABD}

\begin{document}
\begin{table}[]
\begin{tabular}{
>{\columncolor{white}}r 
>{\columncolor{mybeige}}r rr
>{\columncolor{mybeige}}r 
>{\columncolor{mybeige}}r rrr}
\textbf{}   & \cellcolor{white}\textbf{LT}                        & \cellcolor{white}\textbf{LD}                      & \cellcolor{white}\textbf{FK}                      & \cellcolor{white}\textbf{BD}                      & \cellcolor{white}\textbf{AZ}                      & \cellcolor{white}\textbf{BF}                      & \cellcolor{white}\textbf{BK}                      & \cellcolor{white}\textbf{OB}                      \\
\textbf{AG} & 0.01                                                & \cellcolor{mysalmon}0.2                           & \cellcolor{mydarkpink}{\color{myoffwhite} 0.05}   & 0.02                                              & nan                                               & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.04} & \cellcolor{mylightpink}0.04                       & \cellcolor{mypink}0.05                            \\
\textbf{KZ} & 0.01                                                & \cellcolor[HTML]{F873A5}0.25                      & \cellcolor{mypurple}{\color{myoffwhite} 0.06}     & \cellcolor[HTML]{FCC5C0}0.03                      & 0.01                                              & \cellcolor{mypink2}0.03                           & \cellcolor{mypurple}{\color{myoffwhite} 0.06}     & \cellcolor{mybeige}0.04                           \\
\textbf{AZ} & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.02}   & \cellcolor[HTML]{F25D9F}0.26                      & \cellcolor{mypurple}{\color{myoffwhite} 0.06}     & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.06} & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.07} & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.04} & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.07} & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.06} \\
\textbf{FT} & 0.01                                                & \cellcolor{mylightsalmon}0.21                     & \cellcolor{mydarkpink}{\color{myoffwhite} 0.05}   & 0.02                                              & nan                                               & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.04} & \cellcolor{mylightpink}0.04                       & \cellcolor{mypink}0.05                            \\
\textbf{BK} & 0.01                                                & \cellcolor{mysalmon}0.2                           & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.07} & \cellcolor{mypink}0.04                            & nan                                               & \cellcolor{mypink2}0.03                           & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.07} & \cellcolor{mybeige}0.04                           \\
\textbf{OB} & 0.01                                                & \cellcolor{mybeige}0.15                           & \cellcolor{mydarkpink}{\color{myoffwhite} 0.05}   & 0.02                                              & nan                                               & \cellcolor{mybeige}0.02                           & \cellcolor{mydarkpink}{\color{myoffwhite} 0.05}   & \cellcolor{mypink}0.05                            \\
\textbf{HL} & 0.01                                                & \cellcolor[HTML]{E84A9B}0.27                      & \cellcolor{mybeige}0.02                           & 0.02                                              & nan                                               & \cellcolor{mypink2}0.03                           & \cellcolor{mybeige}0.02                           & \cellcolor{mybeige}0.04                           \\
\textbf{SD} & 0.01                                                & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.36} & \cellcolor{mypurple}{\color{myoffwhite} 0.06}     & 0.02                                              & nan                                               & \cellcolor{mydarkpurple}{\color{myoffwhite} 0.04} & \cellcolor{mypurple}{\color{myoffwhite} 0.06}     & \cellcolor{mypink}0.05                       
\end{tabular}
\end{table}
\end{document}

相关内容