## LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

 Options: Use Forum View Use Monospaced Font Show Text Part by Default Show All Mail Headers Message: [<< First] [< Prev] [Next >] [Last >>] Topic: [<< First] [< Prev] [Next >] [Last >>] Author: [<< First] [< Prev] [Next >] [Last >>]

At 20:17 -0800 98/10/21, Donald Arseneau wrote:
...
>>  So LaTeX defines \begin{list} and \end{list} as a part of the
>>list-environment interface, but \list and \endlist are part of the
>>implementation of the list environment. ...
>>  ... \list and \endlist do not belong to the interface,
>
>All untrue!  The command equivalent of an environment is "documented"
>on pages 25 and 34 of Lamport's Manual (1st ed; check the index for
>Environment > made from declaration).  It's not *well* documented,
>(omitting mention of the \end form) but it is clearly intended to
>be part of the user interface.

I think the story is that LaTeX does not make that distinction clear,
which it ought to do.

>For the package or class writer, it is *preferred* to use the commands
>rather than the environments for two reasons:
>
> - less overhead and stack use (minor)

When building a high level user interface, overhead is not an important
factor. One should stick to the interface in order to avoid hard-to-catch
errors (like in your example; see below).

> - better syntax checking (important!)
>
>Let's say you use \begin{list} when defining a new environment {citation},
>and a document has omitted \end{citation}.  The error message you get is
>! LaTeX Error: \begin{list} on input line xx ended by \end{document}.
>but if you use \list and \endlist you get the proper
>! LaTeX Error: \begin{citation} on input line xx ended by \end{document}.

The apparent reason this gives "improved syntax checking" is due to a bug
in LaTeX!:

When nesting environments, there are more than environment to keep track
of for the error checking, which LaTeX does not do. So when you write
\newenvironment{citations}{%
\list{}{%
\renewcommand{\makelabel}[1]{\normalfont\itshape ##1}%
}%
}{%
\endlist
}
you avoid the \begingroup ... \endgroup clause for the inner environment
that any environment. Therefore the variable is set correctly for the error
checking you mentioned, but it may be set incorrectly for other tasks.

Therefore, it is safer to rely that the general programming tasks work
correctly, use
\newenvironment{citations}{%
\begin{list}{}{%
\renewcommand{\makelabel}[1]{\normalfont\itshape ##1}%
}%
}{%
\end{list}%
}
and not worry about that the error message comes out wrong.

I made some code "environments with hooks" which keeps track of both
these environments in the case these area nested, so it should be possible
to make both the error messages and other environment tasks compute
correctly.

Hans Aberg