Quoting from the LaTeX2e sources:
[
\@endparenv,\@doendpe]To suppress the paragraph indentation in text immediately following a paragraph-making environment,
\everyparis changed to remove the space, and\paris redefined to restore\everypar. Instead of redefining\parand\everpar,\@endparenvwas changed to set the@endpeswitch, letting\endredefine\parand\everypar.This allows paragraph-making environments to work right when called by other environments. (Changed 27 Oct 86)
These are the relevant code lines (with line breaks added to improve readability):
\def\@endparenv{%
\addpenalty\@endparpenalty
\addvspace\@topsepadd
\@endpetrue
}
\def\@doendpe{%
\@endpetrue% <---?
\def\par{%
\@restorepar
\everypar{}%
\par
\@endpefalse% <---?
}%
\everypar{%
{\setbox\z@\lastbox}%
\everypar{}%
\@endpefalse% <---?
}%
}
While I roughly comprehend \@doendpe and its \everypar trickery, I'm lost with regard to two details (marked with <---? in the above code):
As the definition of
\beginincludes\@endpefalse, why is it necessary to set\@endpefalseat the end of\@doendpe's\par/\everyparredefinitions?Why is setting
\@endpetrueat the start of\@doendpenecessary? Isn't\@doendpeonly called if the@endpeswitch is set totrue?
I suspect that a possible answer involves the (to me) cryptical remark about "paragraph-making environments [working] right when called by other environments", but would be grateful for a full explanation.
Bonus question: If I were to define a custom list environment that at its end would set \@endpefalse and instead (with the appropriate \aftergroup) call a carbon copy of \@doendpe (say \@doendcustomenv), would the code lines marked wih <---? above be beneficial or superfluous in this copy?
macros2e. – Martin Scharrer Jul 30 '11 at 17:42lrboxthat does some trickery with grouping. It does\@endpefalseat some point. – egreg Jul 30 '11 at 22:28