6

I'm a student teaching myself to use LaTeX (and related tools) to type up my homework. It's going great, and I'm already very happy with what I've been able to do so far. Though, I have questions.

I'm trying to type up a proof with steps in one column and explanations in a second column, separated by a nice vertical bar. A two column table has gotten me most of the way there:

\documentclass[a4paper,12pt]{article}
\usepackage{amsthm}
\begin{document}
We want to show that -2 = 2.
\begin{proof}
\begin{tabular}{r|l}
$-2 = 2$ & assuming the conclusion \\
$(-2)^2 = 2^2$ & square both sides \\
$4$ = $4$ & as desired
\end{tabular}

\end{proof}
\end{document}

However, the equals signs in the left column don't line up. Ideally, I'd like to be able to line them up as I would in an align environment or similar. Can this be done?

Moreover, I don't really like having to repeat the $ on every row of the left column. Is there a way to automate that?

Thanks in advance for any answers, this is my first question here too, so please let me know if I've accidentally violated any mores of this community.

3 Answers 3

7

Do it simpler.

\documentclass[12pt,a4paper]{article}
\usepackage{mathtools}   % loads »amsmath«
\usepackage{amsthm}

\begin{document}
  We want to show that $-2=2$.
  \begin{proof}
    \begin{align*}
      -2 &= 2 && \smash{\Big|}\text{ assuming the conclusion} \\
      (-2)^2 &= 2^2 && \smash{\Big|}\text{ square both sides} \\
      4 &= 4 && \smash{\Big|}\text{ as desired}
    \end{align*}
  \end{proof}
\end{document}
3
  • This is simpler, but it doesn't have a vertical bar between the steps and the explanations like my example had. Can such a vertical line be added?
    – Harold
    Jan 22, 2011 at 23:43
  • See my edits above. Jan 23, 2011 at 11:31
  • Smashing! (no pun intended :)
    – Harold
    Jan 23, 2011 at 16:01
4
\documentclass[a4paper,12pt]{article}
\usepackage{amsthm,amsmath}
\begin{document}
We want to show that $-2 = 2$.

\begin{proof}
$\arraycolsep=1.5pt
\begin{array}[t]{rl|l}
-2     &= 2   & \text{ assuming the conclusion}\\
(-2)^2 &= 2^2 & \text{ square both sides} \\
4      &= 4   & \text{ as desired}
\end{array}$
\end{proof}

\end{document}
1
  • Very nice. I learned a lot from this. Thank you.
    – Harold
    Jan 23, 2011 at 0:00
2
  • You could use further columns to align also the equal signs. For example, you could use a r column followed by a c column for the relation sign which is followed by a l column.

  • The array package allows to insert commands into the table column definition. For example, to get a right aligned math column, use >{$}r<{$}.

  • If all formulas are equations, you could eben specify the equal sign as the column separator: \begin{tabular}{>{$}r<{$}@{\,=\,}>{$}l<{$}|l}.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .