1

With the code

\documentclass{article}
\usepackage{etoolbox}

\newenvironment{Toto}{%
}{%
}

\AfterEndEnvironment{Toto}{I forgot\dots}

\begin{document}
\begin{Toto}

\end{Toto}

\csundef{@afterend@Toto@hook}

\begin{Toto}

\end{Toto}

\end{document}

\csundef doesn't work with TL2020 + 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)

but in overleaf, it works with TL2020 + etoolbox 2020/07/15 v2.5i e-TeX tools for LaTeX (JAW)

3
  • 1
    You are using package internals, which can change without notice; perhaps you could explain the aim here
    – Joseph Wright
    Jan 6, 2021 at 13:40
  • 2
    BTW, the change is as the LaTeX kernel now has a hook system, and etoolbox has been updated to be aware of this
    – Joseph Wright
    Jan 6, 2021 at 13:40
  • I want make personnal exercises with personnal correction for each student of my college classroom. So one environment with hook when i want change correction (yes/not/partial...) Jan 6, 2021 at 15:42

1 Answer 1

1

I don't think this has ever been the right way to remove something from \AfterEndEnvironment.

\documentclass{article}
\usepackage{etoolbox}

\newenvironment{Toto}{%
}{%
}

\newcommand{\iforgot}{I forgot\dots}
\AfterEndEnvironment{Toto}{\iforgot}

\begin{document}
\begin{Toto}
x
\end{Toto}

\renewcommand{\iforgot}{}

\begin{Toto}
x
\end{Toto}

\end{document}

A new hook management is now built in the LaTeX kernel from the 2020-10-01 release.

\documentclass{article}

\newenvironment{Toto}{}{}

\AddToHook{env/Toto/after}[forgot]{I forgot\ldots}

\begin{document}
\begin{Toto}
x
\end{Toto}

\RemoveFromHook{env/Toto/after}[forgot]

\begin{Toto}
x
\end{Toto}

\end{document}

The label in square brackets is an arbitrary string. You can add as many pieces of code you want and only disable some of them through the label mechanism. See the documentation with

texdoc lthooks

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .