The code above is not particularly instructive for beginners and should be accompanied by explicatory notes.
It takes advantage of two facts:
the code in the main argument to \node is executed in a \parbox, due to setting of text width, which forms a (TeX) group;
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.
\listand\endlistare the commands corresponding to the start and end of thelistenvironment. – karlkoeller Jun 18 '17 at 09:09listenvironment in the above code listing? – Evan Aad Jun 18 '17 at 09:13texdoc source2e, search for\def\list. – Torbjørn T. Jun 18 '17 at 09:13\def\listin texdoc resulted in no matches. – Evan Aad Jun 18 '17 at 09:22source2e, open the PDF, and search in the PDF. (texdocis a command line tool, so you can open a terminal/command prompt on your computer, and typetexdoc source2eto get the same PDF, that was what I meant.) – Torbjørn T. Jun 18 '17 at 09:25\def\listin the PDF file opened by runningtexdoc source2eat the terminal yielded no results either. – Evan Aad Jun 18 '17 at 09:29\def\listdoesn't seem to be there, but\listand\endlistare discussed in chapter 55 List, and related environments starting on p. 283. At any rate, thanks. I wasn't aware of the existence oftexdoc. – Evan Aad Jun 18 '17 at 09:43texdoc source2eincluded with TeX Live 2017, look for\def\listat the bottom of page 290, numbered line 34 — the chapter this occurs in is "File A: ltlists.dtx" aka "Lists, and related environments". (You can find this by looking in the index under L for\list, and following the underlined index entry, which stands for where it's defined.) – ShreevatsaR Jun 18 '17 at 15:20