lualatex 和 pdflatex 在空的 dmath 环境中进入无限循环

lualatex 和 pdflatex 在空的 dmath 环境中进入无限循环

这个 MWE 使 lualatex (以及 pdflatex)在 100% CPU 下进入无限循环

\documentclass[12pt]{book}
\usepackage{amsmath}
\usepackage{breqn}

\begin{document}
test
\begin{dmath*}
\end{dmath*}
\end{document}

现在lualatex index.tex进入无限循环:

(/usr/local/texlive/2022/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))

CPU 运行 100%。它会一直这样。这是预料之中的吗?还是一个错误?如果我改成

\begin{align*}
\end{align*}

那么就没问题了。第一个输出是我的程序中的一个错误,它生成了空方程,所以这不是故意的。

但问题是,它是否会因为空环境而陷入无限循环?

TL 2022。我现在也会尝试在 TL 2023 上测试它。刚刚完成安装。

附言:它也挂在TL 2023中:

>lualatex main.tex
This is LuaHBTeX, Version 1.17.0 (TeX Live 2023) 
 restricted system commands enabled.
(./main.tex
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-06-16>
 (/usr/local/texlive/2023/texmf-dist/tex/latex/base/book.cls
Document Class: book 2023/05/17 v1.4n Standard LaTeX document class
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/bk12.clo
luaotfload | db : Font names database not found, generating new one.
luaotfload | db : This can take several minutes; please be patient.))
(/usr/local/texlive/2023/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2023/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2023/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2023/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2023/texmf-dist/tex/latex/breqn/breqn.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-luatex.def))
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics-def/luatex.def)))
(/usr/local/texlive/2023/texmf-dist/tex/latex/breqn/flexisym.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/breqn/cmbase.sym)
(/usr/local/texlive/2023/texmf-dist/tex/latex/breqn/mathstyle.sty))
(/usr/local/texlive/2023/texmf-dist/tex/latex/tools/calc.sty)) (./main.aux)
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/local/texlive/2023/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2023/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))

答案1

可能:

\documentclass[12pt]{book}
\usepackage{amsmath}
\usepackage{breqn}
\makeatletter
\def\eq@repack{%
  \ifcase\lastpenalty
     % case 0: normal case
    \setbox\tw@\lastbox
\ifvoid\tw@
\PackageError{breqn}{???}{???}%
\setbox\tw@\hbox{??}%
\penalty\@ne
\fi
    \eq@repacka\EQ@copy \eq@repacka\EQ@box
    \unskip
  \or % case 1: finished recursing
    \unpenalty
    \setbox\tw@\lastbox
    \eq@repacka\EQ@copy \eq@repacka\EQ@box
    \@xp\@gobble
  \or % case 2: save box width = LHS width
    \unpenalty
    \setbox\tw@\lastbox
    \setbox\z@\copy\tw@ \setbox\z@\hbox{\unhbox\z@\unskip\unpenalty}%
    \addtolength\eq@wdL{\wd\z@}
    \setlength\eq@wdR{\wd\EQ@box}% BRM:  eq@wdL patch
    \xdef\EQ@setwdL{\eq@wdL\the\eq@wdL\relax}%
    \global\setbox\EQ@copy\hbox{%
      \hbox{\unhcopy\tw@\unskip\unpenalty\unskip}%
      \box\EQ@copy
    }%
    \global\setbox\EQ@box\hbox{%
      \hbox{\unhbox\tw@\unskip\unpenalty\unskip}%
      \box\EQ@box
    }%
    \unskip
  \or % case 3: unpack left-right box
    \unpenalty
    \eq@lrunpack
  \else
    \breqn@repack@err
  \fi
  \eq@repack % RECURSE
}
\makeatother

\begin{document}
test
\begin{dmath*}
\end{dmath*}
\end{document}

相关内容