On 2/13/07, Aditya Mahajan wrote:
On Tue, 13 Feb 2007, Mojca Miklavec wrote:
Hello,
is there a nice way to [mis]use \startalign or combine it with something else to typeset equations like the following one (in a fixed-width font)?
fixed-width font?
I meant "fixed-width" font while reading the mail, not for typesetting ;)
Then you can just use \starttable with appropriate setting for distance. Even otherwise you can use starttable with |m| columns, but I understant math align better.
a + b = 9 a - b = 3 ___________ 2a = 12
\noalign is your friend. Here is the first approximation
\starttext
\startformula \startalign[n=5] \NC a \NC + \NC b \NC = \NC 9 \NR \NC a \NC - \NC b \NC = \NC 3 \NR \noalign{\hrule} \NC 2a \NC \NC \NC = \NC 12 \NR \stopalign \stopformula
\stoptext
Hmm... the width of the rule is too long, so lets use something with a fixed width
\starttext
\startformula \startmatrix[n=5] \NC a \NC + \NC b \NC = \NC 9 \NR \NC a \NC - \NC b \NC = \NC 3 \NR \noalign{\hrule} \NC 2a \NC \NC \NC = \NC 12 \NR \stopmatrix \stopformula
\stoptext
Hmm... distance and alignment are wrong, so lets correct that
\starttext
\startformula
\startmatrix[n=5,distance=.3em,align={right,middle,right,middle,right}] \NC a \NC + \NC b \NC = \NC 9 \NR \NC a \NC - \NC b \NC = \NC 3 \NR \noalign{\hrule} \NC 2a \NC \NC \NC = \NC 12 \NR \stopmatrix \stopformula
\stoptext
Voila! I did not know that ConTeXt math alignment macros could do something like this.
Aditya
Wow! That wasn't only a very nice solution, but also a very instructive one. I really need to read your article in Maps again. I've heard about \noalign, but didn't think about using it for a horizontal rule. I've heard about "matrix", but I didn't get the point: I though that \matrix{0&1\cr1&0}-like constructs and \startalign should satisfy my needs ;) Thanks a lot both for your answer and for "forcing Hans" to implement all the possible and impossible math features. I'm now trying to spot the most appropriate place in the wiki tu put that example there, but I really think that you should put it in one if your manuals as a really nice example. Mojca PS: I have another nice math challenge for you or Taco ;) (a hybrid of overline/overrightarrow/vec/"overrigharpoonup" for denoting vectors, but I'll use another thread)