12

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!

10

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.

  • \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 – user2478 Jul 14 '11 at 6:56
0
\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}

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.