# Expansion of Overlay Specification Macro

To provide overlay specifications via a macro I have to use \expandafter\item\foo text, where \foo is something like <+->. When I do this often the \expandafter becomes bothersome. Is there a way to get rid of the \expandafter?

What I guess would work is to renew the overlay specification commands and add an \expandafter? Will this break anything?

Is there an easier way to ensure correct handling of the overlay macro, e.g. a beamer parameter or something?

Edit1: It seems when I instead use \item<\foo> text and let \foo be something like +- things work. I will use this and see if that answers the question.

Edit2: Below I added a MWE

\documentclass{beamer}
\begin{document}
\begin{frame}
\def\foo{<+>}
\def\bar{<+->}
\begin{itemize}
\expandafter\item\foo First
\expandafter\item\bar Second
\end{itemize}
\end{frame}
\end{document}

• Maybe \def\xitem{\expandafter\item}?? – Steven B. Segletes Apr 15 '15 at 11:51

I wouldn't do it, but here it is. I'd much prefer giving the overlay options to \begin{itemize}: how many cases do you have where you'd like to apply this?

\documentclass{beamer}

\makeatletter
% similar to \@ifnextchar, tests if the next token is a control sequence
\newcommand{\@ifnextcs}[2]{%
\def\reserved@a{#1}\def\reserved@b{#2}%
\futurelet\@let@token\@ifncs
}
\def\@ifncs{%
\ifx\@let@token\@sptoken
\let\reserved@c\@xifncs
\else
\if\noexpand\@let@token\relax
\let\reserved@c\reserved@a
\else
\let\reserved@c\reserved@b
\fi
\fi
\reserved@c
}

\let\ody@item\item
\def\item{\@ifnextcs{\expandafter\ody@item}{\ody@item}}
\makeatother

\begin{document}

\begin{frame}
\def\foo{<+>}
\def\bar{<+->}
\begin{itemize}
\item\foo First
\item\bar Second
\end{itemize}
\end{frame}
\end{document}


A different solution would be, of course, using \xitem defined by

\newcommand{\xitem}{\expandafter\item}

• I will try to give the use case later. – Heinrich Ody Apr 15 '15 at 15:16