ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Multi-line labels in MetaPost
Date: Sat, 22 Aug 2009 15:30:15 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LNX.2.00.0908221526380.11397@ybpnyubfg.ybpnyqbznva> (raw)
In-Reply-To: <alpine.OSX.2.00.0908222302060.1508@MacBook-2.local>

On Sat, 22 Aug 2009, Michail Vidiassov wrote:

> Dear All,
>
>>> I have fixed this by using:
>>> 
>>> label.rt(textext("\framed[frame=off,align=right]{One\\Two}"),origin);
>>> 
>
> And what about proper tables there?
> Replacing One\\Two in the above code with
> $ \startmathmatrix \NC 1 \NC 1 \NR \NC 1 \NC  1 \NR \stopmathmatrix $

All metapost environments expand their arguments, so anything looking for 
an optional argument fails. There are workarounds, though

\unexpanded\def\MYMATRIX%
   {$\startmathmatrix \NC 1 \NC 1 \NR \NC 1 \NC  1 \NR \stopmathmatrix$}

\starttext
\startMPcode
   label.rt(\sometxt{\MYMATRIX},   origin) ;
   label.rt(textext ("\MYMATRIX"), (5cm,0)) ;
\stopMPcode
\stoptext

And if you really want it to work, we need to make cetrain things 
unexpandable

\unprotect
\def\dodefinemathmatrix[#1]% [#2]%
   {\unexpanded\setvalue{\e!start#1}{\dodoubleempty\dostartmathmatrix[#1]}%
    \unexpanded\setvalue{\e!stop #1}{\dostopmathmatrix}%
    \setupmathmatrix[#1]}% [#2]

\definemathmatrix[matrix]
\definemathmatrix[\v!mathmatrix]

\unexpanded\def\dodomatrixNC
   {\gdef\domatrixNC{\endmath&}}

% To avoid errors in expansion
\let\NC\relax
\let\NR\relax

\protect

Now this works

\starttext
\startMPcode
   label.rt(\sometxt{$\startmathmatrix \NC 1 \NC 1 \NR \NC 1 \NC  1 \NR 
\stopmathmatrix$},   origin) ;
\stopMPcode

\stoptext


Hans, should we add this to strc-ali?

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2009-08-22 19:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1061.1250104783.3069.ntg-context@ntg.nl>
2009-08-13  8:34 ` richard.stephens
2009-08-13 13:15   ` Aditya Mahajan
2009-08-22 19:07     ` Michail Vidiassov
2009-08-22 19:30       ` Aditya Mahajan [this message]
2009-08-22 20:09         ` Hans Hagen
     [not found] <mailman.1077.1250181719.3069.ntg-context@ntg.nl>
2009-08-14  8:54 ` richard.stephens
2009-08-14  9:37   ` Thomas A. Schmitz
2009-08-12 16:09 richard.stephens
2009-08-12 16:15 ` Wolfgang Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.0908221526380.11397@ybpnyubfg.ybpnyqbznva \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).