当使用大量 \color{} 命令时,无法改变颜色

当使用大量 \color{} 命令时,无法改变颜色

在此处输入图片描述

\documentclass{article}

\usepackage{xcolor}

\begin{document}

\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue

from here, something is wrong?

\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue
\color{red}red  \color{green}green  \color{blue}blue

\end{document}

答案1

如果我使用以下代码运行

xelatex -output-driver="xdvipdfmx -vv" zeno

我进入控制台

<FONTMAP:/usr/local/texlive/2017/texmf-var/fonts/map/pdftex/updmap/pdftex.map><FONTMAP:/usr/local/texlive/2017/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map><FONTMAP:/usr/local/texlive/2017/texmf-dist/fonts/map/dvipdfmx/ckx.map>No dvi filename specified, reading standard input.
stdin -> zenorig.pdf
DVI Comment:  XeTeX output 2018.04.17:1712
<AGL:texglyphlist.txt><AGL:pdfglyphlist.txt><AGL:glyphlist.txt>[1</usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/[email protected]<NATIVE-FONTMAP:/usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0>
fontmap: /usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0 -> /usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf(Identity-H)

pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "/usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf".
(CID:LMRoman10-Regular)
pdf_font>> Type0 font "/usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf" cmap_id=<Identity-H,0> opened at font_id=</usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0,0>.
>
xdvipdfmx:warning: Color stack overflow. Just ignore.
xdvipdfmx:warning: Color stack overflow. Just ignore.
xdvipdfmx:warning: Color stack overflow. Just ignore.
[...several other similar lines...]
xdvipdfmx:warning: Color stack overflow. Just ignore.
xdvipdfmx:warning: Color stack overflow. Just ignore.
]
otf_cmap>> Creating ToUnicode CMap for "/usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf"...
(CID:/usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf[IXRNFR+LMRoman10-Regular][CIDFontType0][20 glyphs][2804 bytes])
Compression saved 14964 bytes
5364 bytes written

每个\color命令执行

\special {color push \current@color }\aftergroup \reset@color

但是 the 后面push从来不会跟着 a pop(除了在作业结束时)。

颜色堆栈显然有 127 或 128 个位置的限制(您得到红色,我得到蓝色,因此根据软件版本的不同,它可能会偏离一个)。

使用{\color{<color>}text},或者更好,

\textcolor{<color>}{text}

改变颜色。

答案2

我在使用一台有 >32 个参考文献的投影机时遇到了这个问题。

由于每个命令\bibitem都会发射 4 个颜色的命令,因此第 31 个命令会中断。

为了解决这个问题,我添加了额外的分组

\setbeamertemplate{bibliography entry author}{\bgroup}
\setbeamertemplate{bibliography entry note}{\egroup}

如果出现missing } before \end{bibliography}错误,请尝试

\setbeamertemplate{bibliography entry author}{\bgroup}
\setbeamertemplate{bibliography entry location}{\egroup}

反而。

相关内容