ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Alan Braslau <braslau.list@comcast.net>
To: Gerhard Kugler <G.W.Kugler@posteo.de>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Circled text in metapost
Date: Fri, 30 Mar 2018 08:44:23 -0600	[thread overview]
Message-ID: <20180330084423.13478889@poo.hsd1.co.comcast.net> (raw)
In-Reply-To: <20180330113130.GJ1800@pi-top>

Hello,

luatex includes the MetaPost library MPlib, so MetaPost code is called
and then injected into the output stream. As a user, it is useful to
know that MP is in fact called in two passes, thus twice, and this can
have some unexpected consequences when not programmed cleanly. Global
variable storage, for example, can reflect the multiple passes. Take
the following (silly) example:

\starttext

\startMPcode
if unknown n : n := 0 ; fi
n := n + 1 ;
draw textext(decimal n) ;
\stopMPcode

\startMPcode
n := n + 1 ;
draw textext(decimal n) ;
\stopMPcode

\stoptext

yielding:
1
3

(perhaps Hans or Taco can explain why one does not get 2 4)


This side effect is somewhat handled by the fact that each call to MP
is treated as a group : begingroup  ... endgroup so

\startMPcode
save n ; n := 0 ;
...
\stopMPcode

works as expected, but n is then local and becomes unknown (or keeps
its global value) for subsequent calls to MP.

What should be understood is that calls to MP returns a bounding box to
TeX, and space is reserved for this bounding box. Likewise, calls
within MP to TeX, for example textext() or label(), or btex ... etex
returns a bounding box to MP, and this (picture) object is placed in
the graphic. Mechanisms exist allowing the passing of values of
variables via lua (as strings, in fact). This is a more advanced
subject.


Now, there are a number of ways of calling MP from TeX, directly as
above, but also as unique MP graphics or as reusable MP graphics, ...
This is another subject all together.

Hopefully this helps some.

Alan



On Fri, 30 Mar 2018 13:31:30 +0200
Gerhard Kugler <G.W.Kugler@posteo.de> wrote:

> Hello,
> 
> my problem is that in other programming langguages there is a main
> procedure which calls others. In metapost in the context of ConteXt I
> can use \starttext ... \stoptext or \startMPpage ... \stopMPpage or
> \beginfig ... \endfig
> 
> And it seems not to be transparent how procedures are called.
> 
> Gerhard
> 
> 

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2018-03-30 14:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29  9:28 Gerhard Kugler
2018-03-29  9:52 ` Henri Menke
2018-03-29 10:17   ` Hans Hagen
2018-03-29 10:43     ` Gerhard Kugler
2018-03-29 13:11       ` Alan Braslau
2018-03-29 16:05         ` Gerhard Kugler
2018-03-30 11:31           ` Gerhard Kugler
2018-03-30 14:44             ` Alan Braslau [this message]
2018-03-30 15:51               ` Gerhard Kugler
2018-03-30 23:22           ` Henri Menke
2018-03-30 23:25             ` Henri Menke
2018-03-31 17:22               ` Gerhard Kugler
2018-04-02 13:16                 ` Hans Hagen
2018-04-02 14:51                   ` Alan Braslau
2018-04-02 15:52                   ` Gerhard Kugler
2018-04-02 16:08                     ` Hans Hagen
2018-04-02 16:34                       ` Gerhard Kugler
2018-04-02 17:21                         ` Gerhard Kugler
2018-04-02 17:30                           ` Alan Braslau
2018-04-02 17:48                             ` Gerhard Kugler
2018-04-05  5:32                               ` Gerhard Kugler

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=20180330084423.13478889@poo.hsd1.co.comcast.net \
    --to=braslau.list@comcast.net \
    --cc=G.W.Kugler@posteo.de \
    --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).