34

Is there a way to make hyphenated words in a PDF generated by LuaTeX searchable? If the MWE below is converted to a PDF, searching for "lexicon" (in Acrobat X for example) will not find the word since it now contains a hyphen followed by a space character.

\documentclass{article}
\begin{document}
\parbox{2cm}{Break lexicon here.}
\end{document}
10
  • 5
    Adobe Reader 10.1.2 on Mac has no problem finding "lexicon". But surprisingly, Preview 5.0.3 can't find it. BTW, great MWE. I just wish more people would provide this. Feb 1, 2012 at 5:45
  • You're right, I wrote about Acrobat (which I have installed but didn't try) but tested Preview. So I guess it is really a question of the respective program's search algorithm and not the file format. Feb 1, 2012 at 5:53
  • 2
    @Dror: Since Skim uses OSX's PDF routines – as does Preview –, that's not surprising.
    – Simifilm
    Feb 1, 2012 at 9:29
  • 2
    @AymanElmasry But there could be a nice LuaTeX solution to overcome that problem.
    – topskip
    Feb 1, 2012 at 9:37
  • 3
    I am thinking: Shouldn't this (i.e. making hyphenated words searchable, by whatever means) be standard behavior for pdfTeX or LuaTeX when generating a PDF? Searching PDFs for expressions is such a common thing, really. Feb 1, 2012 at 12:10

1 Answer 1

6

Searching the PDF output here is really a function of the viewer. As such, each one takes a different approach to what it will work with. You see that not only with hyphenation but also with other awkward items.

2
  • Indeed : I tried the provided MWE under Linux with Evince, ePDFreader and Okular. Verdict : no, no, yes.
    – rcabane
    Nov 24, 2012 at 7:43
  • 9
    I disagree. Having the viewer's search function make up for deficiencies in the encoding is not the way to go. The PDF's contents should be encoded so that the difference between a syllable-separating hyphen (inexo-rably) and a word-joining hyphen (anti-imflammatory) at line ends are obvious to the viewer software. As this information is usually present before the document is created, it should not be removed in the process and then re-created heuristically during the search.
    – Douba
    Oct 27, 2015 at 8:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .