These environments are part of the LaTeX kernel, and thus not easily changeable or tweakable without delving into the implementation. (See Ian's answer.) One solution would be to define your own command and use the ifthen
package:
\usepackage{ifthen}
\newcommand{\safeitemizecmd}[1]{%
\ifthenelse{\equal{#1}{}}{}{\begin{itemize}#1\end{itemize}}}%
}
Note that this solution expands the parameter #1
twice, just for checking if it's empty. You can avoid this by using \expandonce
from the etoolbox
package:
\usepackage{ifthen}
\usepackage{etoolbox}
\newcommand{\safeitemizecmd}[1]{%
\ifthenelse{\equal{\expandonce{#1}}{}}{}{\begin{itemize}#1\end{itemize}}}%
}
Then, \safeitemizecmd{\item ...}
would typeset an itemized environment, and \safeitemizecmd{}
would typeset nothing.
If you want to use an environment, use the command created above:
\newenvironment{safeitemize}{\safeitemizecmd\bgroup}{\egroup}
The \bgroup
and \egroup
commands are essentially equivalent to braces.
\trivlist\item\relax ... \endtrivlist