# command \equal{#1}{} produces error if compactitem is in argument

I want to check if a variable is empty or not in a custom command. This works well, as long as it contains "normal text" but as soon as there is an itemize environment, I get an error message:

\documentclass[11pt, a4paper]{scrartcl}

\usepackage[ngerman]{babel}
\usepackage{ifthen, paralist}

\begin{document}

\begin{compactitem}
\item Item 1
\item Item 2
\end{compactitem}

\newcommand{\equalsNothing}[1]{
\ifthenelse{\equal{#1}{}}{true}{false}
}

\equalsNothing{}
\equalsNothing{1}

\equalsNothing{
\begin{compactitem}
\item Item 1
\item Item 2
\end{compactitem}
}

\end{document}


How can I change the \equalsNothing-command, so that it correctly works also with that itemize-content?

-

The arguments of \equal are fully expanded and this of course causes problems with fragile commands, such as \begin.

Say

\newcommand{\equalsNothing}[1]{%
\ifthenelse{\equal{\unexpanded{#1}}{}}{true}{false}%
}


In this way you look exactly whether there's something in the argument of \equalsNothing.

Don't forget to mask unwanted spaces with %. I'd also recommend to use xifthen instead of ifthen. For example, xifthen provides the test \isempty that doesn't expand its argument:

\newcommand{\equalsNothing}[1]{%
\ifthenelse{\isempty{#1}}{true}{false}%
}

-