[luatex] MPlib + graphictext
Henri Menke
henrimenke at gmail.com
Tue Dec 3 21:13:20 CET 2019
Dear Troy,
MetaFun uses a lot of Lua code which is only available in ConTeXt.
Basically any MetaFun extension which is not implemented only in terms
of MetaPost macros and primitives is not going to work. There is also
no easy way around it. You can try loading the necessary ConTeXt Lua
files using something like
\directlua{dofile(kpse.find_file("util-fmt.lua"))}
where "util-fmt.lua" has to be replaced by the correct file of course.
You will end up loading at least four of those files and you will have
to put some mock definitions in place to make it work in LaTeX. I have
done this before and you can see what this will look like in practice in
these answers on TeX.SX:
https://tex.stackexchange.com/a/451951/
https://tex.stackexchange.com/a/479410/
Looking at this it should be obvious that making MetaFun work in LaTeX
is sort of non-trivial. The best bet is probably to use ConTeXt like so
\startMPpage
% drawing....
\stopMPpage
This will create a PDF with a single page that only contains the drawing
and is cropped to the bounding box. Then you can \includegraphics this
PDF.
Kind regards,
Henri
On 12/4/19 5:33 AM, Troy Henderson wrote:
> I'm trying to use MetaFun's "graphictext" with LuaLaTeX + MPlib with the
> following code:
>
> % Begin code
> \documentclass{standalone}
> \usepackage{luamplib}
> \mplibsetformat{metafun}
> \begin{document}
> \begin{mplibcode}
> beginfig(0);
> graphictext "Fun" scaled 4 withdrawcolor blue withfillcolor
> .5white withpen pencircle scaled 5pt;
> endfig;
> end
> \end{mplibcode}
> \end{document}
> % End code
>
> However, I am getting the following error (perhaps because it cannot find
> my installed pstoedit in /usr/local/bin). I would appreciate assistance.
>
> Thank you in advance,
>
> Troy
>
> -- Error --
> lualatex foo.ltx
> This is LuaTeX, Version 1.10.0 (TeX Live 2019)
> restricted system commands enabled.
> (./foo.ltx
> LaTeX2e <2018-12-01>
>
> luaotfload | main : initialization completed in 0.543 seconds
> (/usr/local/texlive/current/texmf-dist/tex/latex/standalone/standalone.cls
> Document Class: standalone 2018/03/26 v1.3a Class to compile TeX sub-files
> stan
> dalone
> (/usr/local/texlive/current/texmf-dist/tex/latex/tools/shellesc.sty)
> (/usr/local/texlive/current/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
> (/usr/local/texlive/current/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
> (/usr/local/texlive/current/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
> (/usr/local/texlive/current/texmf-dist/tex/latex/xkeyval/xkeyval.sty
> (/usr/local/texlive/current/texmf-dist/tex/generic/xkeyval/xkeyval.tex
> (/usr/local/texlive/current/texmf-dist/tex/generic/xkeyval/xkvutils.tex
> (/usr/local/texlive/current/texmf-dist/tex/generic/xkeyval/keyval.tex))))
> (/usr/local/texlive/current/texmf-dist/tex/latex/standalone/standalone.cfg)
> (/usr/local/texlive/current/texmf-dist/tex/latex/base/article.cls
> Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
> (/usr/local/texlive/current/texmf-dist/tex/latex/base/size10.clo))
> (/usr/local/texlive/current/texmf-dist/tex/generic/luatex85/luatex85.sty)
> (/usr/local/texlive/current/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
> (/usr/local/texlive/current/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
> (/usr/local/texlive/current/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
> (/usr/local/texlive/current/texmf-dist/tex/luatex/luamplib/luamplib.sty)
> (./foo.aux)Error in mp.find_file:
> ...live/current/texmf-dist/tex/luatex/luamplib/luamplib.lua:233: bad
> argument #2 to 'find_file' (invalid option 'Fun')
> mplib warning: error in script: [string "mp.report([===[]===])"]:1: attempt
> to call a nil value (field 'report')
> mplib warning: error in script: [string "mp.report([===[metafun iv
> 2019-12-3 10:32]===..."]:1: attempt to call a nil value (field 'report')
> mplib warning: error in script: [string "mp.report([===[]===])"]:1: attempt
> to call a nil value (field 'report')
>
> Module luamplib Warning: (Please type a command or say `end')
> (luamplib) (Please type a command or say `end')
> (luamplib)
> (luamplib) ! Please prepare 'Fun' in advance with 'pstoedit
> -ssp
> -dt -f mpost yourfile.ps
> (luamplib) Fun'.
> (luamplib) <to be read again>
> (luamplib) ;
> (luamplib) graphictext->...f mpost yourfile.ps "&(EXPR0)&"'";
> (luamplib)
> fi.c
> losefrom(EXPR0);def.da...
> (luamplib) <to be read again>
> (luamplib) scaled
> (luamplib) <*> graphictext "Fun" scaled
> (luamplib) 4 withdrawcolor blue
> with
> fillcolor .5white with...
> (luamplib) This error message was generated by an `errmessage'
> (luamplib) command, so I can't give any explicit help.
> (luamplib) Pretend that you're Miss Marple: Examine all clues,
> (luamplib) and deduce the truth by inspired guesses.
> (luamplib)
> (luamplib) >> mfun_do_graphic_text
> (luamplib) ! Isolated expression.
> (luamplib) <to be read again>
> (luamplib) (
> (luamplib) graphictext->...EXPR0)enddef;mfun_do_graphic_text(
> (luamplib)
> (EXP
> R0))
> (luamplib) <to be read again>
> (luamplib) scaled
> (luamplib) <*> graphictext "Fun" scaled
> (luamplib) 4 withdrawcolor blue
> with
> fillcolor .5white with...
> (luamplib) I couldn't find an `=' or `:=' after the
> (luamplib) expression that is shown above this error message,
> (luamplib) so I guess I'll just ignore it and carry on.
> (luamplib)
> (luamplib) ! Extra tokens will be flushed.
> (luamplib) <to be read again>
> (luamplib) (
> (luamplib) graphictext->...EXPR0)enddef;mfun_do_graphic_text(
> (luamplib)
> (EXP
> R0))
> (luamplib) <to be read again>
> (luamplib) scaled
> (luamplib) <*> graphictext "Fun" scaled
> (luamplib) 4 withdrawcolor blue
> with
> fillcolor .5white with...
> (luamplib) I've just read as much of that statement as I
> could fa
> thom,
> (luamplib) so a semicolon should have been next. It's very
> puzzli
> ng...
> (luamplib) but I'll try to get myself back together, by
> ignoring
> (luamplib) everything up to the next `;'. Please insert a
> semicol
> on
> (luamplib) now in front of anything that you don't want me to
> del
> ete.
> (luamplib) (See Chapter 27 of The METAFONTbook for an
> example.)
> (luamplib)
> (luamplib)
> (luamplib) [0]
> (luamplib)
> (luamplib) (Please type a command or say `end')
> (luamplib) (Please type a command or say `end')
> (luamplib) on input line 10
> ...l/texlive/current/texmf-dist/tex/latex/base/ltluatex.lua:109:
> Module luamplib Error: see above messages on input line 10
>
> stack traceback:
> [C]: in function 'error'
> ...l/texlive/current/texmf-dist/tex/latex/base/ltluatex.lua:109: in
> function <
> ...l/texlive/current/texmf-dist/tex/latex/base/ltluatex.lua:108>
> (...tail calls...)
> ...live/current/texmf-dist/tex/luatex/luamplib/luamplib.lua:265: in
> upvalue 'r
> eporterror'
> ...live/current/texmf-dist/tex/luatex/luamplib/luamplib.lua:309: in
> function <
> ...live/current/texmf-dist/tex/luatex/luamplib/luamplib.lua:305>
> (...tail calls...)
> ...live/current/texmf-dist/tex/luatex/luamplib/luamplib.lua:635: in
> field 'pro
> cess_mplibcode'
> [\directlua]:1: in main chunk.
> <inserted text> BAD
>
> l.10 \end{mplibcode}
>
More information about the luatex
mailing list