3

I would like to make the sub-/supperscript smaller 10% and use package scalerel to do that. Everything is fine until I find out that the sub-/superscript in operators are also scaled but they are not center aligned.

Any idea for fixing this issue. Thanks.

\documentclass{article}
\usepackage{amsmath}
\usepackage{subdepth}
\usepackage{scalerel}

\mathcode`_="8000 
\catcode`_=12 
\mathcode`^="8000 
\catcode`^=12
\begingroup
\catcode`_=\active
\catcode`^=\active
\gdef_#1{\ensuremath{\sb{\begingroup \hstretch{.9}{\vstretch{.9}{#1}} \endgroup}}}
\gdef^#1{\ensuremath{\sp{\begingroup \hstretch{.9}{\vstretch{.9}{#1}} \endgroup}}}
\endgroup

\begin{document}
\(a^2 \qquad \sum\limits_{2}^{3}\)
\end{document}

enter image description here

1

2 Answers 2

1

In my other answer, I suggested an alternate approach to the OP's dilemma, through the use of the \DeclareMathSizes macro. However, in a comment, the OP asked if I could also resolve the issue using his original approach.

When I first looked at the OP's result, I though the mis-centering of the scripts was related to my scalerel package. However, upon closer inspection, I found that if I replaced the OP's \hstretch{.9}{\vstretch{.9}{#1}} with a \scalebox{.9}{#1}, the problem persisted.

I found, through experimentation, that if I wrapped the super/sub-script redefinitions in an \hbox, proper centering was restored.

Using the facilities of the scalerel package to import the current math style into the \hbox, I recast the OP's redefinitions in a way that preserved horizontal centering. In this MWE, I also set the rescale to 0.7, rather than 0.9, merely to emphasize the resizing.

\documentclass{article}
\usepackage{amsmath}
\usepackage{subdepth}
\usepackage{scalerel}

\mathcode`_="8000 
\catcode`_=12 
\mathcode`^="8000 
\catcode`^=12
\begingroup
\catcode`_=\active
\catcode`^=\active
\gdef_#1{\sb{\ThisStyle{\hbox{\scalebox{.7}{$\SavedStyle#1$}}}}}
\gdef^#1{\sp{\ThisStyle{\hbox{\scalebox{.7}{$\SavedStyle#1$}}}}}
\endgroup

\begin{document}
\(a^2 \qquad \sum\limits_{2}^{3}\)
\end{document}

enter image description here

As to why the \hbox is required, I suspected that the super/sub-scripts performed an \unhbox as part of their process, and therefore needed an \hbox on which to act.

The following MWE, in which I had \unhbox announce its arrival, confirmed my suspicions:

\documentclass{article}
\usepackage{amsmath}
\usepackage{subdepth}
\usepackage{scalerel}

\mathcode`_="8000 
\catcode`_=12 
\mathcode`^="8000 
\catcode`^=12
\begingroup
\catcode`_=\active
\catcode`^=\active
\gdef_#1{\sb{\ThisStyle{\hbox{\scalebox{.7}{$\SavedStyle#1$}}}}}
\gdef^#1{\sp{\ThisStyle{\hbox{\scalebox{.7}{$\SavedStyle#1$}}}}}
\endgroup

\let\svunhbox\unhbox
\def\unhbox{*\svunhbox}
\begin{document}
\(a^2 \qquad \sum\limits_{2}^{3}\)
\end{document}

enter image description here

5

I would instead recommend the use of \DeclareMathSizes to address the issue:

\documentclass{article}
\usepackage{amsmath}
%\usepackage{subdepth}
%\usepackage{scalerel}

\DeclareMathSizes{10}{10}{6}{5}

\begin{document}
xxx\(a^2 \qquad \sum\limits_{2}^{3}\)zzz
\end{document}

enter image description here

For comparison, here is the reference scale, in which the scripts are slightly larger:

enter image description here

2
  • thank you. I will try this. But for my old code, is there any way to utilize it?
    – Nuec Tah
    Nov 8, 2021 at 18:46
  • 1
    @NuecTah It is an interesting issue. At first, I thought my scalerel package to be responsible. However, if I replace the h- and v-stretches with a simple \scalebox, the same shifted behavior occurs. I have not yet resolved why, but I will keep on looking. Nov 8, 2021 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.