# PDF text search doesn't find first word in section title

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?

• 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 Feb 10 '20 at 8:14
• 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. – Ulrike Fischer Feb 10 '20 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. – Richard Hansen Feb 10 '20 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). – Ulrike Fischer Feb 10 '20 at 22:55