# How to enable copy and paste of numbers from latex documents with cfr-lm?

I have an issue when copying and pasting numbers from a PDF generated with pdflatex (pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018/W32TeX)) and Acrobat Reader/Acrobat Professional. Also reported at https://github.com/latextemplates/LNCS/issues/22.

MWE:

\documentclass{article}
\usepackage{cfr-lm}

\setlength\parindent{0pt}
\obeylines

\begin{document}
Normal number: 100.
Math mode number: $100$.
\end{document}


Acrobat Professional copy result:

Normal number: 322.
Math mode number: 100.


With oldstyle=false:

\documentclass{article}
\usepackage[rm={oldstyle=false}]{cfr-lm}

\setlength\parindent{0pt}
\obeylines

\begin{document}
Normal number: 100.
Math mode number: $100$.
\end{document}


Result:

Normal number: 􀀀􀀀.
Math mode number: 100.


With lmodern, everything works as expected:

\documentclass{article}
\usepackage{lmodern}

\setlength\parindent{0pt}
\obeylines

\begin{document}
Normal number: 100.
Math mode number: $100$.
\end{document}


Result:

Normal number: 100.
Math mode number: 100.


## Notes

Note that this issue does not appear with SumatraPDF.

This issue also happens with pdf.js in Firefox. Also, using lualatex (LuaTeX, Version 1.07.0 (TeX Live 2018/W32TeX)) does not help.

It also happens with the documentation of cfr-lm. Go to http://texdoc.net/pkg/cfr-lm (with Firefox), copy "Version 1.5 - 2015-02-01". The pasted result is: "Version 3.7 — 4237–24–23"

• Why do you insist on using pdftex when we have luatex/xetex and fontspec? I'm sure whatever this package does can also be done with fontspec. – Martin Schröder May 8 '18 at 9:48
• I can't reproduce this in Okular either. I wouldn't recommend using this package with LuaTeX: in that case, use fontspec. There's no reason to use cfr-lm in that case. – cfr May 22 '18 at 0:38

You can use glyphtounicode:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{cfr-lm}
\input glyphtounicode
\pdfgentounicode=1
\setlength\parindent{0pt}
\obeylines
\pagestyle{empty}
\begin{document}
1234567890 copied: 1234567890

\end{document}

• This is a case, where cmap does not help. Thank you for pointing it out. – koppor May 8 '18 at 10:52
• You don't need to load fontenc here. Do you think cfr-lm should load glyphtounicode? (Conditionally, if pdfTeX is used?) – cfr May 22 '18 at 0:40