Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AMSMath's \uproot and \leftroot #3950

Open
gujunhk opened this issue May 7, 2024 · 1 comment
Open

Implement AMSMath's \uproot and \leftroot #3950

gujunhk opened this issue May 7, 2024 · 1 comment

Comments

@gujunhk
Copy link

gujunhk commented May 7, 2024

\uproot and \leftroot can run in GitHub Markdown(maybe MathJax):

$$\sqrt[\uproot{16}\leftroot{-2}\frac1n]{1+\frac{\sqrt{2}}{n}}$$

$$\sqrt[\uproot{16}\leftroot{-2}\frac1n]{1+\frac{\sqrt{2}}{n}}$$

I wish they'll also be rendered in KaTeX 馃

@edemaine
Copy link
Member

edemaine commented May 7, 2024

Thanks for the feature request! I didn't know these were in amsmath, and I agree they'd be useful.

If I'm reading the source code correctly:

\def\r@@t#1#2{\setboxz@h{$\m@th#1\sqrtsign{#2}$}%
 \dimen@\ht\z@\advance\dimen@-\dp\z@
 \setbox\@ne\hbox{$\m@th#1\mskip\uproot@ mu$}%
 \advance\dimen@ by1.667\wd\@ne
 \mkern-\leftroot@ mu\mkern5mu\raise.6\dimen@\copy\rootbox
 \mkern-10mu\mkern\leftroot@ mu\boxz@}

it looks like \uproot and \leftroot translate into shifts by the specified number of "mu" units.

So I think you can simulate the same behavior in KaTeX today using \hspace and \raisebox:

\sqrt[\raisebox{16mu}{\hspace{-2mu}$\scriptstyle\frac1n$}]{1+\frac{\sqrt{2}}{n}}

Here's how that renders, compared to the non-spaced version:

image

Not exactly what you pasted from MathJax, and neither matches what LaTeX actually renders with \uproot and \leftroot, but it's close:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants