I'm trying to add some overlays to a piece of code, and I'm defining it using moredelim
. However, when I use it on comments within the code, the moredelim
stops working.
What am I missing?
\documentclass{beamer}
\usepackage{listings}
\lstdefinestyle{cexample}{%
language=C++,
moredelim=**[is][\onslide<+->]{|}{|},
}
\begin{document}
\begin{frame}[fragile]{Work without comment}
\begin{lstlisting}[style=cexample]
char * const buffer[]; |comment 1|
char * const * buffer; |comment 2|
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Doesn't work with comments '//'}
\begin{lstlisting}[style=cexample]
char * const buffer[]; |//comment 1|
char * const * buffer; |//comment 2|
\end{lstlisting}
\end{frame}
\end{document}