Is it possible to define
\newcommand{\√}[1]{\sqrt{#1}}
as commands like this one would sometimes be easier to use.
Is it possible to define
\newcommand{\√}[1]{\sqrt{#1}}
as commands like this one would sometimes be easier to use.
If there were no argument to the macro, this would be just a matter of loading the newunicodechar package or using the \DeclareUnicodeCharacter macro. For the "character" to accept arguments, a slightly different approach is needed.
If you use XeTeX or LuaTeX, you can use either of
\catcode`\√=\active
\newcommand{√}[1]{\sqrt{#1}}
…
$√{2}$
or
\newcommand{\√}[1]{\sqrt{#1}}
…
$\√{2}$
(The second approach is more robust.)
With pdfTeX the \√ syntax will not work because of the way pdfTeX handles input (it is theoretically possible to achieve this, though). This leaves the only way (taken and modified from newunicodechar documentation):
\documentclass{article}
\usepackage[utf8]{inputenc}
\expandafter\newcommand\csname u8:\detokenize{√}\endcsname[1]{%
\sqrt{#1}}
\begin{document}
$√{2}$
\end{document}
\newunicodechar{⟨}{\langle} \newunicodechar{⟩}{\rangle} works for me in LuaTeX and TeX Live 2011.
– Andrey Vihrov
Sep 10 '11 at 15:13