-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
\Collect@@body doesn't guard against unmatched if tokens in the part of the body scanned so far (actually \collect@@body copied from amsmath doesn't either but there doesn't appear to be a user interface to that here, and in amsmath all the environments are \halign contexts so nested \if perhaps less likely.
see
https://tex.stackexchange.com/a/604786/1090
\documentclass{article}
\usepackage{environ}
\makeatletter
\long\def\Collect@@Body#1\end#2{%
\edef\begin@stack{%
\Push@Begins#1\begin\end\expandafter\@gobble\begin@stack}%
\ifx\@empty\begin@stack
\endgroup
\@checkend{#2}%
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\Addto@Envbody{#1}}%
{\Addto@Envbody{#1\end{#2}}}%
\process@envbody}
\makeatother
\RenewEnviron{figure}{It's gone!}
\usepackage{ifpdf}
\begin{document}
\begin{figure}
\ifpdf
\begin{tabular}{l}
This works without RenewEnviron, ifpdf or tabular!
\end{tabular}
\else\fi
\end{figure}
\end{document}
Metadata
Metadata
Assignees
Labels
No labels