0

The issue

I compile a latex document which contains accents ("é" for instance), then I copy the text from the pdf generated by pdflatex. Then, I paste this text to my latex file.

The resulting file cannot be completed, for some encoding reason.

Is there a way to solve this problem?

PS:

My system is OSX. My TeX distribution is TeXLive. My PDF previewer is Preview (the default Apple previewer application).

PPS:

This problem seems to be related more to Apple's Preview application than anything else.

Minimal non-working example

\documentclass{article}

\usepackage{cmap}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}

Copy this text "éàoùôêèç" and then paste it here : éàoùôêèç

Then compile again.

\end{document}

The error

./Sans-titre.tex:10: Package inputenc Error: Unicode char \u8:Ì not set up for use with LaTeX.

See the inputenc package documentation for explanation. Type H for immediate help. ...

                                               l.10 ... oùÎêÚç" and then paste it here : eÌ
                                              aÌouÌoÌeÌeÌç

enter image description here

Colas
  • 6,772
  • 4
  • 46
  • 96
  • 1
    Works fine for me (with and without cmap) on windows and sumatra or adobe reader. – Ulrike Fischer May 06 '14 at 11:33
  • My system is OSX. My TeX distribution is TeXLive. My PDF previewer is Preview (the default Apple previewer application). – Colas May 06 '14 at 11:58
  • 1
    Imho Apple decompose sometimes the glyphs in char+combining accent when you copy & paste. If you don't have this problem when you copy from other pdf's then it is perhaps due to the glyph names. You could then try \pdfglyphtounicode to change them. http://tex.stackexchange.com/a/4398/2388. – Ulrike Fischer May 06 '14 at 12:09
  • Yes, it works with Acrobat Reader. – Colas May 06 '14 at 12:23
  • I am using \input glyphtounicode \pdfgentounicode=1 when I am using the IL2 font encoding, or, I am using xelatex and lualatex engines without the inputenc package (I am using fontspec instead). – Malipivo May 06 '14 at 12:26
  • ... and Apple's Preview application? – Colas May 06 '14 at 12:27
  • I didn't wrote "if it works in other pdf readers" but "from other pdf's". The question is if apple preview does it always or if there is something special in the pdf's produced by pdflatex (which one could perhaps change). – Ulrike Fischer May 06 '14 at 12:30
  • Apple does it always IMHO. See http://www.betalogue.com/2004/09/21/pasting-accented-text-from-preview-to-word-how-to-get-the-accented-characters-right/ – Colas May 06 '14 at 13:27
  • It also might be an editor problem, hence a (perhaps naive) question: are you sure your editor saves your .tex file in utf8 format? – Bernard May 06 '14 at 14:08
  • @Bernard Yes I am sure. It is definitively a problem coming from Preview. – Colas May 09 '14 at 08:40

1 Answers1

1

This problem comes from Apple's Preview application up to OS X 10.9. I have not tested on newer versions.

See there.

Colas
  • 6,772
  • 4
  • 46
  • 96
  • 1
    You should provide some more detail here. Plus it can be argued that you're not really answering your own question here, since discovering that the problem lies with Preview is not a solution. – Sverre Sep 17 '15 at 21:25