当我在序言中放入颜色定义时,出现错误,例如
\documentclass[12pt]{article}
\usepackage{xcolor}
\definecolor{es-bg}{HTML}{e7edf4ff}% (cornflower light blue background at the top)
\definecolor{es-aqua}{HTML}{00ffffff}% (bright aquaish, matches)
\definecolor{es-lb}{HTML}{0090d4ff}% (lighter blue, matches)
\definecolor{es-db}{HTML}{003b74ff}% (darker blue, matches)
\begin{document}
\colorbox{es-aqua}{This should be a color.}
\end{document}
给出错误“缺少 \begin{document}”。
如果我将定义放在 \begin{document} 之后,它会编译,但文档中会有一行额外的“FFFFFFFF”,例如
\documentclass[12pt]{article}
\usepackage{xcolor}
\begin{document}
\definecolor{es-bg}{HTML}{e7edf4ff}% (cornflower light blue background at the top)
\definecolor{es-aqua}{HTML}{00ffffff}% (bright aquaish, matches)
\definecolor{es-lb}{HTML}{0090d4ff}% (lighter blue, matches)
\definecolor{es-db}{HTML}{003b74ff}% (darker blue, matches)
\colorbox{es-aqua}{This should be a color.}
\end{document}
答案1
在序言中定义颜色完全没问题。但 HTML 格式要求 6 个数字/字母,而不是 8 个:
\documentclass[]{article}
\usepackage{xcolor}
\definecolor{es-bg}{HTML}{0df400}
\begin{document}
\textcolor{es-bg}{Hello}
\end{document}
答案2
xcolor HTML 颜色模型采用 6 位大写十六进制数字,因此
\documentclass[12pt]{article}
\usepackage{xcolor}
\definecolor{es-bg}{HTML}{E7EDF4}% (cornflower light blue background at the top)
\definecolor{es-aqua}{HTML}{00FFFF}% (bright aquaish, matches)
\definecolor{es-lb}{HTML}{0090D4}% (lighter blue, matches)
\definecolor{es-db}{HTML}{003B74}% (darker blue, matches)
\begin{document}
\colorbox{es-aqua}{This should be a color.}
\end{document}