Note: I have seen a seemingly duplicate question at Why I can not define commands starting with \end? that offers a workaround but does not really answer the "Why" part of the question. This question is meant to really understand the "Why" part.
Example code:
\documentclass{article}
\newcommand{\endnote}{endnote}
\begin{document}
hello
\end{document}
Output:
$ pdflatex foo.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./foo.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18>
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/size10.clo))
! LaTeX Error: Command \endnote already defined.
Or name \end... illegal, see p.192 of the manual.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.2 \newcommand{\endnote}{endnote}
?
The error messages asks me to read page 192 of manual. But I could not understand which manual it is referring to. I would like to know exactly why LaTeX refuses to create a command that begins with \end
.
\newcommand
, since all environments create a macro\end<environmentname>
, your definition, if executed, would overwrite a hypothetical environment namednote
. You can\def\endnote{}
, but you do so at your own risk.\<environmentname>
and\<endenvironmentname>
underlying environments I especially like the environmentscsname
andgroup
. ;-))