ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* ## in \def in \sometxt fails with static MP figure
@ 2006-09-30 19:17 Sanjoy Mahajan
  0 siblings, 0 replies; only message in thread
From: Sanjoy Mahajan @ 2006-09-30 19:17 UTC (permalink / raw)


Now that \sometxt works with static figures (thanks!), I'm converting
from using btex..etex to using \sometxt, to avoid MPenvironments
(instead put it in the general .tex environment).

But I ran into an error with macro arguments and static figures.  Let me
know if it's not worth fixing in view of the Mk IV cleanup, and I'll
switch to reusable figures (and eventually Linux will support dual core
CPUs + suspend to ram, and then I won't notice the processing time
much).

Here is a small example file:

================= y.tex ========================
\def\2#1#2{\vbox{\halign{##\hfil\cr#1\cr#2\cr}}}
\starttext

\startstaticMPfigure{fig}
label(\sometxt{\2{h}{x}}, origin);
\stopstaticMPfigure

\usestaticMPfigure[fig]
\stoptext
================= y.tex ========================

It produces this texexec.tex (2006.09.28 22:43 beta):

================ texexec.tex =====================
\setupoutput[pdftex]
\setupcolors[state=start]
\global \loadfontfileoncetrue \starttext
\startMPpage


beginfig(1);

label(\sometxt{\vbox {\halign {##\hfil \cr h\cr x\cr }}}, origin);

endfig; \stopMPpage
\stoptext
================ texexec.tex =====================

The ## in the expanded argument to \sometxt causes a problem:

=================== texexec.log ==============
! Only one # is allowed per tab.
l.1 \vbox {\halign {##
                      \hfil \cr h\cr x\cr }}
\doTeXtext ... \startcurrentcolor \scantokens {#3}
                                                  \stopcurrentcolor }\global...

\dodofiltersometxt ...er \TeXtext \txtcounter {#1}
                                                  \expandafter \filtersometx...
<argument> ...halign {##\hfil \cr h\cr x\cr }}}, o
                                                  rigin);

endfig; 
\flushTeXtexts ...llectedmptexts \filtersometxt #1
                                                  \sometxt {}\empty \relax \...

\writecheckedMPgraphic ...phic \flushTeXtexts {#1}
                                                  \writeMPgraphic {#1}
...
l.9 endfig; \stopMPpage
                       
? 
=================== texexec.log ==============

Alas using

\def\2#1#2{\vbox{\halign{#\hfil\cr#1\cr#2\cr}}}

leads to a different error (illegal parameter number).

But using a reusable graphic works:

==================== yy.tex =====================
\def\2#1#2{\vbox{\halign{##\hfil\cr#1\cr#2\cr}}}
\starttext

\startreusableMPgraphic{fig}
label(\sometxt{\2{h}{x}}, origin);
\stopreusableMPgraphic

\reuseMPgraphic{fig}
\stoptext
==================== yy.tex =====================


-Sanjoy

`A society of sheep must in time beget a government of wolves.'
   -- Bertrand de Jouvenal

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-09-30 19:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-30 19:17 ## in \def in \sometxt fails with static MP figure Sanjoy Mahajan

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