我希望能够做以下事情:
\documentclass{standalone}
\begin{document}
Foo
\begin{MyUndefinedEnv}
Bar
\end{MyUndefinedEnv}
\end{document}
而不LaTeX
抱怨未定义的环境。在不破坏现有环境的情况下是否可行?
答案1
是的你可以:
\documentclass{article}
\makeatletter
\let\xbegin\begin % store original \begin
\let\xifundefined\@ifundefined % store original \@ifundefined
\def\begin{%
% "inactivate" \@ifundefined, but only once, hence reverting
% it to original definition immediately
\def\@ifundefined##1##2##3{\global\let\@ifundefined\xifundefined##3}%
\xbegin}
\makeatother
\begin{document}
\begin{ttgg}
Hello!
\end{ttgg}
\begin{center}
Hello!
\end{center}
\end{document}