1

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?

4

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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.