Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In a previous question ( How do I globally set the text color in XeLaTeX ), I've asked how to globally set a text colour in XeLaTeX and got some excellent answers.

However, while the proposed mechanisms seem to work in most cases, they also seem to fail consistently for the colour white. I'm not sure if this is a bug or if I'm doing something wrong here, but please consider the following example:

\documentclass{report}
\usepackage{xcolor}
\usepackage{fontspec}
\setmainfont[Color=white]{Linux Libertine O}
\setsansfont[Color=white]{Linux Biolinum O}
\setmonofont[Color=white]{Inconsolata}

\pagecolor{darkgray}

\begin{document}
\chapter{A chapter}
\section{A section}
\texttt{Some mono text}
The text above is invisible as it is all black and not white.

{\addfontfeature{Color=yellow} Some yellow text showing up on the dark page.}
{\addfontfeature{Color=white} Some white text invisible on the dark page.}

\end{document}

The example follows @AlanMunn s suggestion on the other question. The result is:

White text is black

The white text is printed in black. Other colours (like yellow in the example) work well.

If I use @Herbert s suggestion of adding

\AtBeginDocument{\color{white}}

\addtokomafont{sectioning}{\color{white}}


to the document, I keep stumbling over environments that are still black, like the captions of figures for example. In any case, the \color command seems to be stronger than the fontspec setting.

Any thoughts or solutions to this?

share|improve this question
2  
This looks like a bug (maybe in the driver?) It works with LuaLaTeX, so if that's an option for you, you could try that. Alternatively, loading xcolor with the [svgnames] option and using Snow instead of white gives you a very close approximation. –  Alan Munn Sep 13 '11 at 12:25
1  
Another alternative is to use the technique that Philippe Goutet in your previous question. tex.stackexchange.com/questions/26549/… –  Alan Munn Sep 13 '11 at 13:06
    
@AlanMunn Thanks for pointing back to Philippe's answer. Indeed, that's the one that should get the credit here. –  kongo09 Sep 13 '11 at 21:24
add comment

2 Answers

It seems to be a bug in XeTeX, as

\font\x="Linux Libertine O:color=FFFFFF"
\x ABC\bye

prints ABC in black, while

\font\x="Linux Libertine O:color=FFFFFE"
\x ABC\bye

prints ABC in "almost white".

So the answer might be

\setmainfont[Color=FFFFFE]{Linux Libertine O}

This "explains" Alan's suggestion.

share|improve this answer
1  
You could make it FEFEFE for even color distribution. –  Andrey Vihrov Sep 13 '11 at 15:28
    
Thanks, that's a good workaround, but not really white. –  kongo09 Sep 13 '11 at 21:24
    
@kongo09: sorry, but it seems that really white is not accepted by XeTeX. –  egreg Sep 13 '11 at 21:27
add comment
up vote 1 down vote accepted

Full credit goes to Philippe Goutet who wrote the follwing answer here: How do I globally set the text color in XeLaTeX

Thanks to Alan Munn for pointing this out.


Here's a way to do it which will work whether you use XeLaTeX or not, and whether you use Komascript or not. It works by redefining the default color used by LaTeX.

\documentclass{report}
%\documentclass{scrreprt}

\usepackage{xcolor}

\makeatletter
\newcommand{\globalcolor}[1]{%
  \color{#1}\global\let\default@color\current@color
}
\makeatother

\AtBeginDocument{\globalcolor{red}}

\begin{document}

\section{A section heading}

some test text

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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