Tell me more ×
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.

Bit of a niche question. There is a beautiful set of TrueType fonts called Chartwell designed for producing graphs from text. I am trying to get these to work in Latex. I have switched to Xe(La)tex, and can now get the fonts to appear. However I would like to change text colour without sequence of numbers being split into two. Best explained with some code and a picture.

\documentclass[13pt]{article}
\usepackage{fontspec}
\usepackage{xcolor}

% Now define your quick commands for switching fonts
\setmainfont{ChartwellRose}
\newfontfamily\cwrose[Ligatures=Rare, Color=blue]{ChartwellRose}

\begin{document}
\raggedright

Here is the text without ligatures

\fontsize{48}{60}
\selectfont
40+20+50
\rmfamily
\normalsize


Here is the text with ligatures

\cwrose
\fontsize{48}{60}
\selectfont
40+70
\rmfamily
\normalsize

Here is the text with a colour change inserted

\cwrose
\fontsize{48}{60}
\selectfont
40+\addfontfeature{Color=red}+70
\rmfamily
\normalsize

And as you can see the colour change has broken the effect of enabling the ligatures and the 'rose' is now presented as two separate objects (rather than a single object with 2 different colours.

\end{document}

Is it possible therefore to change the colour of a part of the text without the ligature formation being broken?

Here is a screenshot of the compiled example and here is a screenshot of unbroken form of the last example

share|improve this question
Not in XeTeX, color will always break text flow and hence the ligatures, and \addfontfeature just defines a new font from the current one plus the requested features. Possible with LuaTeX though, if you are interested in LuaTeX solutions. – Khaled Hosny Feb 18 at 22:21
Thanks for the advice. At least I know to stop looking. I'll leave the question open just a little longer in case someone else has an alternative suggestion. – drstevok Feb 19 at 8:17
So I have just discovered the sparklines package. Should have worked out that many of the things that Chartwell does can already be done in latex. Will use these instead of chartwell! – drstevok Feb 20 at 15:49

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.