On Thu, 13 Aug 2009, richard.stephens@converteam.com wrote:
Hello,
Is it possible to generate multi-line labels in MetaPost? I have naively tried the following hoping to get a line feed between the two words, but it doesn't work!
label.rt( btex One \crlf Two etex, (0,0));
\defineframed[mplabel][frame=off,align=right,width=fit]
label.rt(textext("\mplabel{One\\Two}"),origin) ;
Wolfgang
Thank-you for a very elegant solution, Wolfgang, unfortunately I get an error:
! Argument of \dododefinecolor has an extra }.
I have fixed this by using:
label.rt(textext("\framed[frame=off,align=right]{One\\Two}"),origin);
which works okay. It's not as elegant but as the code is generated automatically it does not require any more typing on my part!
Section 4.2 of Mojca's MyWay on sometxt http://dl.contextgarden.net/myway/sometxt.pdf provides another solution. Aditya
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 $ or \starttable{|cm|cm|} \NC 1 \NC 1 \NC \NR \NC 1 \NC 1 \NC \NR \stoptable does not work for me. It complains about "dotripletestemptyx", but that seems to be some low level utility code and the error messages say nothing to me :( ConTeXt ver: 2009.08.14 10:48 MKIV Sincerely, Michail
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
Aditya Mahajan wrote:
Hans, should we add this to strc-ali?
sure, i'll also do the same with getbuffer, as often using buffere is convenient in such cases: \unexpanded\def\getbuffer {\dodoubleempty\dogetbuffer} \starttext \startbuffer[a] $\startmathmatrix \NC 1 \NC 1 \NR \NC 1 \NC 1 \NR \stopmathmatrix$ \stopbuffer \startMPcode label.rt("\getbuffer[a]",origin) ; \stopMPcode \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (4)
-
Aditya Mahajan
-
Hans Hagen
-
Michail Vidiassov
-
richard.stephens@converteam.com