2

The TeX file

\documentclass[12pt]{article}
\begin{document}
ffi
\end{document}

produces the following ligature when compiled to PDF:

[image]

Note that ffi is represented by a single special character.

However, when I try to color each character in a different color, the characters won't translated to a ligature anymore. For example, when I type

\documentclass[12pt]{article}
\usepackage{color}
\begin{document}
\textcolor{red}{f}\textcolor{blue}{f}\textcolor{green}{i}
\end{document}

the produced PDF looks as follows:

enter image description here

Note that ffi is now represented by three individual characters.

Is there any possibility to color the characters without breaking ligatures apart, i.e.: to produce a ligature like in the first example but with colored characters?

  • 3
    A ligature is, by definition, a single glyph. – egreg Aug 28 at 15:24
  • 1
    not really: you could convert the outline of the ligature back to paths (pstricks can do that forexample) and then colour the parts separately. or colour the ligature character but then clip to show each part, doing that three times – David Carlisle Aug 28 at 15:24
  • @egreg: Good point :-) – seakey Aug 28 at 15:33
  • tex.stackexchange.com/questions/492129/… may help you... – MadyYuvi Aug 29 at 8:29
2

You can try with \llap command:

\documentclass[12pt]{article}
\usepackage{color}
\begin{document}
\textcolor{red}{f}\textcolor{blue}{f}\textcolor{green}{i}

\textcolor{red}{ffi}\llap{\textcolor{blue}{fi}}\llap{\textcolor{green}{i}}
\end{document}

It's not perfect (little discrepancy in the "i", why?, perhaps the PDF viewer?), but it's easy.

enter image description here

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.