From: "Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: passing dimensions to metapost
Date: Thu, 28 Aug 2008 15:02:03 +0200 [thread overview]
Message-ID: <6A9F5376-35B7-47EE-8D00-E6EB4D92B6A4@uni-bonn.de> (raw)
In-Reply-To: <48B65781.7000408@wxs.nl>
On Aug 28, 2008, at 9:45 AM, Hans Hagen wrote:
Hans, thanks a lot for your reply. Amazing - the lua code is so simple
that even I can understand it! I'm certain to use it later; for the
time being, I want to remain compatible for mkii and XeTeX as well.
> \startluacode
> document.mymodule = document.mymodule or { }
>
> function document.mymodule.checkdimen(str)
> return (str:find("%a%a$") and str) or (str .. "mm")
> end
> \stopluacode
>
> \ctxlua{document.mymodule.checkdimen("#1")}
>
> or more fancy:
>
> function document.mymodule.checkdimen(str)
> if not str:find("%a%a$") then
> str = str .. "mm"
> ctx.writestatus("mymodule","you forgot a dimension unit, so I
> made it up for you: %s",str)
> end
> return str
> end
>
> for mkii you can use \doifdimensionelse (it reminds me to implement
> that
> in mkiv)
Hey, I WAS using \doifdimensionelse and \doifnumberelse! :-) And it
appears to be working in mkiv as well! I found out the error in my
code (it was too complex, and I was overwriting a variable with the
same name; it looks like Metapost assigns "sp" as default unit to
\MPvar). Problem solved, but it took me half a day...
All best
Thomas
___________________________________________________________________________________
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://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2008-08-28 13:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-27 22:07 Thomas A. Schmitz
2008-08-28 7:45 ` Hans Hagen
2008-08-28 13:02 ` Thomas A. Schmitz [this message]
2008-08-28 13:34 ` "Padding" in natural tables B. Tommy Jensen
2008-08-28 15:04 ` B. Tommy Jensen
2008-08-28 15:47 ` Thomas A. Schmitz
2008-08-29 15: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=6A9F5376-35B7-47EE-8D00-E6EB4D92B6A4@uni-bonn.de \
--to=thomas.schmitz@uni-bonn.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).