# Encoding to be able to search pdf

I am writing a document in Czech. I want

1. To be able to fully search the pdf (at the moment I can search only for words with non-Czech characters, but I want to be able to search with Czech characters as well).
2. To be able to copy & paste from the pdf. At the moment, when I copy the text and paste it in notepad, words such as "společnost" are pasted as "spolecˇnost".

My MWE:

\documentclass[11pt,a4paper]{article}
\usepackage[czech]{babel}
\usepackage[X]{inputenc}
\usepackage[Y]{fontenc}
\begin{document}
Zvyšuje se nebezpečí, že skupina pomatených lidí na společnosti napáchá obrovské škody.
\end{document}


What should go instead of X and Y? Thank you.

-

X is irrelevant, use whatever encoding allows you to enter your chars, e.g. utf8.

For Y you need T1. You should also use glyphtounicode (the č works only with it).

\documentclass[11pt,a4paper]{article}
\usepackage[czech]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\input{glyphtounicode}
\pdfgentounicode=1
\begin{document}
Zvyšuje se nebezpečí, že skupina pomatených lidí na společnosti napáchá obrovské škody.
\end{document}

-
+1 I was writing the same answer! –  JLDiaz Dec 21 '12 at 8:30

glyphtounicode and cmap
The X and Y are probably not the problems.

With reference to page 7 in the MinioPro-manual, to make figures and ligatures searchable, you need to enable glyphtounicode translation and load the default mapping table:

\input{glyphtounicode}
\pdfgentounicode=1


glyphtounicode was included in my MikTeX-distribution, but if it is not included in yours, you can find it at Sarovar.

This solution works with all fonts.

If you are using computer modern as font, you may try adding:

\usepackage{lmodern}


I also tried cmap, but it still not make the special glyphs searchable. In addition, I tried the tex-gyre font thermes (similar to times)

\usepackage{tgthermes}


The glyphs are not searchable (but should have been).

I guess this is because the glyphs are not defined in the font and therefore Tex constructs them by combining two other glyphs. I do not have the skills to help you further, but may be @egreg can: Copy Czech characters from PDF with charter font

newtx and tgtermes
Regarding newtx, this MWE compiles on my system, but the Czech characters are not searchable:

\documentclass[final,oneside,a6paper,11pt,norsk,article]{memoir}
%\documentclass{standalone}
\usepackage{fixltx2e}
\usepackage{babel}
\usepackage[osf]{newtxtext}
\input{glyphtounicode}
\pdfgentounicode=1

\usepackage{lipsum}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}

\begin{document}

Dette er en prøve på æøå AÅØ
Dette er en prøve på æøå AÅØDette er en prøve på æøå AÅØDette er en prøve på æøå AÅØDette er en prøve på æøå AÅØDette er en prøve på æøå AÅØDette er en prøve på æøå AÅØDette er en prøve på æøå AÅØDette er en prøve på æøå AÅØDette er en prøve på æøå AÅØ

vis-à-vis ñ ôö ä

1234567890

Zvyšuje se nebezpečí, že skupina pomatených lidí na společnosti napáchá obrovské škody.

\end{document}


You have to extend the glyphtounicode-table with the Czech characters.

I have no time to look into that now, but perhaps some of the tex-wizards may help. I believe it is so simple as to provide some commands in the form:

\pdfglyphtounicode{A}{0041}
\pdfglyphtounicode{AE}{00C6}
\pdfglyphtounicode{AEacute}{01FC}
\pdfglyphtounicode{AEmacron}{01E2}


Where the first and second parametres are the code from the font and the second is the Unicode-representative.

-
This seems to work for me only with \usepackage{lmodern}. However, I am writing in \usepackage{times}, where several characters (notably č, ě, ř) do not work. What should I do? –  Dominik Teiml Dec 21 '12 at 9:00
@DominikTeiml I suggest you try using a more modern times-package. Try the newtx-package (\usepackage[osf]{newtxtext}), see mail-archive.com/ctan-ann@dante.de/msg04863.html. Also check that glyphtounicode is installed on your system. –  Sveinung Dec 21 '12 at 9:34
When I use \usepackage{newtxtext}, the characters č, ě, ř still don't work propertly. And when I use \usepackage[osf]{newtxtext}, I get a fatal error (not as a red error message, but in the log file), so that the pdf isn't even produced. Is there no way to be able to type in Times and correctly produce foreign characters? Btw, glyphtounicode must be installed on my system since there is no problem if I use \usepackage{lmodern}, but I really want to write in Times. –  Dominik Teiml Dec 21 '12 at 10:14
@egreg Have a look at this question, please. –  Sveinung Dec 21 '12 at 12:41
@Sveinung: interesting… however I was looking for documentation on glyphtounicode and only found a couple lines about \pdfglyphtounicode in pdfTeX's manual. Your recommandations to try different fonts or a newer Times package suggests that this is a feature that needs some love from maintainers and TeX distributions… any chance we get a fix in TeXlive 2013 or 2014? –  Damien Pollet Dec 21 '12 at 14:21