TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The aim is to generate the .pdf with accented characters (the .tex file has mixed macro and unicode input), in a way that the .pdf text can be copy-pasted.

An example:




Unicode input: ā ī ū ṃ ṅ ñ

Macro input: \=a \={\i} \=u \d{m} \.n \~n


Compiling with pdflatex, the above will visually produce the desired characters, but when you select and copy-paste them from the .pdf, you get

Unicode input: a  ̄ u m n ñ
 ̄ı ̄ .  ̇
Macro input: a  ̄ u m n ñ

Ulrike's answer explains what pdflatex is doing here.

share|improve this question

pdflatex doesn't use "unicode compounds". You are using T1-encoding and for the accented chars not available in this encoding pdflatex use various methods to build them. E.g the dot below the m is actually a small tabular with the m in the first row and a dot in the second:


In theory you can get correct glyphs with pdflatex (if your font contains them). In practice it would mean a lot work. Better use xelatex or lualatex.

share|improve this answer
With XeLaTeX and LuaLaTeX, use, accordingly, \usepackage[EU1]{fontenc} and \usepackage[EU2]{fontenc}, or just load fontspec. – Andrey Vihrov Jul 3 '11 at 17:04
Thanks, I didn't realize that. I removed the latter part of the question accordingly. I see that I'll need to update lualatex to work with fontspec. – Nyiti Jul 3 '11 at 17:43
up vote 4 down vote accepted

This is the path to victory:

  1. Install TeX Live 2010 which has a luatex and fontspec version that work together. Follow the instructions on tug.org.

  2. On Linux, don't forget to update the $PATH! If you already have TeX Live installed with your package manager, give the new path priority over the old one. For example, at the end of ~/.bashrc, put PATH=/usr/local/texlive/2010/bin/i386-linux:$PATH; export PATH

  3. Log out and back in (or just open a new terminal) so that your $PATH updates.

Save this test to test.tex somewhere, and compile with
lualatex --interaction=nonstopmode test.tex


\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}


Unicode input: ā ī ū ṃ ṅ ñ

Macro input: \=a \={\i} \=u \d{m} \.n \~n


Open the resulting test.pdf, and when you copy-paste from it, you get

Unicode input: ā ī ū ṃ ṅ ñ
Macro input: ā ī ū ṃ ṅ ñ


share|improve this answer

Try adding \usepackage{cmap}. Or switch to xelatex/lualatex.

share|improve this answer
Thanks! There should be a phrase on this site for the "yet another latex package I didn't know about" feeling. – Nyiti Jul 6 '11 at 16:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.