Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have two equations:

    \begin{equation}
    \begin{split} 
    d_1 & =\frac{aaaaaaaaaa}{b}\\
    d_2 & =\frac{aaaaaa}{b}
    \end{split} 
    \end{equation}

I want the fraction lines to have equal lengths in the two cases. How can I make it happen?

share|improve this question
add comment

1 Answer

up vote 12 down vote accepted

If I understand correctly your intent, you can use \phantoms:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\begin{split} 
    d_1 & =\frac{aaaaaaaaaa}{b}\\
    d_2 & =\frac{aaaaaa\phantom{aaaa}}{b} \\
    d_3 & =\frac{\phantom{aa}aaaaaa\phantom{aa}}{b}
\end{split} 
\end{equation}

\end{document}

enter image description here

Of course, you can measure the longest string, and then use this as the width of a box containing the other expression:

\documentclass{article}
\usepackage{amsmath}

\newlength\mylen

\begin{document}

\settowidth\mylen{$aaaaaaaaaa$}

\begin{equation}
\begin{split} 
    d_1 & =\frac{aaaaaaaaaa}{b}\\
    d_2 & =\frac{\makebox[\mylen][c]{$aaaaaa$}}{b} \\
\end{split} 
\end{equation}

\end{document}

enter image description here

As egreg comments, one can also use \mathmakebox from mathtools:

\documentclass{article}
\usepackage{mathtools}

\newlength\mylen

\begin{document}

\settowidth\mylen{$aaaaaaaaaa$}

\begin{equation}
\begin{split} 
    d_1 & =\frac{aaaaaaaaaa}{b} \\
    d_2 & =\frac{\mathmakebox[\mylen][c]{aaaaaa}}{b} \\
\end{split} 
\end{equation}

\end{document}
share|improve this answer
1  
Brilliant. thanks. –  Shb Aug 29 '13 at 1:36
1  
See also \mathmakebox from mathtools. –  egreg Aug 29 '13 at 9:35
    
@egreg thanks for the suggestion; I've incorporated it to my answer. –  Gonzalo Medina Aug 29 '13 at 13:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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