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}
  • 1
    I see nothing wrong and I can run that code without problems. – egreg Apr 17 '18 at 14:28
  • 1
    I don't see any problems – percusse Apr 17 '18 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 Apr 17 '18 at 14:40
  • 1
    Indeed XeLaTeX is broken – percusse Apr 17 '18 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 Apr 17 '18 at 15:02
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/lmroman10-regular.otf@9.96pt<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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.