lualatex / luamplib

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

missing \par in \mplibstoptoPDF leads to unbalanced paragraph hooks #113

Closed mbertucci47 closed 11 months ago

mbertucci47 commented 11 months ago

From @u-fischer's analysis in response to my question in the LaTeX tagging-project repo, it seems \mplibstoptoPDF is missing a beginning \par. This causes the paragraph hooks to be unbalanced, which in turn causes the tagging code to produce an error. I've copied the example showing the issue below:

\documentclass{article}
\usepackage{luamplib}

\begin{document}
\AddToHook{para/begin}{begin} \AddToHook{para/end}{end}

\begin{mplibcode}
beginfig(1); draw (0,0)--(100,0)--(100,100)--(0,100)--cycle; endfig; 
\end{mplibcode}

\def\mplibstoptoPDF{%
  \par % missing
  \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
}

\begin{mplibcode}
beginfig(1); draw (0,0)--(100,0)--(100,100)--(0,100)--cycle; endfig; 
\end{mplibcode}

\end{document}
dohyunkim commented 11 months ago

Thanks for the report. The issue is corrected via #114 and a new version is uploaded.