7

If you compile the piece of code given below using pdflatex, then open the resulting PDF file with your preferred viewer, copy the word "efficient" and paste it in a text editor, you will read "efcient". This does not happen with xelatex or lualatex. Is there a way to fix this issue with pdflatex?

\documentclass[fleqn,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{libertine}
%\usepackage{lmodern}
\begin{document}
efficient
\end{document}
  • Doesn't happen to me. Can you be more precise about your TeX system? – egreg Sep 11 '18 at 11:13
  • 1
    Add \input glyphtounicode \pdfgentounicode=1. – Ulrike Fischer Sep 11 '18 at 12:13
  • 1
    @UlrikeFischer Could you please transform your comment into an answer with maybe adequate explanatory details? Thanks – pluton Sep 11 '18 at 12:26
  • 1
    @Mico yes I could but it looks like there is an easier fix, see above. – pluton Sep 11 '18 at 12:30
  • 1
    @Mico I see the problem also with tl2018. Imho it is (also) viewer (and so OS) dependant. – Ulrike Fischer Sep 11 '18 at 12:47
7

Add

\input glyphtounicode
\pdfgentounicode=1

glyphtounicode.tex contains a lot of mappings like

\pdfglyphtounicode{ffi}{0066 0066 0069}

which are added to the pdf and helps the viewer to correctly interprete special chars. I didn't check which of the mappings is needed for libertine, imho it doesn't harm to simply load the whole lot.

The issue itself can be viewer dependant -- some are better in guessing than other.

  • Why not simply load cmap, see pdftex-a.pdf, p. 31: »LaTeX users could load the cmap package to achieve the same effect.« ? – Keks Dose Sep 14 '18 at 12:03
  • @KeksDose cmap doesn't work for all fonts (and here not with libertine). "The main limitation currently is inability to work with virtual fonts". – Ulrike Fischer Sep 14 '18 at 12:24
  • Aha, thank you! I should have had a look into the cmap manual. Which says, by the way, the inablity to work with virtual fonts were a limitation of pdftex. So on the pdftex side this is no longer a limitation? – Keks Dose Sep 14 '18 at 12:26

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.