# mtpro2 SQRT with root index affect the subsequent spacing

I recently installed math professional II font (mtpro2 lite). It works fine except that the SQRT with root index sucks.

$\sqrt[100]{1000000} = 1000 \quad \sqrt[3]{1000000} = 100$

$\SQRT[100]{1000000} = 1000 \quad \SQRT[3]{1000000}= 100$


Output

Is this a problem of the lite version (intended or not)? Does the complete version have this problem too? How can I define a new command to handle the situation automatically?

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Martin Schröder Jul 29 '15 at 8:35
• I can confirm that the full mtpro2 package suffers the same problem. My system runs MacOSX 10.10.4, and I use the version of pdfLaTeX that comes with MacTeX2015. – Mico Jul 29 '15 at 11:04
• Yup, same here. – JPi Jul 30 '15 at 2:44

Don't know exactly why this fixes the problem, but it seems to. ;-)

\documentclass{article}

\usepackage{mtpro2}
\usepackage{mathtools}

\newcommand{\SQRTFIX}[2][ ]{{\hphantom{\scriptscriptstyle{#1}}}\SQRT[\mathllap{#1}]{#2}}

\begin{document}

$\sqrt[100]{1000000} = 1000 \quad \sqrt[3]{1000000} = 100$

$\SQRT[100]{1000000} = 1000 \quad \SQRT[3]{1000000} = 100$

$\SQRTFIX[100]{1000000} =1000 \quad \SQRTFIX[3]{1000000} = 100$
\end{document}


The second image simply shows in the yellow box what the original $\SQRT$ does and in the blue box what $\SQRTFIX$ does.

• Good eyesight! Thanks to you, I was able to track down the bug in the mtpro2 package. – Ruixi Zhang Mar 13 at 3:04

Thanks to @JPi’s amazing eyesight, I was able to track down exactly the bug in the mtpro2 package. All credits goes to him/her.

@JPi’s solution suggests that the offsetting space is somehow the width of the root index. I confirm this is the case. The root index is placed inside a box called \rootbox. Here is how LaTeX defines its placement:

% From ltmath.dtx:
\def\r@@t#1#2{%
\setbox\z@\hbox{$\m@th#1\sqrtsign{#2}$}%
\mkern5mu\raise.6\dimen@\copy\rootbox
\mkern-10mu\box\z@}


which is the default, while mtpro2 does some similar things like:

% From mtpro2.dtx or mtpro2.sty
\def\R@@T#1#2{\setbox\z@\hbox{$\UPROOT@\z@\LEFTROOT@\z@\m@th#1\SQR@@T{#2}$}%
\dimen@ii\dimen@
\setbox\tw@\hbox{$\m@th#1\mskip\UPROOT@ mu$}\advance\dimen@ii by1.667\wd\tw@
\setbox\tw@\hbox{$\m@th#1\mskip10mu$}%
\mkern1mu\kern.13\dimen@\mkern-\LEFTROOT@ mu
\raise.5\dimen@ii\copy\rootbox % was .44
\mkern-1mu\kern-.13\dimen@\mkern\LEFTROOT@ mu\box\z@\kern-\wd\rootbox
\LEFTROOT\z@\UPROOT\z@}


Focusing on the overall structures, we see immediately that \R@@T has additional code of \kern-\wd\rootbox, which IMHO is utterly wrong. So here is my fix:

\documentclass{article}
\usepackage{newtxtext}
\usepackage{mtpro2}% lite or complete, does not matter here

\usepackage{etoolbox}
\makeatletter
\patchcmd\R@@T
{\kern-\wd\rootbox} % search this within \R@@T
{} % replace it with nothing
{}{}
\makeatother

\begin{document}
$\sqrt[100]{1000000} = 1000 \quad \sqrt[3]{1000000} = 100$
$\SQRT[100]{1000000} = 1000 \quad \SQRT[3]{1000000} = 100$
\end{document}


Note: \sqrt and \SQRT, by design, will produce slightly different results (as seen in the above picture). \SQRT is supposed to be used for really large formulae (hence the awkward root index placement). Please refrain from using \SQRT for small formulae.

• Wow! Thanks for doing this! – JPi Mar 13 at 11:47
• @JPi You are welcome! I have been investigating my complete font set for almost two months now. It all started with me trying to scale MathTime (see also Scaling the mtpro2 fonts to work with Baskerville). So far, I have found 13+ errors in the LaTeX support package… – Ruixi Zhang Mar 13 at 20:15
• I made a list of the 13+ bugs in a developing file mtpro2-patch.tex (Warning: Repository is mostly Chinese, but this file is in English). It is, for the most part, for my personal use. So the instructions inside were telling you to modify mtpro2.sty directly for yourself. However, the fixes for \undercbrace and \overcbrace (among other things) were deemed too complicated so I provided new definitions. – Ruixi Zhang Mar 13 at 20:25