3

This question already has an answer here:

Trying to get Schrodinger's equation to format better. The first term is

-\dfrac{\hslash^2}{2m} \, \dfrac{\mathrm{d}^2 \psi}{\mathrm{d} x^2}

However, because of the exponent in the denominator, the second fraction prints lower than the first one, and looks unbalanced. Is there a way to drop the baseline for the exponent of the first fraction so they line up? Also, this is in beamer, if that adds other complexity to the issue

marked as duplicate by Werner, Gonzalo Medina, Peter Jansson, egreg, cmhughes Feb 9 '14 at 19:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Regarding physics: Keep in mind, that the spacial derivative is only a partial derivative, hence use \partial instead of \mathrm{d}. – Henri Menke Feb 9 '14 at 18:50
  • Yes, but we're just working in one dimension, so \mathrm{d} is proper. – Martin Feb 9 '14 at 20:09
2

\vphantom can be used in the denominator of the first fraction to line to increase the height to the height of the second denominator.

Because we have fractions with superscripts, it becomes a little more complicate, because TeX changes into the "cramped" math style, where the superscripts are less raised. Therefore the example calculates the height in macro \crampedvphantom. The macro uses \overline to force TeX to change the math style into its cramped math style for the expression in the argument.

In the example I have increased the height of the second denominator a little to make the effect more visible:

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{amssymb}

\makeatletter
\newcommand*{\crampedvphantom}[1]{%
  \mathpalette\cramped@vphantom{#1}%
}
\newcommand*{\cramped@vphantom}[2]{%
  \sbox0{$#1\overline{}$}%
  \sbox2{$#1\overline{#2}\m@th$}%
  \dimen0=\ht2 %
  \advance\dimen0 by -\ht0 %
  \ht2=\dimen0
  \hbox{\vrule width0pt height\dimen0 depth\dp0}%
}

\begin{document}
\[
  -\dfrac{\hslash^2}{2m \crampedvphantom{\partial x^{2^{1^1}}}}
   \, \dfrac{\partial^2 \psi}{\partial x^{2^{1^1}}}
\]
\end{document}

Result

  • Perhaps the OP meant \mathrm{d}^2 instead of \mathrm(d)^2? – Gonzalo Medina Feb 9 '14 at 18:34
  • @GonzaloMedina: Yes, this makes sense. The example also now uses \partial (see Henri Menke's comment/answer) and takes into account the "cramped" math style. – Heiko Oberdiek Feb 9 '14 at 19:05
  • I agree. The \vphantom solves it nicely, even works in beamer, and can adjust for super or subscripts. I used the simple differential \mathrm{d} because we're at the beginning of the course, still working the basic examples in 1 dimension. – Martin Feb 9 '14 at 20:06
  • Yes, of course, \mathrm{d}. Edited in OP, thanks. – Martin Feb 9 '14 at 20:13

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