# Is there a way to have an “empty” environment to merely limit scope of declarations?

I am fairly new to LaTeX, so I apologize if this is a beginner question, but I have not found a good way to query for it otherwise.

I have observed that when I use an environment like \begin{itemize}...\end{itemize}, I can place \newcommand inside the environment, which are scoped to the environment.

\documentclass{article}

\begin{document}
\begin{itemize}

\newcommand{\FFF}{\epsilon}

\item $\FFF$

\end{itemize}
%$\FFF$ %this is out of scope, so it would cause an error if it were commented back in.

\end{document}


However, environments like itemize and enumerate tend to have special effects (such as giving meaning to \item). My question is whether there exists an environment which has no "special effects", whose only role is to limit the scope of declarations.

-
You can enclose anything in braces {...} and this will limit the scope macro definitions within the braces. –  Alan Munn Feb 25 '13 at 4:36
I accept this answer if you write it as one, but just out of curiosity, does this mean all LaTeX environments come with built-in {...}? –  merlin2011 Feb 25 '13 at 4:40
@merlin2011 Essentially yes; LaTeX environments have their own scope. Anything defined (or renewed) inside of them won't be available outside of the environment. –  Sam Whited Feb 25 '13 at 4:43

As Alan Munn said, using braces is one way to go. You an also simply define your own environment:

\newenvironment*{dummyenv}{}{}


And then use it like you normally would:

\begin{dummyenv}
\newcommand*{\scopedcommand}{Do stuff}
\scopedcommand % This works
\end{dummyenv}


The two arguments to newenvironment are the code to insert before the content of the environment, and after. Leaving them blank essentially defines an environment that does nothing.

Therefore, the following won't compile:

\documentclass[a4paper]{article}

\newenvironment*{dummyenv}{}{}

\begin{document}
\begin{dummyenv}
\newcommand*{\dummycmd}{This is scoped}
\dummycmd
\end{dummyenv}
\dummycmd
\end{document}


Unless you comment out the second dummycmd.

EDIT: Also, meant to say: You can also use the TeX primitives \begingroup and \endgroup for this. They form what TeX calls a 'semi-simple' group, and are not interchangeable with {...}.

EDIT 2: As @tohecz reminded me in the comments, the correct way to do this (if you really want an environment for whatever reason) is to use

\begin{@empty}
\end{@empty}


Any of the other solutions will work too, however, this is cleaner than defining a new environment.

-
You can use \begin{@empty} for this. Just remember that you cannot use \begin{relax} because \relax behaves like a non-defined thingy in these contexts ;) –  yo' Feb 25 '13 at 23:27
@tohecz Absolutely right; I forgot all about @empty. I'll update the answer — thanks! –  Sam Whited Feb 25 '13 at 23:58