# Conditional to test whether in an itemize

I'm using LaTeX to write manuscripts for plays, I've been looking a bit into conditional expressions. The reason is that I want comments in the manus, and I currently have two different commands for this: One for when in an itemize, and one for when not.

Is it possible to have an if/else, so that I don't need two commands?

You can check for the value of \@currenvir:

\documentclass{article}

\makeatletter
\def\itemizename{itemize}
\def\ifinitemize{%
\ifx\@currenvir\itemizename
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
\makeatother

\begin{document}

\begin{itemize}
\item Now we are \ifinitemize{in an itemize environment}{somewhere else}
\end{itemize}

Now we are \ifinitemize{in an itemize environment}{somewhere else}

\end{document}


I created a conditional command that executes the first or the second braced argument depending on the value of \@currenvir. This will not work, for example, if you nest some other environment inside the itemize because the value of \@currenvir will be updated.