The \list command

Consider the following code listing from p. 82 of the TikZ & PGF manual for version 3.0.1a:

A code listing from the TikZ & PGF manual

\def\lecture#1#2#3#4#5#6{
  \node [annotation, #3, scale=0.65, text width=4cm, inner sep=2mm] at (#4) {
    Lecture #1: \textcolor{orange}{\textbf{#2}}
    \list{--}{\topsep=2pt\itemsep=0pt\parsep=0pt
              \parskip=0pt\labelwidth=8pt\leftmargin=8pt
              \itemindent=0pt\labelsep=2pt}
    #5
    \endlist
  };
}

The listing uses a pair of commands: \list and \endlist. The \list command takes two arguments: {--} and {\topset...=2pt}.

The \list command is not listed in the TikZ manual’s index, nor in the indices of Knuth’s The TeX Book or Lamport’s LaTeX.

To which system/package does this command belong?
What is its syntax?
What are its semantics?

Solutions Collecting From Web of "The \list command"

The code above is not particularly instructive for beginners and should be accompanied by explicatory notes.

It takes advantage of two facts:

  1. the code in the main argument to \node is executed in a \parbox, due to setting of text width, which forms a (TeX) group;

  2. code such as \begin{env}...\end{env} is essentially equivalent to

    \begingroup
    <some bookkeeping>
    \env
    ...
    \endenv
    <some bookkeeping>
    \endgroup
    

The bookkeeping is, in this case, irrelevant, because the whole construction is performed in the group provided by \parbox.

Never use \list...\endlist in the wild, because not doing the bookkeeping will almost certainly have adverse effects.

The code should better be, from a teacher’s point of view,

\newcommand{\lecture}[6]{%
  \node [annotation, #3, scale=0.65, text width=4cm, inner sep=2mm] at (#4) {
    Lecture #1: \textcolor{orange}{\textbf{#2}}
    \begin{list}{--}{%
      \setlength{\topsep}{2pt}%
      \setlength{\itemsep}{0pt}%
      \setlength{\parsep}{0pt}%
      \setlength{\parskip}{0pt}%
      \setlength{\labelwidth}{8pt}%
      \setlength{\leftmargin}{8pt}%
      \setlength{\itemindent}{0pt}%
      \setlength{\labelsep}{2pt}%
    }%
    #5
    \end{list}
  };
}

Optimizations such as those require experience and actually don’t gain much.

Better yet, one could do

\newenvironment{lecturelist}
 {\begin{list}{--}{%
    \setlength{\topsep}{2pt}%
    \setlength{\itemsep}{0pt}%
    \setlength{\parsep}{0pt}%
    \setlength{\parskip}{0pt}%
    \setlength{\labelwidth}{8pt}%
    \setlength{\leftmargin}{8pt}%
    \setlength{\itemindent}{0pt}%
    \setlength{\labelsep}{2pt}%
  }%
  {\end{list}}

and then

\newcommand{\lecture}[6]{%
  \node [annotation, #3, scale=0.65, text width=4cm, inner sep=2mm] at (#4) {
    Lecture #1: \textcolor{orange}{\textbf{#2}}
    \begin{lecturelist}
    #5
    \end{lecturelist}
  };
}

In the code for lecturelist it would be good to change \begin{list} and \end{list} with \list and \endlist respectively: the bookkeeping will be taken care of by \begin{lecturelist} and \end{lecturelist}, so it doesn’t need to be done in the inner part. It would also give better error messages in case one doesn’t properly close the lecturelist package.