2

When I run lualatex on the following MWE, open the resulting PDF in either Evince or Okular, and search for foo, I get zero matches. If I instead search for f oo (note the space between the f and oo) then a match is found. Searching for bar works fine. If I select "Foo" in the PDF, copy it, and paste it into a plain text document, I get F oo (note the space).

\documentclass[twoside]{article} % Works if twoside is removed.
\usepackage[tracking=true]{microtype} % Works if commented out or tracking=true removed.
\usepackage{geometry} % Works if commented out.
\usepackage{titlesec}
\titleformat{\section}{\normalfont\scshape}{}{0pt}{} % Works if commented out or \scshape removed.
\titlespacing*{\section}{ % Works if commented out.
  -1110630sp % Works if -1110629sp or greater.
}{*1.5}{*2}
\begin{document}%
\section{Foo Bar}%
\end{document}

If I tweak the above MWE as described in the comments, then searching for foo works (as does copy+paste).

Can anyone explain what is going wrong?

4
  • I assume that the small caps are letter spaced. Sometimes letter spacing end up as a space in the letter spaced text. I have the same problem when I copy and paste text from LaTeX pdf-document into Word, open the pdf in word 2016 or export the text from Adobe Acrobat to Word.
    – Sveinung
    Commented Feb 10, 2020 at 8:14
  • 2
    your example work fine for me on windows both in the sumatra viewer and the adobe viewer. But as @Sveinung writes: pdf viewer have to guess if a space is a real space or not here. You would have to tag the pdf and use real space char to reduce such problems (but it probably wouldn't prevent them completly). You could also try the accsupp package to add Foo as ActualText. Commented Feb 10, 2020 at 10:08
  • Thanks for the help. I tried tagging the PDF via the accessibility package but couldn't get it to work. I was able to get ActualText working via accsupp and \texorpdfstring, however. Commented Feb 10, 2020 at 22:24
  • I don't think that the accessibility package will work - the last time I looked it produced broken pdf as it didn't handle page breaks correctly. You could try tagpdf - with lualatex it works ok (but as it is experimental it can/will change). Commented Feb 10, 2020 at 22:55

2 Answers 2

2

Your example work fine for me on windows both in the sumatra viewer and the adobe viewer.

But as @Sveinung wrote in a comment: pdf viewer have to guess if a space is a real space or not and if the font is tracked they can err quite easily.

You would have to tag the pdf (see e.g. https://tex.stackexchange.com/a/444308/2388) and use real space char to reduce such problems (but it probably wouldn't prevent them completly).

You could also try the accsupp package to add Foo as /ActualText.

1

That bug was recently fixed in Poppler, so it will eventually get to Evince.

You must log in to answer this question.

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