|
我在Wikibook讀到了加`\neg`重新定義根号的一種方式
- % New definition of square root:
- % it renames \sqrt as \oldsqrt
- \let\oldsqrt\sqrt
- % it defines the new \sqrt in terms of the old one
- \def\sqrt{\mathpalette\DHLhksqrt}
- \def\DHLhksqrt#1#2{%
- \setbox0=\hbox{$#1\oldsqrt{#2\,}$}\dimen0=\ht0
- \advance\dimen0-0.2\ht0
- \setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
- {\box0\lower0.4pt\box2}}
复制代码
我的理解是,它將 \sqrt 的高度保存到\dimen0,加入短竪線box2,它的一端的高度等於\sqrt的高度\dimen0,另一端的高度等於\sqrt的高度的$1-0.2=0.8$倍。
0.4pt應該是 \sqrt 的高度减去 \sqrt 的實際高度?
上述方法如果n次根號\sqrt[n]{a}將會出錯。
後面給出了加`\neg`重新定義n次根號的一種方式
- \usepackage{letltxmacro}
- \makeatletter
- \let\oldr@@t\r@@t
- \def\r@@t#1#2{%
- \setbox0=\hbox{$\oldr@@t#1{#2\,}$}\dimen0=\ht0
- \advance\dimen0-0.2\ht0
- \setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
- {\box0\lower0.4pt\box2}}
- \LetLtxMacro{\oldsqrt}{\sqrt}
- \renewcommand*{\sqrt}[2][\ ]{\oldsqrt[#1]{#2} }
- \makeatother
- $\sqrt[a]{b} \quad \oldsqrt[a]{b}$
复制代码 |
|