4

The picture below says it all. Color highlighting with the soul package prevents a correct rendering of the ff ligature. Is there a way to fix this?

\documentclass{article}
\usepackage{color, soul}
\begin{document}
off -- offer \hl{off -- offer}
\end{document}

enter image description here


EDIT

cfr's answer below demonstrates that the problem disappears if the words are boxed with \mbox. This will, however, break hyphenation and line-breaking, features that I would like to retain.

  • You could just box the individual words. That would break hyphenation, but not line-breaking, I guess. – cfr Apr 4 '15 at 19:46
2

Boxing the text to be highlighted avoids the problem:

\documentclass{article}
\usepackage{xcolor, soul}
\begin{document}
  off -- offer \hl{\mbox{off -- offer}}
\end{document}

boxed highlighted text

  • 1
    But the only reason I'm using soul's \hl command over color's \colorbox command is that the former allows line breaks. \mbox would take that function away again :( – Sverre Apr 4 '15 at 19:41
  • @Sverre Well, you didn't say that in the question! – cfr Apr 4 '15 at 19:44
  • 1
    I know, but it's hard to predict in advance that the proposed solution will destroy something else in your document. I prefer to ask simple questions rather than say "here is a problem I have, and here are a thousand other things I do in my document that anyone trying to solve my problem will need to consider" :) – Sverre Apr 4 '15 at 19:46
  • @Sverre Fair enough. I'm not complaining. Just that you have to expect that answers may not always solve the actual problem in that case, since it is impossible to guess what additional desiderata you may have in mind :). – cfr Apr 4 '15 at 19:48
  • 2
    For sure - I am always aware of that possible problem. But I prefer to deal with that problem when and if it arises. So I'll edit the question accordingly now. – Sverre Apr 4 '15 at 19:51

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.