I run with an example today:
\documentclass{article}
\begin{document}
\def\EE{\section{EE}}
\begin{EE}
A
\end{EE}
\end{document}
this source can be compiled successfully using pdflatex
, and generate the output:
According to the answer and my basic understanding of LaTeX, the fisrt section is generated by \EE
, something like \begin{EE}
there, but without starting group.
My question is: "why this source is compilable", for that the command \endEE
hasn't been defined? Then i check the definitions of these 2 macros \begin
and \end
using latexdef
, get the following:
$ latexdef \begin
\begin:
macro:->\protect \begin
\begin :
macro:#1->\UseHook {env/#1/before}\@ifundefined {#1}{\def \reserved@a {\@latex@error {Environment #1 undefined}\@eha }}{\def \reserved@a {\def \@currenvir {#1}\edef \@currenvline {\on@line }\@execute@begin@hook {#1}\csname #1\endcsname }}\@ignorefalse \begingroup \@endpefalse \reserved@a
$ latexdef \end
\end:
macro:->\romannumeral \ifx \protect \@typeset@protect \expandafter \expandafter \expandafter \expandafter \expandafter \expandafter \expandafter \z@ \else \expandafter \z@ \expandafter \protect \fi \end
I find \csname #1\endcsname
in the definition of \begin
, roughly consistent with my guess. There is nothing like \csname
in the definition of \end
, is this the reason that the above source compilable ? But from my previous experience, the environment \begin{Env}...\end{Env}
can be write as \Env ... \endEnv
, maybe within a group.
For the last \end
macro in the definition of \end
in LaTeX. I have check the meaning of \end
in The TeXbook
, found the following in "Chapter 6: RunningTEX":
TEX will now prompt you with ‘*’, because the file did not contain ‘\end’. Enter \end into the computer now ...
So there is nothing special about the macro \end
in plain TeX. Then, what makes the above source compilable?