ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \textext can fail in definitions in \startMPinclusions
@ 2006-09-25  3:26 Sanjoy Mahajan
  2006-09-25 13:46 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Sanjoy Mahajan @ 2006-09-25  3:26 UTC (permalink / raw)


Another test file for metafun.  I know that textext doesn't work in
loops.  I don't understand how it's implemented enough to know why, but
is the reason for its not working in loops the same as the reason it
doesn't work in included definitions (related to static analysis of the
code)?

The following file gives an example of what I mean.  It gives a page
saying "unknown", but if one uses draw \textext{directly} directly (the
commented-out line) then it works as expected.  I see the same behavior
with \sometxt{}.  [All with context 2006.08.08]

====================  cut here ====================
\starttext
\startMPinclusions
def yy = 
  draw \textext{via yy def}
enddef;
\stopMPinclusions

\startMPcode
  % draw \textext{directly};  % would give "via yy def" as the text
  yy;                         % gives "unknown" as the text on the page
\stopMPcode
\stoptext
====================  cut here ====================

Oh maybe here's the problem.  The log file says (1.tex is the test
file):

  system(mpost  -progname=metafun -mem=metafun 1-mpgraph)...executed.

Doing that by hand to get PDF gives a figure containing "unknown":

$ mpost  -progname=metafun -mem=metafun 1-mpgraph
$ mptopdf 1-mpgraph.1

But "texexec --mpgraphic 1.mp" produces the right figure.  So why does
\startMPcode run the wrong command?  The following works fine:

==================== cut here ====================
\starttext
\startMPinclusions
def yy = 
  draw \textext{via yy def};
enddef;
\stopMPinclusions

\startstaticMPfigure{a}
  yy;
\stopstaticMPfigure

\usestaticMPfigure[a]
\stoptext
==================== cut here ====================

The log shows startstaticMPfigure running texexec:

system(texmfstart --ifchanged=1a-a.mp texexec --mpgraphic 1a-a.mp)...executed.

Oh I think I know why mpost is being called with \startMPcode: It gets
fooled by the label hidden inside the def, so it thinks that there is no
need to run the more complicated texexec comment.  I tried two
hacks^H^H^H^Htests to check this:

1. Added \forceMPTEXgraphictrue right after \starttext, and then the
   figure came out fine.  Not sure whether this method will work if
   there is more than one figure (\ifforceMPTEXgraphic might get reset
   to false after each figure).

2. Added an explicit \textext{} in the figure:

    \startMPcode
      label(\textext{jj},(1in,1in));
      yy;
    \stopMPcode

  and the yy produces the right text.

Though I still don't know why the staticMPfigure doesn't need either
hack.

-Sanjoy

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

* Re: \textext can fail in definitions in \startMPinclusions
  2006-09-25  3:26 \textext can fail in definitions in \startMPinclusions Sanjoy Mahajan
@ 2006-09-25 13:46 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2006-09-25 13:46 UTC (permalink / raw)


Sanjoy Mahajan wrote:
> Another test file for metafun.  I know that textext doesn't work in
> loops.  I don't understand how it's implemented enough to know why, but
> is the reason for its not working in loops the same as the reason it
> doesn't work in included definitions (related to static analysis of the
> code)?
>
> The following file gives an example of what I mean.  It gives a page
> saying "unknown", but if one uses draw \textext{directly} directly (the
> commented-out line) then it works as expected.  I see the same behavior
> with \sometxt{}.  [All with context 2006.08.08]
>
> ====================  cut here ====================
> \starttext
> \startMPinclusions
> def yy = 
>   draw \textext{via yy def}
> enddef;
> \stopMPinclusions
>
> \startMPcode
>   % draw \textext{directly};  % would give "via yy def" as the text
>   yy;                         % gives "unknown" as the text on the page
> \stopMPcode
> \stoptext
> ====================  cut here ====================
>
> Oh maybe here's the problem.  The log file says (1.tex is the test
> file):
>
>   system(mpost  -progname=metafun -mem=metafun 1-mpgraph)...executed.
>
> Doing that by hand to get PDF gives a figure containing "unknown":
>
> $ mpost  -progname=metafun -mem=metafun 1-mpgraph
> $ mptopdf 1-mpgraph.1
>
> But "texexec --mpgraphic 1.mp" produces the right figure.  So why does
> \startMPcode run the wrong command?  The following works fine:
>
> ==================== cut here ====================
> \starttext
> \startMPinclusions
> def yy = 
>   draw \textext{via yy def};
> enddef;
> \stopMPinclusions
>   
\forceMPTEXgraphictrue

inclusions are not parsed for MPTEX content
> \startstaticMPfigure{a}
>   yy;
> \stopstaticMPfigure
>
> \usestaticMPfigure[a]
> \stoptext
> ==================== cut here ====================
>   
-----------------------------------------------------------------
                                          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
-----------------------------------------------------------------

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

end of thread, other threads:[~2006-09-25 13:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-25  3:26 \textext can fail in definitions in \startMPinclusions Sanjoy Mahajan
2006-09-25 13:46 ` Hans Hagen

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