lualatex / luamplib

generic TeX package - including MetaPost code in LuaTeX documents
http://ctan.org/pkg/luamplib
16 stars 11 forks source link

An equivalent of the \startMPinclusions…\stopMPinclusions in luamplib? #15

Closed franckpastor closed 10 years ago

franckpastor commented 10 years ago

Hello,

Since the recent progresses in luamplib (inclusion of btex…etex, the textext macro, etc, cheers again for that!), i have begun to use it regularly. However, there are some things I still miss in this package, and the most important (in my opinion) is an equivalent of the \startMPinclusions … \stopMPinclusions of ConTeXt, or the "everymp" key of the gmp package of LaTeX, which would take care of the code shared in common by each picture in a TeX file.

For example, if I must use the "mpcolornames" package of Stephan Henning and/or the "boxes" packages for each drawing, or if these drawings use the same parameter(s), I must include them explicitly in each mplibcode environment:

\begin{mplibcode} input mpcolornames; input boxes; labeloffset:=6bp; .... \end{mplibcode}

and so on, and it becomes tedious if my LaTeX file contains numerous MetaPost pictures. In ConTeXt, we only have to put these common instructions into the \startMPinclusions … \stopMPinclusions environment, and they are automatically included in each MetaPost drawing. With the "gmp" LaTeX package of Enrico Gregorio, there is the "everymp" key which we can use for that.

So, my question: is something like the \startMPinclusions … \stopMPinclusions foreseen in the development of luamplib?

dohyunkim commented 10 years ago

Just committed new version of luamplib:

-- new macros \everymplib and \everyendmplib. I hope this feature being close to what you expected: \everymplib{ input mpcolornames; input boxes; }

-- allow naked TeX commands (including new macro \mpdim) inside mplibcode environment. I was quite impressed by gmp package you have informed to us. By this feature, however, luamplib has become somewhat error-prone. Anyway, now we can write codes like this: numeric u; u := \mpdim{\linewidth};

franckpastor commented 10 years ago

\everymplib is exactly what I expected. :-)

What's more, combined with \everyendmplib,it allows us to get rid of the beginfig()…endfig environments, which we previously had to place in each mplibcode. I found that tedious, compared with ConTeXt's \startMPcode…\stopMPcode or gmp's mpost(*) environment, which introduce them automatically. Thanks (twice thus)!

I will try your new features as soon as possible (the new version of luamplib hasn't shown up on CTAN yet). Personally, I don't often use the nice features of the gmp package related to naked TeX commands. That is to say, when I use gmp I write much more mpost* environments than mpost ones. But I will see how my few examples fare with luamplib.

If you think that the allowance of naked TeX commands makes luamplib more prone for bugs, maybe you should contact Enrico Gregorio directly for suggestions? He is one of the most prominent TeX-MetaPost specialist I know of. And he would be surely pleased with your appreciation of gmp :-)

Again, congratulations for your great work!

Franck Pastor