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 an equation that I'm trying to display with horizontal line separation. The result I'm looking for is similar to this question, but I'm not sure how to apply it to my equation (below).

\begin{equation*}
\begin{aligned}
x + 3& = &7\\
-3 & = &-3\\
x& = &4\\
\end{aligned}
\end{equation*}

Thanks!

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

It's quite easy, actually: aligned is a special form of array, so \hline works. But I suggest to load the package booktabs:

\usepackage{booktabs}

...

\begin{equation*}
\begin{aligned}
x + 3& = 7\\
\midrule
-3 & = -3\\
\midrule
x& = 4\\
\end{aligned}
\end{equation*}

\midrule produce better spacing than \hline.

aligned (like align) requires a & before the alignment point (usually a relation), but not after it.

As Herbert points out, the vertical spacing may be not optimal. In case this is a real problem, one can resort to array (this requires the array package):

\begin{equation*}
\setlength{\arraycolsep}{0pt}
\begin{array}{r>{{}}l}
x + 3& =  7 \\
\midrule
-3   & = -3 \\
\midrule
x    & = 4
\end{array}
\end{equation*}

The intercolumn space is reduced to zero and before the relation symbol we put an empty group, so that TeX finds {}=7 in the cell, that produces the correct horizontal spacing.

share|improve this answer
    
\midrule works great. Wondering if there is something that works as well in an align environment? –  Peter Grill Jul 14 '11 at 1:16
    
works with \cline or \cmidrule but has problems with vertical spacing –  Herbert Jul 14 '11 at 6:56
    
This works great - thanks! –  Shane Fulmer Jul 14 '11 at 13:33
add comment
\documentclass{article}
\usepackage{booktabs}
\begin{document}

\[\renewcommand\arraystretch{1.4}
  \arraycolsep=1.4pt
\begin{array}{rl}\toprule[1pt]
x + 3& = 7     \\\midrule
-3 & = -3      \\\midrule
x& = 4         \\\bottomrule[1pt]
\end{array}
\]
\end{document}
share|improve this answer
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.