ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Sanjoy Mahajan <sanjoy@mrao.cam.ac.uk>
Subject: \textext can fail in definitions in \startMPinclusions
Date: Sun, 24 Sep 2006 23:26:16 -0400	[thread overview]
Message-ID: <E1GRh6m-0006CQ-1T@approximate.corpus.cam.ac.uk> (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

             reply	other threads:[~2006-09-25  3:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-25  3:26 Sanjoy Mahajan [this message]
2006-09-25 13:46 ` Hans Hagen

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=E1GRh6m-0006CQ-1T@approximate.corpus.cam.ac.uk \
    --to=sanjoy@mrao.cam.ac.uk \
    --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).