4

In the beamer documentation you can find macros that have two <⟨overlay specification⟩>'s. For example:

\alt<⟨overlay specification⟩>{⟨default text⟩}{⟨alternative text⟩}<⟨overlay specification⟩>

However, I couldn't find an explanation what is the difference? It seems like it is only possible to use one <(overlay specification)>. Is it some backwards compatibility issue? In the following MWE seems I could not spot the difference:

\documentclass{beamer}
\begin{document}
\begin{frame}
  \frametitle{Foo}
  \begin{itemize}[<+->]
  \item Foo
  \item \alt<2>{Hello}{World}
  \item Bar
  \end{itemize}
\end{frame}
\begin{frame}
  \frametitle{Bar}
  \begin{itemize}[<+->]
  \item Foo
  \item \alt{Hello}{World}<2>
  \item Bar
  \end{itemize}
\end{frame}
\end{document}

So what is the deal here?

7
  • Not sure at all, but I think this design choice allows more flexibility at user side to set overlay specifications. Commented Apr 9, 2014 at 7:41
  • Probably only Till can answer this! Reading the code, I suspect you are right on the 'back compatibility' idea, but there are no comments.
    – Joseph Wright
    Commented Apr 9, 2014 at 7:41
  • @ClaudioFiandrino: Can you elaborate? If the result is the same then where is the flexibility?
    – Dror
    Commented Apr 9, 2014 at 7:42
  • I mean that according to personal programming style, somebody \alt<>{}{} while others might prefer \alt{}{}<>. Allowing both versions provides a choice to users. Commented Apr 9, 2014 at 7:46
  • 1
    @ClaudioFiandrino LaTeX (at the kernel level) is all about trying to provide a consistent interface. All of the bemear docs show that it extends standard LaTeX syntax by adding the <...> arg as the first optional argument to commands. So adding it at the end as well is not good.
    – Joseph Wright
    Commented Apr 9, 2014 at 8:40

1 Answer 1

4

If I understand it correctly, it's for ease of your job. The natural place for an optional argument is is of course before all the other arguments:

\alt<2>{this}{that}

However, imagine you define a macro with overlays to be specified when used, then you can do:

\newcommand\macro{\alt{this}{that}}
...
\macro<2>

Of course, there's another (maybe more proper) way how to achieve this, cf. beameruserguide.pdf, p. 86, paragraph \renewcommand<> and Reverse of \only:

\newcommand<>\macro{\alt#1{this}{that}}
...
\macro<2>

But it's a matter of taste which one do you prefer. I find optional arguments after mandatory ones strange, so I certainly use the latter option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .