I can't get any of the verbatim environments (alltt, semiverbatim) to respect white space as soon as I place it in an overlay macro:
\documentclass{beamer}
\begin{document}
\begin{frame}[fragile]
\only<1>{\begin{minipage}{0.9\textwidth}
\begin{semiverbatim}
top level
2 spaces indent
4 spaces indent
\end{semiverbatim}
\end{minipage}};
\end{frame}
\end{document}
The above example typesets as follows, on a single line:
top level 2 spaces 4 spaces
According to this answer https://tex.stackexchange.com/a/32488/63936 this has something to do with verbatim not working inside macro parameters. However verbatim indentation does work inside some macros, for instance in tikz's \node, but only if the node has no overlay spec. So there is some strange interaction between overlays and verbatim processing. Possibly tikz does some magic to overcome issues, but it does not go us far as nodes with overlays. The solution presented in the answer linked above only works with the listings package.
Is there anyway to make the other verbatim environments work inside overlayed contents?
