ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \startalign and "underline"
@ 2007-02-13 12:54 Mojca Miklavec
  2007-02-13 16:20 ` Aditya Mahajan
  0 siblings, 1 reply; 3+ messages in thread
From: Mojca Miklavec @ 2007-02-13 12:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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)?

   a + b =  9
   a - b =  3
  ___________
  2a     = 12

Thanks for any hints,
    Mojca

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: \startalign and "underline"
  2007-02-13 12:54 \startalign and "underline" Mojca Miklavec
@ 2007-02-13 16:20 ` Aditya Mahajan
  2007-02-13 16:53   ` Mojca Miklavec
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan @ 2007-02-13 16:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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? 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: \startalign and "underline"
  2007-02-13 16:20 ` Aditya Mahajan
@ 2007-02-13 16:53   ` Mojca Miklavec
  0 siblings, 0 replies; 3+ messages in thread
From: Mojca Miklavec @ 2007-02-13 16:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-13 16:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-13 12:54 \startalign and "underline" Mojca Miklavec
2007-02-13 16:20 ` Aditya Mahajan
2007-02-13 16:53   ` Mojca Miklavec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).