Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm creating a Beamer presentation and I wanted to change margin size for single slides. I've found a solution on some old mailing list, adapted it a little and it works perfectly, but I have no idea how it works=/

\newenvironment{codemargin}{%
  \begin{list}{}{%
        \setlength{\leftmargin}{-0.7cm}%
        \setlength{\rightmargin}{-0.7cm}%
      }%
  \item[]}{
  \end{list}
}

This creates a new environment that I can use on slides that I want to have smaller margins.

Now to the point - what does \item[]}{ mean? I can't find any other examples using similar syntax.

share|improve this question
add comment

2 Answers 2

up vote 10 down vote accepted

The rough idea is that the list environment (for reasons I don't fully understand) makes various kinds of formatting easier, such as the setlengths you have. I believe it also suppresses the initial paragraph indentation, too. However, just as with the itemize, enumerate, and description environments—which are all wrappers around list—the only permitted text must follow an \item. And since \item can take an optional argument (something used to great effect in description lists), an empty one is provided so that you can write

\begin{codemargin}
  [This text] demonstrates...
\end{codemargin}

Otherwise, the [This text] would get swallowed up by the \item command.

share|improve this answer
1  
I do wonder, though, why the macro writer didn't use trivlist instead. –  Harald Hanche-Olsen Nov 15 '10 at 8:11
add comment

to answer the other part of your question, it seems you are being confused by the order of braces, read rather:

\newenvironment{codemargin}
{% begin
     \begin{list}{
}{% do
     \setlength{\leftmargin}{-0.7cm}\setlength{\rightmargin}{-0.7cm}}%
     \item[]
}{% end
     \end{list}
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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