[NTG-context] Align with comments
Aditya Mahajan
adityam at umich.edu
Thu May 4 08:44:32 CEST 2006
Hi David,
On Wed, 3 May 2006, David Arnold wrote:
> I think a while back you provided an align example with comments, such as:
>
> 2x+3=5 Add -3 to both sides
> 2x+3-3=5-3 Simplify
> 2x=2 Divide both sides by 2
>
> Etc.
>
> Could you provide another sample of this for us?
Assuming that you want to align at the = in the equations, you can use
the following
\startformula \startalign[m=2,distance=4em]
\NC 2x + 3 \NC = 5 \NC\NC \text{Add -3 to both sides} \NR
\NC 2x + 3 - 3 \NC = 5 - 3 \NC\NC \text{Simplify} \NR
\NC 2x \NC = 2 \NC\NC \text{Divide both sides by 2} \NR
\stopalign \stopformula
If you use this kind of thing frequently, you can add some
syntax sugar.
\definemathalignment
[aligncomments]
[m=2,distance=4em]
\def\Comment#1\NR{\NC\NC\text{#1}\NR}
\startformula \startaligncomments
\NC 2x + 3 \NC = 5 \Comment Add -3 to both sides \NR
\NC 2x + 3 - 3 \NC = 5 - 3 \Comment Simplify \NR
\NC 2x \NC = 2 \Comment Divide both sides by 2 \NR
\stopaligncomments \stopformula
If you simply want to left align the equations, you can use
\definemathalignment
[aligncomments]
[n=1,align={left},m=2,distance=4em]
\def\Comment#1\NR{\NC\text{#1}\NR}
\startformula \startaligncomments
\NC 2x + 3 = 5 \Comment Add -3 to both sides \NR
\NC 2x + 3 - 3 = 5 - 3 \Comment Simplify \NR
\NC 2x = 2 \Comment Divide both sides by 2 \NR
\stopaligncomments \stopformula
Aditya
--
Aditya Mahajan, EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam || Ph: 7342624008
More information about the ntg-context
mailing list