[XeTeX] Problems with xcolor and fontspec

Herbert Schulz herbs at wideopenwest.com
Mon Oct 3 16:29:04 CEST 2011


On Oct 3, 2011, at 8:57 AM, Stephen Moye wrote:

> The following minimum example shows the problem: I would like to generate some text in random colors and specify the opacity. In the example file below, either I get black text with opacity of 50%, or random colors at 100% opacity, or one random color for all the text at 50% opacity. Can I have my cake and eat it too? That is, can I have random colors *and* control over the opacity?
> 
> I'm using MacTeX 2011.
> 
> Thanks for any insights.
> 
> Stephen Moye
> 
> %%=====8><-----%%
> 
> % !TEX TS-program = XeLaTeX-xdv2pdf
> 
> \documentclass{article}
> 
> \input random
> \usepackage{xcolor}
> \usepackage{fontspec}
> 
> \setmainfont{Helvetica}
> 
> \newlength{\huedim}
> 
> \newcommand{\randcolor}{%
> 	\setrandim\huedim{0.0pt}{1.0pt}%
> 	\definecolor{mycolor}{hsb}{\pointless\huedim,1.0,1.0}%
> 	\color{mycolor}
> }
> 
> \newcommand{\testit}[3]{%
> 	%%% Uncomment *one* of the following \put commands to see the difference:
> 	%
> 	%%% This returns only gray:
> 	%\put(#1,#2){\randcolor\addfontfeature{Opacity=0.5}\color{mycolor}#3}
> 	%
> 	%%% This returns only the color first defined:
> 	%\put(#1,#2){\randcolor\addfontfeature{Color=mycolor,Opacity=0.5}\color{mycolor}#3}
> 	%
> 	%%% This works as it should, but the opacity is 100%
> 	%\put(#1,#2){\randcolor\color{mycolor}#3}
> }
> 
> \begin{document}
> 
> \begin{picture}(100,100)
> \testit{20}{100}{X}
> \testit{30}{90}{y}
> \testit{40}{80}{z}
> \end{picture}
> 
> \end{document}


Howdy,

Don't know if this will help but try using the xecolor package. Note that it's commands have a different name than the xcolor package though.

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)






More information about the XeTeX mailing list