16

Is there some way allow PDF search to find words with ligatures? I use XeLaTeX.

\documentclass{book}
\begin{document}
Prefix.
\end{document}

In the resulting pdf file, searching for the word "Prefix" fails.

doncherry
  • 54,637
srking
  • 1,125
  • Note that this is searchable e.g. with SumatraPDF on Win7. I'm assuming you used Acrobat Reader, with which I can reproduce your problem. Good MWE! – doncherry Aug 19 '12 at 21:01

1 Answers1

8

Add \usepackage{fontspec}. This actually loads the package fontenc, which would solve your problem for pdfLaTeX.

As a result, the ec fonts are loaded instead of the standard Computer Modern fonts, as Ulrike remarked in the comments. For other fonts, other solutions might apply; this answer addresses a standard setup as seen in the OP's MWE.

doncherry
  • 54,637
  • 5
    Your solution works because with fontspec you are using a different font which uses correct glyph names and so allow the pdf reader to "understand" the ligature. \usepackage[T1]{fontenc} (which switches from the cm fonts to the ec fonts), \usepackage{lmodern} or \usepackage{times} work too. – Ulrike Fischer Aug 20 '12 at 08:37
  • @Ulrike - Thanks for your clue in this comment! fontspec doesn't help for fonts without proper glyph names, e.g. Cambria. I switched to LibertineOTF and all is well. – srking Aug 20 '12 at 22:52
  • I have a similar problem. After adding '\usepackage{fontspec}' to the minimal example the word "prefix" becames searchable, however after adding '\setmainfont[Path=Fonts/,Extension=.ttf,BoldFont=FrutigerLTCom-Bold,ItalicFont=FrutigerLTCom-Italic,BoldItalicFont=FrutigerLTCom-BoldItalic]{FrutigerLTCom-Light}' the problem returns. – Mik May 03 '18 at 14:37
  • By the way, the document with the Frutiger font worked for years until I shortly updated my MikTeX. – Mik May 03 '18 at 16:18
  • @UlrikeFischer, could you look at this? – Mik May 04 '18 at 13:44
  • @Mik don't add a new question in a comment. Create a new question. – Ulrike Fischer May 04 '18 at 13:48
  • @UlrikeFischer: ok, will do so – Mik May 04 '18 at 13:50
  • Here is the new question: https://tex.stackexchange.com/questions/430054/failing-search-for-words-with-ligatures-after-update – Mik May 04 '18 at 14:08