[NTG-context] embed metapost figure into document
Sylvain Hubert
champignoom at gmail.com
Tue Nov 10 01:23:52 CET 2020
On Mon, 9 Nov 2020 at 23:40, Jairo A. del Rio <jairoadelrio6 at gmail.com>
wrote:
> Hi, Sylvain.
>
> LuaMetaTeX and LuaTeX, the engines used by ConTeXt nowadays, use an
> embedded library, so external compilations/files are not necessary. Just
> out of curiosity, wouldn't it be easier to use a ConTeXt environment? E.g.:
>
> \starttext
> \startMPcode %\startuseMPgraphic{<name>} if you want to reuse your graphic
> with \useMPgraphic{<name>}
> draw fullcircle scaled cm
> %withcolor black % black is default
> ;
> \stopMPcode %\stopuseMPgraphic
> \stoptext
>
> More info here:
> https://wiki.contextgarden.net/MetaFun_-_MetaPost_in_ConTeXt
> To actually answer your question, if you actually want to load a Metapost
> graphic externally generated, you should have something like:
>
> %nice.mp
> %"begin ... endfig", as well as "end" are important
> beginfig (1);
> draw fullcircle scaled cm
> %withcolor black
> ;
> endfig;
> end
>
> so when you compile it via
>
> mpost nice.mp
>
> (obviously supposing you have Metapost installed) you'll get a file called
> nice.1 and
>
> \starttext
>
> \externalfigure[nice.1][width=4cm]
>
> \stoptext
>
> will work. However, as you can see, ConTeXt deals with such minutiae for
> you and extends Metapost capabilities too, so the second alternative is not
> the ConTeXt way to go.
>
> I hope it helps.
>
> Jairo :)
>
Hi Jairo,
Thank you very much for the suggestion and the thorough explanation.
I extracted the metapost code to a new file because I felt it would be a
bit lengthy and noisy to stay with the text content.
But you're right, an extra compilation step is not any better. I should
probably use \component figure.tex, in place of \externalfigure[figure.1]
Sylvain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20201110/56c9306a/attachment.htm>
More information about the ntg-context
mailing list