20

Consider the following code:

\begin{align}
f_1(x) &= \frac{15x}{3} \\
f_2(x) &= 3x + 5 \\
f_3(x) &= 4x + 13
\end{align}

This produces three lines where the first line takes up more vertical space than the others. Is there any way to make all the lines take the same vertical space (meaning effectively all lines take as much vertical space as the largest one)?

David Carlisle
  • 757,742

3 Answers3

16

if you do not want it globally changed put the complete formula into {...}

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\savebox\strutbox{$\vphantom{\dfrac11}$}
\begin{align}
  f_1(x) &= \frac{15x}{3} \\
  f_2(x) &= 3x + 5 \\
  f_3(x) &= 4x + 13
\end{align}

\end{document}
  • Despite the additional white space below the display, this is definitely most elegant. – Hendrik Vogt Jan 17 '11 at 14:28
  • Beautiful! How exactly does it work? – mavzolej Nov 20 '18 at 17:33
  • \vphantom{...} defines box of width zero and height nof its contents. Which is the height of a fraction "1/1". \strutbox is used by align for every row. –  Nov 20 '18 at 18:38
  • This is very useful, thank you. Would this only affect the following align environment? Or all the way down to the end of the document? – Daneel Olivaw Oct 05 '20 at 10:39
  • 1
    @DaneelOlivaw it's a normal tex local assignment so has the same scope as a font change or \renewcommand etc, the current group or environment (which is document here, but could be any local scope from {} or minipage etc. – David Carlisle Oct 10 '20 at 12:51
15

I don't know of an automatic way to do this, but in a particular case, you can use \vphantom to effect this.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
f_1(x) &= \frac{15x}{3} \\
f_2(x) &= \vphantom{\frac11}3x + 5 \\
f_3(x) &= \vphantom{\frac11}4x + 13
\end{align}
\end{document}

alt text

TH.
  • 62,639
5

I can offer a variant of TH's answer that produces a bit less vertical space, but it is adjusted to your particular situation: Only the second line needs a bit of additional depth. The advantage of this more special adjustment is that it doesn't produce additional white space below the display.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Here's some text just to fill the line sufficiently
\begin{align}
f_1(x) &= \frac{15x}{3} \\
f_2(x) &= 3x + 5 \vphantom{\smash[t]{\frac11}} \\
f_3(x) &= 4x + 13
\end{align}
Here's some text just to fill the line sufficiently
\end{document}

Hendrik Vogt
  • 37,935