# The √ symbol in the unicode-math package

I'm using the unicode-math package in comination with xelatex. Thanks to this package I can write unicode symbols in the tex code. However some unicode symbols, don't compile the way I would expect it. For example, I hoped that if type $√{2+3}$ that this would compile the same way as $\sqrt{2+3}$. But I get this output:

What is happening here, and how can I fix this ?

Edit: I understand now that I can fix this using:

\usepackage{unicode-math,newunicodechar}
\newunicodechar{√}{\sqrt}


Now I'm wondering how I could define something like:

\unicodedef█$$#1$${$$#1$$}

-
There is a difference between the character and a square root layout just as there is a difference between / and a fraction. The odd position is because TeX traditionally uses the height of character to specify the width of the rule, so it has small height and large depth. You could of course define √ to be an active character defined as \sqrt but that is not the default. –  David Carlisle Nov 7 '13 at 9:26
@DavidCarlisle Ah, I found it. So I need to do: \usepackage{unicode-math,newunicodechar} \newunicodechar{√}{\sqrt} –  Kasper Nov 7 '13 at 9:32

As you already figured out, by default √ is just printed as a usual symbol and not a mathematical object. Thus you must define it

\documentclass{article}
\usepackage{unicode-math}

\usepackage{newunicodechar}
\newunicodechar{√}{\sqrt}


Now you want to put the argument in between an equation environment. To do that you need to define an auxiliary macro which does that for you:

\newcommand\myeq[1]{$$#1$$}
\newunicodechar{█}{\myeq}


But there are more options. You can also make the character \active manually and use it as command name

\catcode▒=\active
\newcommand▒[1]{$$#1$$}


Or you can mark the end of the equation by another character

\catcode▙=\active
\long\def▙$$#1$$▜{$$#1$$}


To do this with newunicodechar you need to define

\newunicodechar{▛}{$$} \newunicodechar{▟}{$$}


This has the possible problem, that when is expanded, it can not see but only ▟. Although it seems to work in my examples:

\begin{document}

█{√{a^2 + b^2} = c}

▒{a + b ≥ c}

▙e^{iπ} + 1 = 0▜

▛f(z) = \frac{1}{2πi}∫_{∂B_ε(z)}{\frac{f(ζ)}{ζ-z}\;\mathrm{d}ζ}▟

\end{document}

-
doesn't look up to find the matching , so this works (but I wouldn't recommend doing so). It won't work for align and the other multiline environments. In (Xe|Lua)LaTeX, \newunicodechar just makes the character active and defines it to what the second argument specifies. The definition is \protected, but not \long (which is irrelevant for a command with no argument). –  egreg Feb 27 '14 at 13:43
With \newunicodechar no argument can be specified; but one can say \newcommand{\myeq}[1]{$$#1$$ and \newunicodechar{█}{\myeq}. Again, I wouldn't recommend doing so. –  egreg Feb 27 '14 at 13:45
@egreg: Thanks for the details. The second comment is exactly what I wrote as the first suggestion ;-) –  canaaerus Feb 27 '14 at 13:47
I should pay more attention. ;-) –  egreg Feb 27 '14 at 13:55

as active character:

\documentclass{scrartcl}
\usepackage{unicode-math}
\setmathfont{XITS Math}

\begin{document}
$√2+3$

\catcode\√=13 \let√\sqrt
$√{2+3}$
\end{document}
`

-