I'm looking for a way to use the left and right narrow angle symbols (〈 〉, Unicode #3008, #3009) so that they are not changed when copy and pasted from a PDF.
These symbols are used e.g. by the doc
package for \meta{...}
and other formatting macros to indicate the content of an argument, e.g.: \command[〈options〉]{〈filename〉}
would be written with |\command|\oarg{options}\marg{filename}
. This package uses the \langle
and \rangle
math symbols. The problem with this is that if this code is copied from the generated PDF the symbols are changed to h
and i
, e.g.:\command[hoptionsi]{hfilenamei}
.
Detexify now pointed me to \textlangle
and \textrangle
from the textcomp
package. These angles are copied to ASCII angles <
and >
, respectively, which is much better already, but I like to have the correct narrow angles instead.
How can I insert this angles so that the can be copied correctly from the PDF? I tried to use [utf8]{inputenc}
and insert them as Unicode symbols in VIM manually (CTRL+V u 3008 or 3009, respectively) but got an error that this symbols are not setup for this use. I need this for my ydoc
class/package, an alternative to doc
and ltxdoc
and would like to avoid hassle with fonts and encoding as much as possible. This should work for PDFLaTeX and not just for XeLaTeX or LuaLaTeX.
Best Answer
With
the two symbols may be associated to U+27E8 MATHEMATICAL LEFT ANGLE BRACKET and U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET. If you want to input them directly, here it is how it can be done:
Another choice might be
You can use directly
\DeclareUnicodeCharacter
, of course, withinstead of
\newunicodechar
.This should allow to copy and paste the symbol from the PDF viewer, but it seems that the code of the copied character is viewer dependent, when
\textlangle
and\textrangle
are used. :(Thanks to Martin Scharrer for having suggested improvements to the answer.