请查看以下 MWE。我找到了一个自动解决好根的方法。字母的深度被忽略,下标不影响深度。
但是当我嵌套根时,它变得丑陋。我做错了什么?为了获得漂亮的嵌套根,必须做些什么?
谢谢。
抱歉使用了\over
,但我通常使用 Plain (Lua-)TeX。但使用低级命令加载 OTF 字体会在代码中产生许多额外的行,因此我使用 LuaLaTeX 和 Unicode Math 编写了这个 MWE。
% Only for LuaTeX
\documentclass[17pt]{extarticle}
\usepackage[math-style=upright]{unicode-math}
\setmainfont{lmroman10-regular.otf}
\setmathfont{latinmodern-math.otf}
\begin{document}
\makeatletter
\newbox\r@@tbox
\newdimen\r@dic@ldepth
% to get cramped style
\def\mathpalettecramped#1#2{\mathchoice{#1\crampeddisplaystyle{#2}}%
{#1\crampedtextstyle{#2}}{#1\crampedscriptstyle{#2}}%
{#1\crampedscriptscriptstyle{#2}}}
\protected\def\sqrt{\mathpalettecramped\printr@@t}
\def\printr@@t#1#2{\begingroup
\Umathcodenum`j=`i % example for goobling depth of letters
\setbox\z@\hbox{\scantokens{\catcode`\_=\active \let_=\@gobble
$\m@th#1{\vphantom{0}#2}$}} % Subscripts do not influence depth
\global\r@dic@ldepth\dp\z@
\endgroup
\setbox\r@@tbox\hbox{$\m@th#1{\vphantom{0}#2}$}
\dp\r@@tbox\r@dic@ldepth
\Uradical"0"221A {\box\r@@tbox}}
\section{Good}
This works fine for not nested roots:
$ \sqrt A \sqrt j $, $ \sqrt{Aj} $, $ \sqrt{1_{1_1}\over Aj_{A_A}} $
\section{Bad}
However, there is a problem with nested roots:
$ \sqrt{\sqrt{\sqrt{\sqrt{\sqrt{11}}}}} $
The base of the root signs alternates and the radical rules
are vertically spaced unequal. What am I doing wrong?
\end{document}