# Copying ligatures from XeLaTeX PDF

For quite a while I am having the problem that copying and searching from my PDFs is a bit difficult as ligatures are not properly translated. I am using XeLaTeX with Libertine/Biolinum.

I am a simple user, so I tried workarounds I found on the internet (Make ligatures in Linux Libertine copyable (and searchable) - \pdfglyphtounicode with XeTeX - Can PDF search find words with ligatures in XeLaTeX-documents?) but all of this doesn't work.

Here's my MWE

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass{scrreprt}
\usepackage{fontspec}
%\defaultfontfeatures{Ligatures=Historic}
%\setmainfont{Linux Libertine O}
\usepackage{libertine}
\begin{document}
fluffier soufflé fisticuffs fb fh ffh fj ffj fk ffk ft fft tt Qu Th ch ck ct
\end{document}


Which renders

u er sou é sticu s ch ck ct

for the above and

u er sou é icu s ch ck

when I use the historic ligatures.

Using \input{glyphtounicode} workaround I get:

Undefined control sequence. l.7 \pdfglyphtounicode{A}{0041}

Using \usepackage[t1]{fontenc} I get:

/usr/local/texlive/2014/texmf-dist/tex/latex/base/fontenc.sty:100: LaTeX Error: Encoding scheme t1' unknown.

See the LaTeX manual or LaTeX Companion for explanation.

Type H for immediate help.

l.100 \fontencoding\encodingdefault\selectfont

Experimenting with other fonts shows very mixed results, so while it's obviously possible that the problem is in the fonts, is there something, anything, I can do to work around this and still keep ligatures?

Something like the above-mentioned

\input{glyphtounicode}

\pdfglyphtounicode{f_f}{FB00}


where I could "translate" the ligatures by hand - the above doesn't work for me, though.

• If I compile your very example, select the words in my PDF previewer and paste, I get what you can see here: fluffier soufflé fisticuffs fb fh ffh fj ffj fk ffk ft fft tt Qu Th ch ck ct Jan 21, 2016 at 13:29
• It depends on where you paste the text. A while ago it happened to me with certain ligatures, and nowadays it still occurs with accents appearing as ’e but it only occurs in some editors. If you paste it somewhere else and then copy it back, it works fine. Jan 21, 2016 at 13:35
• @egreg - In a way I am glad to hear that, what am I doing wrong then? I am using the latest Libertine fonts (well, they haven't been updated for ages, but still) and "This is XeTeX, Version 3.14159265-2.6-0.99991 (TeX Live 2014)" BTW, I am on OSX. Jan 21, 2016 at 17:03
• My try was with TL 2015, but if I do the same with TL 2014, I paste here like this: fluffier soufflé fisticuffs fb fh ffh fj ffj fk ffk ft fft tt Qu Th ch ck ct Jan 21, 2016 at 17:07
• @jan I can also reproduce Thorsten’s problem on a Mac using either Skim or Preview. However, in Acrobat Reader everything works as it should, and I can correctly copy and paste ligatures. Feb 1, 2018 at 23:06

Try adding \XeTeXgenerateactualtext=1` at the start of your document.