lualatex / luamplib

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

Argument of show command… doesn't show up #43

Closed franckpastor closed 10 years ago

franckpastor commented 10 years ago

Hello,

I've recently noticed the following behavior with luamplib: when using the MetaPost show command, its argument isn't shown, either in the console or the log file. For example, this command alone

show 1+2;

would return this in the console, as expected:

This is MetaPost Engine 1.4.6 (2013/12/31) by Nicola Vitacolonna Going to process show_command.mp... This is MetaPost, version 1.803 (kpathsea version 6.1.1) (mpost.mp (/usr/local/texlive/2013/texmf-dist/metapost/base/plain.mp Preloading the plain mem file, version 1.005) ) (./show_command.mp >> 3)

Whereas the following LuaLaTeX program returns nothing:

\documentclass{article}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
beginfig(1);
show 1+2;
endfig;
\end{mplibcode}
\end{document}

Note that you have to include the show command into a beginfig;endfig; environment, which is not necessary with standalone MetaPost.

Is it a bug or is luamplib intended to behave like this?

dohyunkim commented 10 years ago

There is an undocumented feature in luamplib. After declaring

\directlua{ luamplib.showlog=true }

terminal messages of mplib library will be printed to the console and to the log file.

There is no TeX macro supporting this feature; we should write a lua code, though small one, with \directlua command. Moreover, assigning true to showlog will prevent figure outputs. I don't know why, but this part of luamplib code is very old one, maybe from the very start of the package.

It would be better if we can see terminal messages automatically without \directlua hassle when show command is used inside mplibcode environments. So I have uploaded a new version just now. Nothing is required from the users' part. Incidentally, show command without beginfig/endfig will not raise an error, but print terminal message and a small warning saying no figure output.

franckpastor commented 10 years ago

After a few tries, it seems to work flawlessly. Thanks… once more!