下面的完整示例(很抱歉我没能成功使其更简洁)曾经可以顺利编译(我猜是因为 TL 2017 没有更新),但现在情况已经不再如此了:
!TeX 容量超出,抱歉 [输入堆栈大小=5000]。\q_nil l.53 \end{align}
你知道发生了什么吗?
\documentclass{article}
%
\usepackage{xparse}
\usepackage{amsmath}
\usepackage{environ}
\usepackage{autonum}
%
\makeatletter
\ExplSyntaxOn
\clist_set:Nn \l_tmpa_clist {flalign,alignat}
\clist_map_inline:Nn \l_tmpa_clist {
\RenewEnviron{#1}{}
}
\clist_set:Nn \l_tmpa_clist {align,multline}
\clist_map_inline:Nn \l_tmpa_clist {
\cs_set_eq:cc {db_#1_start:} {#1}
\cs_set_eq:cc {db_#1_end:} {end#1}
\NewDocumentEnvironment{amsmath#1}{}
{\cs:w db_#1_start:\cs_end:}
{\cs:w db_#1_end:\cs_end:}
\RenewEnviron{#1}
{
\cs:w db_multiline_eq:nV\cs_end: {#1} \BODY
}
}
\seq_new:N \l_db_multiline_eq_seq
\cs_new_protected:Nn \db_multiline_eq:nn
{
\seq_set_split:Nnn \l_db_multiline_eq_seq { \\ } { #2 }
\begin{amsmath#1}
\seq_use:Nn \l_db_multiline_eq_seq { \multiline@double@backslash }
\end{amsmath#1}
}
\cs_generate_variant:Nn \db_multiline_eq:nn { nV }
\cs_new_protected:Nn \db_multiline_double_backslash:n
{
\IfBooleanTF{#1}{\\*}{\\}
%
\db_add_multiline_eq_label:
}
\NewDocumentCommand{\multiline@double@backslash}{s}{%
\db_multiline_double_backslash:n {#1}
}
\cs_new_protected:Nn \db_add_multiline_eq_label: {}
\ExplSyntaxOff
\makeatother
\begin{document}
\begin{align}
e^{i\pi}+1 & = 0 \\
e & = \sum_{n\geq 0} \frac{1}{n!}
\end{align}
\end{document}