# LaTeX strange new environment definition

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.

-

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.

-
I do wonder, though, why the macro writer didn't use trivlist instead. –  Harald Hanche-Olsen Nov 15 '10 at 8:11

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}
}
-