%% %% This is file `luamplib.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% luamplib.dtx (with options: `package') %% %% See source file 'luamplib.dtx' for licencing and contact information. %% \ifcsname ProvidesPackage\endcsname \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} [2024/08/03 v2.34.5 mplib package for LuaTeX] \fi \ifdefined\newluafunction\else \input ltluatex \fi \ifnum\outputmode=0 \ifdefined\AddToHookNext \def\luamplibatnextshipout{\AddToHookNext{shipout/background}} \def\luamplibatfirstshipout{\AddToHook{shipout/firstpage}} \def\luamplibateveryshipout{\AddToHook{shipout/background}} \else \input atbegshi.sty \def\luamplibatnextshipout#1{\AtBeginShipoutNext{\AtBeginShipoutAddToBox{#1}}} \let\luamplibatfirstshipout\AtBeginShipoutFirst \def\luamplibateveryshipout#1{\AtBeginShipout{\AtBeginShipoutAddToBox{#1}}} \fi \fi \directlua{require("luamplib")} \ifx\pdfoutput\undefined \let\pdfoutput\outputmode \fi \ifx\pdfliteral\undefined \protected\def\pdfliteral{\pdfextension literal} \fi \def\mplibsetformat#1{\directlua{luamplib.setformat("#1")}} \ifnum\pdfoutput>0 \let\mplibtoPDF\pdfliteral \else \def\mplibtoPDF#1{\special{pdf:literal direct #1}} \ifcsname PackageInfo\endcsname \PackageInfo{luamplib}{only dvipdfmx is supported currently} \else \immediate\write-1{luamplib Info: only dvipdfmx is supported currently} \fi \fi \def\mplibforcehmode{\let\prependtomplibbox\leavevmode} \def\mplibnoforcehmode{\let\prependtomplibbox\relax} \mplibnoforcehmode \def\mplibsetupcatcodes{% %catcode`\{=12 %catcode`\}=12 \catcode`\#=12 \catcode`\^=12 \catcode`\~=12 \catcode`\_=12 \catcode`\&=12 \catcode`\$=12 \catcode`\%=12 \catcode`\^^M=12 } \def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\copy#1\hss}}} \protected\def\usemplibgroup#1{\csname luamplib.group.#1\endcsname} \protected\def\mplibgroup#1{% \begingroup \def\MPllx{0}\def\MPlly{0}% \def\mplibgroupname{#1}% \mplibgroupgetnexttok } \def\mplibgroupgetnexttok{\futurelet\nexttok\mplibgroupbranch} \def\mplibgroupskipspace{\afterassignment\mplibgroupgetnexttok\let\nexttok= } \def\mplibgroupbranch{% \ifx [\nexttok \expandafter\mplibgroupopts \else \ifx\mplibsptoken\nexttok \expandafter\expandafter\expandafter\mplibgroupskipspace \else \let\mplibgroupoptions\empty \expandafter\expandafter\expandafter\mplibgroupmain \fi \fi } \def\mplibgroupopts[#1]{\def\mplibgroupoptions{#1}\mplibgroupmain} \def\mplibgroupmain{\setbox\mplibscratchbox\hbox\bgroup\ignorespaces} \protected\def\endmplibgroup{\egroup \directlua{ luamplib.registergroup( \the\mplibscratchbox, '\mplibgroupname', {\mplibgroupoptions} )}% \endgroup } {\def\:{\global\let\mplibsptoken= } \: } \protected\def\mppattern#1{% \begingroup \def\mplibpatternname{#1}% \mplibpatterngetnexttok } \def\mplibpatterngetnexttok{\futurelet\nexttok\mplibpatternbranch} \def\mplibpatternskipspace{\afterassignment\mplibpatterngetnexttok\let\nexttok= } \def\mplibpatternbranch{% \ifx [\nexttok \expandafter\mplibpatternopts \else \ifx\mplibsptoken\nexttok \expandafter\expandafter\expandafter\mplibpatternskipspace \else \let\mplibpatternoptions\empty \expandafter\expandafter\expandafter\mplibpatternmain \fi \fi } \def\mplibpatternopts[#1]{% \def\mplibpatternoptions{#1}% \mplibpatternmain } \def\mplibpatternmain{% \setbox\mplibscratchbox\hbox\bgroup\ignorespaces } \protected\def\endmppattern{% \egroup \directlua{ luamplib.registerpattern( \the\mplibscratchbox, '\mplibpatternname', {\mplibpatternoptions} )}% \endgroup } \def\mpfiginstancename{@mpfig} \protected\def\mpfig{% \begingroup \futurelet\nexttok\mplibmpfigbranch } \def\mplibmpfigbranch{% \ifx *\nexttok \expandafter\mplibprempfig \else \expandafter\mplibmainmpfig \fi } \def\mplibmainmpfig{% \begingroup \mplibsetupcatcodes \mplibdomainmpfig } \long\def\mplibdomainmpfig#1\endmpfig{% \endgroup \directlua{ local legacy = luamplib.legacyverbatimtex local everympfig = luamplib.everymplib["\mpfiginstancename"] or "" local everyendmpfig = luamplib.everyendmplib["\mpfiginstancename"] or "" luamplib.legacyverbatimtex = false luamplib.everymplib["\mpfiginstancename"] = "" luamplib.everyendmplib["\mpfiginstancename"] = "" luamplib.process_mplibcode( "beginfig(0) "..everympfig.." "..[===[\unexpanded{#1}]===].." "..everyendmpfig.." endfig;", "\mpfiginstancename") luamplib.legacyverbatimtex = legacy luamplib.everymplib["\mpfiginstancename"] = everympfig luamplib.everyendmplib["\mpfiginstancename"] = everyendmpfig }% \endgroup } \def\mplibprempfig#1{% \begingroup \mplibsetupcatcodes \mplibdoprempfig } \long\def\mplibdoprempfig#1\endmpfig{% \endgroup \directlua{ local legacy = luamplib.legacyverbatimtex local everympfig = luamplib.everymplib["\mpfiginstancename"] local everyendmpfig = luamplib.everyendmplib["\mpfiginstancename"] luamplib.legacyverbatimtex = false luamplib.everymplib["\mpfiginstancename"] = "" luamplib.everyendmplib["\mpfiginstancename"] = "" luamplib.process_mplibcode([===[\unexpanded{#1}]===],"\mpfiginstancename") luamplib.legacyverbatimtex = legacy luamplib.everymplib["\mpfiginstancename"] = everympfig luamplib.everyendmplib["\mpfiginstancename"] = everyendmpfig }% \endgroup } \protected\def\endmpfig{endmpfig} \unless\ifcsname ver@luamplib.sty\endcsname \def\mplibcodegetinstancename[#1]{\gdef\currentmpinstancename{#1}\mplibcodeindeed} \protected\def\mplibcode{% \begingroup \futurelet\nexttok\mplibcodebranch } \def\mplibcodebranch{% \ifx [\nexttok \expandafter\mplibcodegetinstancename \else \global\let\currentmpinstancename\empty \expandafter\mplibcodeindeed \fi } \def\mplibcodeindeed{% \begingroup \mplibsetupcatcodes \mplibdocode } \long\def\mplibdocode#1\endmplibcode{% \endgroup \directlua{luamplib.process_mplibcode([===[\unexpanded{#1}]===],"\currentmpinstancename")}% \endgroup } \protected\def\endmplibcode{endmplibcode} \else \newenvironment{mplibcode}[1][]{% \global\def\currentmpinstancename{#1}% \mplibtmptoks{}\ltxdomplibcode }{} \def\ltxdomplibcode{% \begingroup \mplibsetupcatcodes \ltxdomplibcodeindeed } \def\mplib@mplibcode{mplibcode} \long\def\ltxdomplibcodeindeed#1\end#2{% \endgroup \mplibtmptoks\expandafter{\the\mplibtmptoks#1}% \def\mplibtemp@a{#2}% \ifx\mplib@mplibcode\mplibtemp@a \directlua{luamplib.process_mplibcode([===[\the\mplibtmptoks]===],"\currentmpinstancename")}% \end{mplibcode}% \else \mplibtmptoks\expandafter{\the\mplibtmptoks\end{#2}}% \expandafter\ltxdomplibcode \fi } \fi \def\mplibshowlog#1{\directlua{ local s = string.lower("#1") if s == "enable" or s == "true" or s == "yes" then luamplib.showlog = true else luamplib.showlog = false end }} \def\mpliblegacybehavior#1{\directlua{ local s = string.lower("#1") if s == "enable" or s == "true" or s == "yes" then luamplib.legacyverbatimtex = true else luamplib.legacyverbatimtex = false end }} \def\mplibverbatim#1{\directlua{ local s = string.lower("#1") if s == "enable" or s == "true" or s == "yes" then luamplib.verbatiminput = true else luamplib.verbatiminput = false end }} \newtoks\mplibtmptoks \ifcsname ver@luamplib.sty\endcsname \protected\def\everymplib{% \begingroup \mplibsetupcatcodes \mplibdoeverymplib } \protected\def\everyendmplib{% \begingroup \mplibsetupcatcodes \mplibdoeveryendmplib } \newcommand\mplibdoeverymplib[2][]{% \endgroup \directlua{ luamplib.everymplib["#1"] = [===[\unexpanded{#2}]===] }% } \newcommand\mplibdoeveryendmplib[2][]{% \endgroup \directlua{ luamplib.everyendmplib["#1"] = [===[\unexpanded{#2}]===] }% } \else \def\mplibgetinstancename[#1]{\def\currentmpinstancename{#1}} \protected\def\everymplib#1#{% \ifx\empty#1\empty \mplibgetinstancename[]\else \mplibgetinstancename#1\fi \begingroup \mplibsetupcatcodes \mplibdoeverymplib } \long\def\mplibdoeverymplib#1{% \endgroup \directlua{ luamplib.everymplib["\currentmpinstancename"] = [===[\unexpanded{#1}]===] }% } \protected\def\everyendmplib#1#{% \ifx\empty#1\empty \mplibgetinstancename[]\else \mplibgetinstancename#1\fi \begingroup \mplibsetupcatcodes \mplibdoeveryendmplib } \long\def\mplibdoeveryendmplib#1{% \endgroup \directlua{ luamplib.everyendmplib["\currentmpinstancename"] = [===[\unexpanded{#1}]===] }% } \fi \def\mpdim#1{ runscript("luamplibdimen{#1}") } \def\mpcolor#1#{\domplibcolor{#1}} \def\domplibcolor#1#2{ runscript("luamplibcolor{#1{#2}}") } \def\mplibnumbersystem#1{\directlua{ local t = "#1" if t == "binary" then t = "decimal" end luamplib.numbersystem = t }} \def\mplibmakenocache#1{\mplibdomakenocache #1,*,} \def\mplibdomakenocache#1,{% \ifx\empty#1\empty \expandafter\mplibdomakenocache \else \ifx*#1\else \directlua{luamplib.noneedtoreplace["#1.mp"]=true}% \expandafter\expandafter\expandafter\mplibdomakenocache \fi \fi } \def\mplibcancelnocache#1{\mplibdocancelnocache #1,*,} \def\mplibdocancelnocache#1,{% \ifx\empty#1\empty \expandafter\mplibdocancelnocache \else \ifx*#1\else \directlua{luamplib.noneedtoreplace["#1.mp"]=false}% \expandafter\expandafter\expandafter\mplibdocancelnocache \fi \fi } \def\mplibcachedir#1{\directlua{luamplib.getcachedir("\unexpanded{#1}")}} \def\mplibtextextlabel#1{\directlua{ local s = string.lower("#1") if s == "enable" or s == "true" or s == "yes" then luamplib.textextlabel = true else luamplib.textextlabel = false end }} \def\mplibcodeinherit#1{\directlua{ local s = string.lower("#1") if s == "enable" or s == "true" or s == "yes" then luamplib.codeinherit = true else luamplib.codeinherit = false end }} \def\mplibglobaltextext#1{\directlua{ local s = string.lower("#1") if s == "enable" or s == "true" or s == "yes" then luamplib.globaltextext = true else luamplib.globaltextext = false end }} \ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi \def\mplibstarttoPDF#1#2#3#4{% \prependtomplibbox \hbox dir TLT\bgroup \xdef\MPllx{#1}\xdef\MPlly{#2}% \xdef\MPurx{#3}\xdef\MPury{#4}% \xdef\MPwidth{\the\dimexpr#3bp-#1bp\relax}% \xdef\MPheight{\the\dimexpr#4bp-#2bp\relax}% \parskip0pt% \leftskip0pt% \parindent0pt% \everypar{}% \setbox\mplibscratchbox\vbox\bgroup \noindent } \def\mplibstoptoPDF{% \par \egroup % \setbox\mplibscratchbox\hbox % {\hskip-\MPllx bp% \raise-\MPlly bp% \box\mplibscratchbox}% \setbox\mplibscratchbox\vbox to \MPheight {\vfill \hsize\MPwidth \wd\mplibscratchbox0pt% \ht\mplibscratchbox0pt% \dp\mplibscratchbox0pt% \box\mplibscratchbox}% \wd\mplibscratchbox\MPwidth \ht\mplibscratchbox\MPheight \box\mplibscratchbox \egroup } \def\mplibtextext#1#2#3#4#5{% \begingroup \setbox\mplibscratchbox\hbox {\font\temp=#1 at #2bp% \temp #3}% \setbox\mplibscratchbox\hbox {\hskip#4 bp% \raise#5 bp% \box\mplibscratchbox}% \wd\mplibscratchbox0pt% \ht\mplibscratchbox0pt% \dp\mplibscratchbox0pt% \box\mplibscratchbox \endgroup } \openin0=luamplib.cfg \ifeof0 \else \closein0 \input luamplib.cfg \fi \endinput %% %% End of file `luamplib.sty'.