[Tex/LaTex] Can’t overwrite Unicode character definition

unicode

I want this Unicode symbol , left-pointing angle bracket, to be interpreted as \langle.

On TeX Live on my Mac, I tried this:

\documentclass[11pt]{article}
\usepackage[utf8x]{inputenc}

\DeclareUnicodeCharacter{2329}{\langle}

\begin{document}
$ 〈  $
\end{document}

which produces this error:

./foo.tex:7: Package ucs Error: Unknown Unicode character 9001 = U+2329,
(ucs)                possibly declared in uni-35.def.
(ucs)                Type H to see if it is available with options.
Unicode character 9001 = U+2329:
Unicode character 9001 = U+2329:
LEFT-POINTING ANGLE BRACKET
BRA
Character available with following options:
   postscript.

But I don't want to use the option postscript, I just want to define that Unicode character 2329 should emit \langle.

What am I doing wrong?

Best Answer

You can use the newunicodechar package, but not with the utf8x option to inputenc:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}
\newunicodechar{〈}{\langle}

\begin{document}
$〈$
\end{document}

If you want to use ucs and utf8x (which I can't recommend), you have to load ucs with the Postscript option. The definition associated to U+2329 is however faulty, because it produces nothing even when loading pifont, that seems required. I provide a workaround.

\documentclass[11pt]{article}
\usepackage[postscript]{ucs}
\usepackage[utf8x]{inputenc}

\makeatletter
\AtBeginDocument{%
  \sbox0{\let\Pisymbol\relax〈}% this loads uni-35.def and defines the character
  \@namedef{u-postscript-9001}#1{\langle}% we can now change the definition
}
\makeatother

\begin{document}

$a〈b$
\end{document}
Related Question