Math & Scienceequations with right-justified reasons

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
matloff
Posts: 1
Joined: Sat Dec 11, 2010 11:15 pm

equations with right-justified reasons

Post by matloff »

I'd like to display equations using eqnarray, with reasons shown on the far right. It's straightforward to put in reasons, but I don't see how to right justify them. Is there a way to do this?

Norm Matloff

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

equations with right-justified reasons

Post by gmedina »

Hi,

it's preferable not to use eqnarray anymore (read Avoid eqnarray! by Lars Madsen). You could use an align (or an align*) environment:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
  a (b + c) &= ab + ac  && \text{(by distributivity)} \\
  &= ba + ca && \text{(by commutativity)} \notag\\
  &= (b + c)a. && \text{(by distributivity)} \notag
\end{align*}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: equations with right-justified reasons

Post by frabjous »

Unfortunately, those aren't right aligned, gmedina.
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

equations with right-justified reasons

Post by CrazyHorse »

matloff wrote:I'd like to display equations using eqnarray, with reasons shown on the far right. It's straightforward to put in reasons, but I don't see how to right justify them. Is there a way to do this?

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\parindent=0pt

\begin{document}

\rule{\textwidth}{1pt}

\begin{align*}
  a (b + c) &= ab + ac  \tag*{(by distributivity)} \\
  &= ba + ca            \tag*{(by commutativity)} \\
  &= (b + c)a.          \tag*{(by distributivity)}
\end{align*}

\end{document}
Herbert
Post Reply