You should separate input and output. If you want to print a symbol you at first need a font which contains it. If you want to use normal latex (it will work with xelatex too) you can e.g. use the dingbat font to get an anchor. If you want to use the symbol in the input you must declare it (I'm not sure if the ⚓ copy& paste correctly):
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{2693}{\anchor}
\usepackage{dingbat}
\begin{document}
\anchor ⚓
\end{document}
With xetex you can use e.g. dejavu sans (if you get the wrong glyph:make sure that you have only version of dejavu sans). Here too you can use commands/other notation if you don't want to use the symbol in the input:
\documentclass[12pt]{article}
\usepackage{fontspec}
\begin{document}
{\fontspec{DejaVu Sans Condensed} ^^^^2693 \char"2693 ⚓}
\end{document}
This is comparable to the problem of bundling several key-value arguments (for instance for \includegraphics
) in a macro: At the time of executing (the amsmath version of) \sqrt
, which is now \OldSqrt
, the content of []
is parsed for \leftroot
&c. At that time only \DHLindex
is found, and later \leftroot
is useless.
Changing
\setbox0=\hbox{$#1\OldSqrt[\DHLindex]{#2\,}$}\dimen0=\ht0\relax%
to
\setbox0=\hbox{$#1\expandafter\OldSqrt\expandafter[\DHLindex]{#2\,}$}\dimen0=\ht0\relax%
makes the \leftroot
visible and the first attempt goes through.
Dunno whether it does what you want though.
This should also work for attempt 2. Didn't look at attempt 3.
EDIT: What exactly do you want to know about the \DHLhksqrt
macro? AFAICS it takes two arguments, builds a root expression from them, which it measures and tries (with debatable success) to decorate with an additional vertical rule.
EDIT2: To make this look a bit better, at least \DHLhksqrt
needs to take into account when the root index is moved above the root symbol, otherwise the additional rule is placed too high.
EDIT3: Ok, here's my take at a correction for the displacement problem. The root is formatted twice, so there might be a performance problem.
\def\DHLhksqrt#1#2{%
\setbox0=\hbox{$#1\OldSqrt{#2\,}$}\dimen0=\ht0\relax%
\advance\dimen0-0.2\ht0\relax%
\setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
{\hbox{$#1\expandafter\OldSqrt\expandafter[\DHLindex]{#2\,}$}\lower0.4pt\box2}%
}
EDIT4: Unfortunately the root symbol has more whitespace above in bold math mode. Look at
\fboxsep0pt
\fbox{$f(x) = \OldSqrt{e^{2x}}$}
\fbox{\boldmath$ f(x) = \OldSqrt{e^{2x}}$}
Hence, this has to be considered when placing the "closing rule":
\makeatletter
\newcommand*\bold@name{bold}
\def\DHLhksqrt#1#2{%
\setbox0=\hbox{$#1\OldSqrt{#2\,}$}\dimen0=\ht0\relax%
\advance\dimen0-0.2\ht0\relax%
\setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
{%
\hbox{$#1\expandafter\OldSqrt\expandafter[\DHLindex]{#2\,}$}%
\lower\ifx\math@version\bold@name0.6pt\else0.4pt\fi\box2%
}%
}
\makeatother
Best Answer
Based on the linked answer you gave yourself, I suppose this is what you’re looking for.
You can find the definitions of the character code point (e.g.,
B2
for\oint
) intex/latex/stix/stix.sty
in your LaTeX distribution.