19

This is a random, silly question. I was writing two versions of my calc 1 final and came across something that is going to bug the crap out of me. I have noticed a different spacing format for one fraction verses another. Anyway, does anyone know why this spacing looks different?

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
    \frac{d}{dx}\big[\tan x\big] &= \frac{d}{dx}\left[\frac{\sin x}{\cos x}\right]\\
    \frac{d}{dx}\big[\cot x\big] &= \frac{d}{dx}\left[\frac{\cos x}{\sin x}\right]
\end{align*}
\end{document}

The top one formats the brackets perfectly, while the second looks off... But yeah, it's just driving me nuts!

0
16

It is because you have i in sin and its height is different than that of cos. If you interchange sin and cos, every thing is normal. To avoid this, you may add \vphantom{i} in the numerator or, better, use \biggl and \biggr pair instead of \left and \right. For more details on these \big family of delimiters, please refer to amsmath documentation (texdoc amsldoc from command prompt), pages 15 and 16.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
    \frac{d}{dx}\big[\tan x\big] &= \frac{d}{dx}\left[\frac{\sin x}{\cos x}\right]\\
    \frac{d}{dx}\big[\cot x\big] &= \frac{d}{dx}\left[\frac{\cos x}{\sin x}\right]
\end{align*}
\begin{align*}
    \frac{d}{dx}\big[\tan x\big] &= \frac{d}{dx}\left[\frac{\sin x}{\cos x}\right]\\
    \frac{d}{dx}\big[\cot x\big] &= \frac{d}{dx}\left[\frac{\cos x \vphantom{i}}{\sin x}\right]
\end{align*}
\begin{align*}
    \frac{d}{dx}\big[\tan x\big] &= \frac{d}{dx}\biggl[\frac{\sin x}{\cos x}\biggr]\\
    \frac{d}{dx}\big[\cot x\big] &= \frac{d}{dx}\biggl[\frac{\cos x}{\sin x}\biggr]
\end{align*}
\end{document}

enter image description here

2
  • 1
    I would also like to mention that using \mathstrut rather than \vphantom{i} is (possibly) an even more general solution, but it depends on personal taste what exact spacing is preferrable. – 1010011010 May 2 '15 at 8:00
  • 1
    Please, teach the OP about the usage of \bigl and \bigr instead of \big – egreg May 2 '15 at 11:18
16

This is a problem that shows up also in different situations. Consider

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[
\sqrt{\sin x}\sqrt{\cos x}
\]
\end{document}

gives

enter image description here

which is horrible.

If we correct the definitions performed in amsopn.sty in the following way,

\documentclass{article}
\usepackage{amsmath}

\protected\def\arccos{\qopname\relax o{\vphantom{i}arccos}}
\protected\def\cos{\qopname\relax o{\vphantom{i}cos}}

\begin{document}
\[
\sqrt{\sin x}\sqrt{\cos x}
\]
\end{document}

we get

enter image description here

I see no point in doing just local assignments, as the majority of operators have ascenders. Possibly also \max and the other few operators that don't have ascenders should be redefined in the same way.

In your case, we have

\documentclass{article}
\usepackage{amsmath}

\protected\def\arccos{\qopname\relax o{\vphantom{i}arccos}}
\protected\def\cos{\qopname\relax o{\vphantom{i}cos}}

\begin{document}
\begin{align*}
\frac{d}{dx}\bigl[\tan x\bigr] &= \frac{d}{dx}\left[\frac{\sin x}{\cos x}\right]\\
\frac{d}{dx}\bigl[\cot x\bigr] &= \frac{d}{dx}\left[\frac{\cos x}{\sin x}\right]
\end{align*}
\end{document}

enter image description here

Note that \bigl and \bigr should be used, not the simple \big, so the delimiters are assigned the correct Opening and Closing type.

1
  • No doubt, you are a better teacher of TeX than me :-) – user11232 May 3 '15 at 1:27

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.