lualatex / luamplib

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

pgf package hinders \mpcolor process #84

Closed dohyunkim closed 4 years ago

dohyunkim commented 4 years ago
\pdfvariable compresslevel 0
\pdfvariable objcompresslevel 0
\documentclass{beamer}
\usepackage{luamplib}
\begin{document}
\begin{frame}
  \begin{mplibcode}
    beginfig(1)
    draw fullcircle scaled 1cm withcolor \mpcolor{red};
    endfig;
  \end{mplibcode}
\end{frame}
\end{document}

In the pdf, we get a line as follows:

\xcolor@ {}{1 0 0 rg 1 0 0 RG}{rgb}{1,0,0}

It seems that \pgfutil@namelet redefines \corrent@color at the last stage of color process. See xxcolor.sty.

dohyunkim commented 4 years ago
--- a/luamplib/luamplib.lua
+++ b/usr/local/texlive/2019/texmf-dist/tex/luatex/luamplib/luamplib.lua
@@ -377,7 +377,7 @@ local function process_color (str)
       str = format("{%s}",str)
     end
     run_tex_code(format(
-      "\\def\\set@color{\\toks0\\expandafter{\\current@color}}\\color %s", str),
+      "\\let\\XC@mcolor\\relax\\def\\set@color{\\toks0\\expandafter{\\current@color}}\\color %s", str),
       catat11)
     return format("1 withprescript \"MPlibOverrideColor=%s\"", texgettoks(0))
   end

How about?