Unicode mapping based on font encoding
Packages cmap
or mmap
add information about glyph to Unicode conversions into the PDF file based on the used TeX encoding. The hooks into the font loading mechanism of LaTeX and should be used as early as possible, e.g.:
\RequirePackage{mmap}% (\usepackage does not work before \documentclass)
\documentclass{article}
Package mmap
is used here, because it has better math support AFAIK.
Unicode mapping based on glyph name
An alternative is a feature of pdfTeX that adds the mapping to Unicode based on the name of the glyph in the font. Therefore it does not work for PK fonts, because they do not contain glyph names.
\pdfgentounicode=1 %
\input{glyphtounicode}
Caution: Package cmap
or mmap
cannot be used together with \pdfgentounicode
. The result would be a duplicated entry in the font data dictionary. This is not allowed in the PDF specification:
Note: No two entries in the same dictionary should have the same key.
If a key does appear more than once, its value is undefined.
And copy&paste yield a random result depends on the PDF viewer.
Font encoding
Especially if you have accented characters or more special symbols you should consider using T1
font encoding. The default encoding for LaTeX is OT1
that support 7-bit only (max. 128 glyphs). Accented characters are constructed, that's bad for copy&paste:
\usepackage[T1]{fontenc}
You should have installed the cm-super
font bundle that contain Type 1 versions of the EC fonts. Or use the modern Latin Modern fonts. They descend from the CM/EC fonts.
\usepackage[T1]{fontenc}
\usepackage{lmodern}
1
is probably the page number...