4

enter image description here

\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}
11
  • 1
    I see nothing wrong and I can run that code without problems.
    – egreg
    Commented Apr 17, 2018 at 14:28
  • 1
    I don't see any problems
    – percusse
    Commented Apr 17, 2018 at 14:29
  • 1
    My counting may be off, but is that happening after 128 color changes? That close to 2^7 seems suspicious. What OS do you have? What version of xcolor?
    – Teepeemm
    Commented Apr 17, 2018 at 14:40
  • 1
    Indeed XeLaTeX is broken
    – percusse
    Commented Apr 17, 2018 at 14:45
  • 1
    I guess this is a limitation of the xdvipdfmx driver that cannot handle more than 128 groups. Each \color command does a color push.
    – egreg
    Commented Apr 17, 2018 at 15:02

2 Answers 2

5

If I run this code with

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

I get on the console

<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

Each \color command executes

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

but the push is never followed by a pop (except at the end of the job).

The color stack apparently has a limitation of 127 or 128 positions (you get red, I get blue, so it can be off by one depending on the version of the software).

Use {\color{<color>}text} or, better,

\textcolor{<color>}{text}

for color changes.

2
  • Just to provide some relevant info: noted dvipdfm-x's source file pdfcolor.c@r55807 has #define DEV_COLOR_STACK_MAX 128 and if (color_stack.current >= DEV_COLOR_STACK_MAX-1) { WARN("Color stack overflow. Just ignore."); } else { ... }. Commented Oct 4, 2020 at 8:52
  • @muzimuzhiZ Maybe there is more in this than just the definition of a variable.
    – egreg
    Commented Oct 4, 2020 at 8:56
0

I encounter this with a beamer with >32 references.

Since each \bibitem will fire 4 color commands, the 31th breaks.

To fix this, I added additional grouping by

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

If that gives you a missing } before \end{bibliography} error, try

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

instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .