[Tex/LaTex] scalebox / resizebox shifts fraction component

fractionsscaling

I have the following code in my document:

$$ \frac{\displaystyle \sum_i \min(A_i,B_i)}
        {\displaystyle \sum_i \max(A_i,B_i)} $$

resulting in:
                                                enter image description here
I prefer "display style" here, but the size of the contents in the numerator and denominator are a bit too large for my liking in the context where they appear, so I decided to scale down.

$$ \frac{\scalebox{0.75}{\text{$\displaystyle \sum_i \min(A_i,B_i)$}}}
        {\scalebox{0.75}{\text{$\displaystyle \sum_i \max(A_i,B_i)$}}} $$

but for some reason, this causes an unwanted shift:

                                                
enter image description here

so I'm forced to go back to standard "text style" mode in the meantime…

I can't spot why this might be happening based on the code above; I've also tried resizebox but it has the same issue … has anyone got any idea why it's happening or how I could fix it?

(EDIT: I solved my particular problem by scaling down the fraction as a whole rather than its constituent parts; but the question remains. Is this a latex bug? Thanks.)

Best Answer

In my opinion you don't really want \displaystyle, but neither you want \scalebox.

The size of \min and the other letters is right, it's just the summation symbol that grow too large:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\frac{\sum\limits_i \min(A_i,B_i)}
     {\sum\limits_i \max(A_i,B_i)}
\qquad
\frac{\displaystyle\sum_i \min(A_i,B_i)}
     {\displaystyle\sum_i \max(A_i,B_i)}
\]
\end{document}

enter image description here

If you really want to go the \scalebox way, enclose them in \mbox:

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\begin{document}
\[
\frac{\mbox{\scalebox{0.75}{$\displaystyle \sum_i \min(A_i,B_i)$}}}
     {\mbox{\scalebox{0.75}{$\displaystyle \sum_i \max(A_i,B_i)$}}}
\]
\end{document}

The issue is apparently due to how TeX typesets fractions, putting aside the numerator until it decides the size; the assignments performed by \scalebox get wrong without this further level of boxing.

Or, maybe better, use \mfrac from the nccmath package:

\documentclass{article}
\usepackage{amsmath}
\usepackage{nccmath}
\begin{document}
\[
\mfrac{\displaystyle \sum_i \min(A_i,B_i)}
      {\displaystyle \sum_i \max(A_i,B_i)}
\qquad
\frac{\displaystyle \sum_i \min(A_i,B_i)}
      {\displaystyle \sum_i \max(A_i,B_i)}
\]
\end{document}

enter image description here