2

In this question, the following solution was offered for creating an indented environment.

\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist 

I want to understand this code better.

First of all, I think I get the basic idea of \def and \let, and the difference between them. But does anyone have a good reference for the finer points of these?

Also, I see this \list{} command popping up in a lot of places, and I don't understand what it does. Googling didn't bring a lot of help. And what is this item[] thing doing?

David Carlisle
  • 757,742
Eric Auld
  • 1,223
  • see http://tex.stackexchange.com/questions/47057/use-of-trivlist-and-list-in-defining-environments/47069#47069 – David Carlisle Sep 30 '16 at 17:53
  • @DavidCarlisle Hi David, thanks for your comment. Maybe it would help if I had a reference for the \list{} command and what it does. Then I could figure out how it accomplishes what you say. – Eric Auld Sep 30 '16 at 17:58

1 Answers1

6

See Use of \trivlist and \list in defining environments

\list is the command that underlies \begin{enumerate} and \begin{itemize} (hence its name), but also \begin{quote} \begin{verbatim} , \begin{center} and more or less all display environments in latex. \item[] is the usual \item command as used in enumerate

The changemargin environment shown, like the standard centerand quote environments is implemented as a one item list with no visible item label (hence the \item[] command in the environment definition).

Using the list mechanism is a convenient way to control the paragraph shape and the spacing before and after the environment.

David Carlisle
  • 757,742
  • Thank you! Can you explain why {\rightmargin#2\leftmargin#1} is surrounded by its own set of braces? – Eric Auld Sep 30 '16 at 18:19
  • 1
    @EricAuld they are not a group, that is the second argument of \list and that macro injects them to set up the inner paragraph setting, after it has handled other details of the setup. – David Carlisle Sep 30 '16 at 19:03