14

I'm aware of this question that explains the difference between \sin and \cos because of the letter 'i' in \sin. However, just out of curiosity, I don't understand why \tan isn't treated like \sin in the following MWE. After all, the 't' has about the same height as the 'i', doesn't it? Also, I only see this with amsmath.

\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
$\frac{\sqrt{a^2+4b^2\sin^2\alpha}}{2}$\quad\quad
$\frac{\sqrt{a^2+4b^2\cos^2\alpha}}{2}$\quad\quad
$\frac{\sqrt{a^2+4b^2\tan^2\alpha}}{2}$
\end{document}

enter image description here

7
  • It isn't realli i vs t, try 2\sin^2 vs 2\cos^2 vs 2\tan^2, the sqrt is the same, then add a = before the 2
    – daleif
    Commented May 26, 2023 at 9:14
  • 1
    Using Computer Modern, i and t do not have the same height. The height of the letter i is a tad larger than that of the lettter t which is probably the reason for the above behaviour. But this does not really answer why the scaling is that much different, I have to admit. Commented May 26, 2023 at 9:56
  • 4
    @JasperHabicht I think it is like this: The radical comes in different sizes, and a threshold is hit, just for the difference of heights of the i and the t. If one does not load amsmath it seems that the threshold is different, and the radical for tan is also bigger. Maybe some parameter is set differently in amsmath.
    – mickep
    Commented May 26, 2023 at 11:38
  • 1
    In any case, as everywhere in life, \smash is your friend.
    – Gaussler
    Commented May 26, 2023 at 11:51
  • 1
    It is in fact a combination of the heights of the i and the t and the depth of the +. Nice example.
    – mickep
    Commented May 26, 2023 at 12:44

2 Answers 2

11

You can notice that the exponent is a bit higher in \sin^2 than in \tan^2, which in turn is higher than in a^2. The height of i is larger than the height of t, but only to an extent that affects the placement of the superscript in cramped styles.

\documentclass[12pt]{article}
\usepackage{mathtools}

\newcommand{\two}{2\rlap{\vrule height 0pt depth 0.1pt width 3cm}}

\begin{document}

\begin{gather*}
a^{\two} \tan^{\two} \sin^{\two} \\
\cramped{a^{\two} \tan^{\two} \sin^{\two}} \\
\textstyle a^{\two} \tan^{\two} \sin^{\two} \\
\textstyle \cramped{a^{\two} \tan^{\two} \sin^{\two}}
\end{gather*}

\end{document}

enter image description here

The math material under the square root is typeset in cramped style and you can see in the image the difference in height.

Workaround, very useful when you have a lot of trigonometry:

\documentclass[12pt]{article}
\usepackage{amsmath,mathtools}

\let\sin\relax
\let\tan\relax
\DeclareMathOperator{\sin}{\vphantom{x}\smash{\mathrm{sin}}}
\DeclareMathOperator{\tan}{\vphantom{x}\smash{\mathrm{tan}}}

\newcommand{\two}{2\rlap{\vrule height 0pt depth 0.1pt width 3cm}}

\begin{document}

\begin{gather*}
a^{\two} \tan^{\two} \sin^{\two} \\
\cramped{a^{\two} \tan^{\two} \sin^{\two}} \\
\textstyle a^{\two} \tan^{\two} \sin^{\two} \\
\textstyle \cramped{a^{\two} \tan^{\two} \sin^{\two}}
\end{gather*}

\begin{center}
$\frac{\sqrt{a^2+4b^2\sin^2\alpha}}{2}$\quad
$\frac{\sqrt{a^2+4b^2\cos^2\alpha}}{2}$\quad
$\frac{\sqrt{a^2+4b^2\tan^2\alpha}}{2}$
\end{center}
\[
\frac{\sqrt{a^2+4b^2\sin^2\alpha}}{2}\quad
\frac{\sqrt{a^2+4b^2\cos^2\alpha}}{2}\quad
\frac{\sqrt{a^2+4b^2\tan^2\alpha}}{2}
\]

\end{document}

enter image description here

9
  • 1
    Actually, I would question why the exponent is higher in $\sin^2$ than in $4b^2$. I would have thought that the ascender on $b$ is just as tall as the dot on the i. Commented May 26, 2023 at 13:47
  • 2
    @barbarabeeton “sin” makes a box and the superscript is placed with respect to the box: try $b^{\two}{{}b}^{\two}$ and you'll see that the superscript is higher in the second case.
    – egreg
    Commented May 26, 2023 at 14:39
  • Thanks. Reasonable explanation, but I do wonder why the box. Commented May 26, 2023 at 15:13
  • @barbarabeeton It's essentially \mathop{\mathrm{sin}} and this is a subformula, hence it's boxed when the math list is translated to a horizontal list. The alternative would be \mathop{\mathrm{s}}\!\mathrm{i}\!\mathop{\mathrm{n}}. However, this is definitely unfeasible for operator taking limits.
    – egreg
    Commented May 26, 2023 at 16:30
  • I guess I have to go back and read the details of Appendix G. i'd forgotten about the boxing. Commented May 26, 2023 at 17:46
10

You have already gotten ideas on how to get around it, so let me just elaborate a bit. (This is too long for being a comment.)

This is a nice example where several things coincide.

  • The radical come in some different sizes, so there has to be discrete jumps as the content grows.
  • The i and the t have slightly different heights. This makes the superscript 2 on the sin sit a bit higher than that on the tan, which in turn sits slighly higher than the one of cos.
  • The effect curiously goes away when the + is removed. I first thought that might be because of the depth of the +, but surprisingly enough it remains if the plus is changed into a minus (that does not have a large depth!). I have no good explanation of that.
  • The result differs (in the tan part) depending on if amsmath is loaded or not. I do not know why.
  • One could argue (as barbara does in a comment to the other answer) that the square on the b should be at least as high as that on the sin, and this is where things start to get interesting. What happens here is that superscripts are done differently depending on if they sit on a character or on some construction. The code path is simply different. To overemphasize this, here are two big squared squares (haha!) squared squares The left square acts as a character, and that puts the 2 on a certain fixed height. The second does not act as a character, and so the 2 is located accordingly. The first model is for characters, the second for large parentheses and such things.

Accidentaly, I got to discuss this with Hans Hagen, and since we are discussing math a lot these days we got curious. It took us a while to get what exactly was the cause of the issue, but once we got it, the fix was pretty close thanks to the opening up of atom classes. We have a specific atom class for functions, and from today there is (in luametatex) a class option single that tells the atom to behave like a single glyph in this sense. So the two black squares above were set with

$\mathatom single class \mathordinarycode {\vrule height 1cm depth 0pt width 1cm}^2$ \quad
$\mathatom class \mathordinarycode {\vrule height 1cm depth 0pt width 1cm}^2$

At the same time, this new option single was also added to the specific construction where math functions are defined. This means that when we now type

$\frac{ \sqrt{ a^2 + 4b^2 \sin^2 \alpha} }{2}$\quad
$\frac{ \sqrt{ a^2 + 4b^2 \cos^2 \alpha} }{2}$\quad
$\frac{ \sqrt{ a^2 + 4b^2 \tan^2 \alpha} }{2}$

we get in ConTeXt (in the next release)

radical trigonometric formulas

2
  • 2
    In Computer Modern fonts, the minus has the same bounding box as the plus.
    – egreg
    Commented May 26, 2023 at 21:11
  • Ah, thanks, I did not know that. In Latin Modern (Open type) that seems not to be the case anymore. Do you by chance also know why the outcome of the tan formula depends on whether the amsmath packages is loaded or not?
    – mickep
    Commented May 27, 2023 at 5:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .