Generallistings: Overlay

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
replika
Posts: 2
Joined: Mon May 11, 2009 5:07 pm

listings: Overlay

Post by replika »

Hi there.
I have defined a listings block:

Code: Select all

\lstdefinestyle{mystyle}{...}%
{\lstnewenvironment{mylst}[1][]{%
  \lstset{style=mystyle}%
  \lstset{#1}%
}{}%
...
\begin{mylst}[numbers=left]
...
\end{mylst}
Now, I am trying to use overlay in listings environments in my presentation (beamer).
I googled a solution that using moredelim (worked fine, very interesting)

Code: Select all

\lstset{
  moredelim=[is][\alert<1>]{/1+}{+/},
  moredelim=[is][\alert<2>]{/2+}{+/}
}
\begin{mylst}
/1+Line1+/
/2+Line2+/
\end{mylst}
My questions are:
1. If I used my env like this, pdflatex push errors

Code: Select all

\begin{mylst}[moredelim=[is][\alert<2>]{/2+}{+/}]
\end{mylst}
It seems a mistake in my arguments when passing (may be something did not be escaped), but I do not know how to fix it?

2. I intend to define a shortcut to create new delim for overlay, something that works like this:

Code: Select all

\newcommand{\mydelim}[1]{%
  moredelim=[is][\alert<#1>]{/#1+}{+/}
}
% use alert<1>, alert<2->, alert<3>
\begin{mylst}[\mydelim{1},\mydelim{2-},\mydelim{3}]
...
\end{mylst}
But have no success.

Please help. Thanks in advance

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: listings: Overlay

Post by josephwright »

Please post a full example. Are you using the fragile option for your slides?
Joseph Wright
replika
Posts: 2
Joined: Mon May 11, 2009 5:07 pm

listings: Overlay

Post by replika »

josephwright wrote:Please post a full example. Are you using the fragile option for your slides?
Yes, of course.
My code just works fine if using lstset (the second code block in the first post), but not if I pass as a parameter of "mylst" environment (third code block in the first post)
Post Reply