0

When creating environments based on list I have seen two implementations:

\documentclass{report}

\newenvironment{examplea}{% \begin{list}{}{% stuff here }} {\end{list}}

\newenvironment{exampleb}{% \list{}{% stuff here }} {\endlist}

\begin{document}

\begin{examplea} \item bla \end{examplea}

\begin{exampleb} \item bla \end{exampleb}

\end{document}

They both seem to be behaving the same way. In comments here it is recommended not to use \list and \endlist in the wild ... but that leaves unanswered the question about their difference.

What is the difference in using \list vs. \begin{list} and \endlist vs. \end{list}?
Are there contexts where I should not use \begin{list} and \end{list}, for instance?

jan
  • 2,236
  • Mostly, \begin sets \@currenvir and \end checks it; hence the error message "\begin{list} was ended by \end{document}" (for example). There was a time I worried about nesting environments before I realized that \@currenvir was being stored locally in nested groups. – John Kormylo Jun 12 '22 at 03:16
  • @user202729 It does :) ... only now I'm wondering why anyone would ever use the begin ... end format? – jan Jun 12 '22 at 03:42
  • 1
    \begin and \end have changed in the LaTeX kernel since Martin Scharrer wrote this answer. If you don't call them for the inner environment, its \BeforeBeginEnvironment, \AtBeginEnvironment, \AtEndEnvironment and \AfterEndEnvironment hooks won't be run! AFAIK, the hooks were added in 2020; see texdoc lthooks. – frougon Jun 12 '22 at 08:41

0 Answers0