beamer icon indicating copy to clipboard operation
beamer copied to clipboard

overlay specification range by length

Open jlaurens opened this issue 3 years ago • 14 comments

\only<a-b>{bla bla bla} displays text from slide a to slide b The range is specified from the start to the end. The range could also be specified from its starting point and its length such that for example \only<a--n>{bla bla bla} would be equivalent to \only<a-(a+n-1)>{bla bla bla}

jlaurens avatar Sep 19 '21 08:09 jlaurens

That's \only<a-(n)>

josephwright avatar Sep 19 '21 09:09 josephwright

New feature I guess since it is not available in beamer 2021/05/26 v3.63

jlaurens avatar Sep 19 '21 10:09 jlaurens

@jlaurens It is available since version 0.92 from 2004, but you need a +, e.g. \only<2-+(2)>{f}

See section "9.6.4 Incremental Specifications" of the user guide for more information

Screenshot 2021-09-19 at 12 51 57

samcarter avatar Sep 19 '21 10:09 samcarter

It does not work because '+(...)' has side effects.

Next document creates 6 frames instead of 4

\documentclass{beamer}
\begin{document}
\begin{frame}
\insertslidenumber\\
\only<2-+(1)>{Should be from 2 to 2}
\only<2-+(2)>{Should be from 2 to 3}
\only<2-+(3)>{Should be from 2 to 4}
\end{frame}
\end{document}

jlaurens avatar Sep 19 '21 10:09 jlaurens

\documentclass{beamer}
\begin{document}
\begin{frame}

\Huge 
\insertslidenumber

\only<2>{Should be from 2 to 2}

\only<+(1)-+(2)>{Should be from 2 to 3}

\only<+(0)-+(2)>{Should be from 2 to 4}
\end{frame}
\end{document}

samcarter avatar Sep 19 '21 11:09 samcarter

That is not what I am asking for. Given a slide number a and a positive number n, I want some material to be displayed only from slide number a to slide number a+n-1.

This is useful in 2 different situations at least.

Actually, one is using for example \only<10-13>{From 10 to 13}

  • when we insert a slide before, we must change 10 to 11 and 13 to 14
  • when 10 is the result of a macro, then 13 must also be the result of a macro.

If we would have something like \only<10--4>{From 10 to 13}

  • when we insert a slide before, we must only change 10 to 11
  • when 10 is the result of a macro, then 13 is automatically computed

jlaurens avatar Sep 19 '21 11:09 jlaurens

Another syntax proposal.

Something like '\only<10-*(4)> {bla bla bla}' could mean "display bla bla bla 4 times starting at slide 10".

\only< -*(4)>{} could mean "display bla bla bla 4 times starting at slide \beamerpauses".

jlaurens avatar Sep 19 '21 14:09 jlaurens

@jlaurens You don't want a + in there: beamer interprets that as 'step and include the current frame number'. So for example

\only<4-.(4)>

for frames 4, 5, 6, 7, not

\only<4-+(4)>

(which will be off in frames 44, 45, 46, 47)

josephwright avatar Sep 19 '21 19:09 josephwright

https://www.texdev.net/2014/01/17/the-beamer-slide-overlay-concept/

josephwright avatar Sep 19 '21 19:09 josephwright

As I said the + syntax does not work, unfortunately, the . syntax does not work either.

\documentclass{beamer}
\begin{document}
\begin{frame}
\insertslidenumber\\
  \begin{itemize}
    \item<+(1)-> This is on the second and all following slides
    \item<+(1)-> This is on the third and all following slides
    \item<+-> This is also on the third and all following slides
  \end{itemize}
\only<1-2>{On slides 1, 2 GOOD\\}
\only<1-.(2)>{On slides 1, 2 BAD\\}
\end{frame}
\end{document}

The text "On slides 1, 2 GOOD" appears on slides 1 and 2 as expected whereas the text "On slides 1, 2 BAD" appears on all the slides. The ...(...) overlay syntax seems to rely on the value of the beamerpause counter which is not what I am asking for.

jlaurens avatar Sep 21 '21 13:09 jlaurens

Your example is mixing explicit and +/. syntax, which is always 'interesting'. You've stepped the counter three times, so you'd need .(-2) in the example. I'd therefore go for

\documentclass{beamer}
\begin{document}
\begin{frame}
\insertslidenumber\\
  \begin{itemize}
    \item<+(1)-> This is on the second and all following slides
    \item<+(1)-> This is on the third and all following slides
    \item<+-> This is also on the third and all following slides
  \end{itemize}
\only<1-.2>{On slides 1, 2 GOOD\\}
\only<.(-2)-.(-1)>{On slides 1, 2 BAD\\}
\end{frame}
\end{document}

josephwright avatar Sep 21 '21 13:09 josephwright

This does not work. Given a and n two positive integers, the question is to replace the syntax <a-b> where b==a+n-1 by a unique syntax that only depends on a and n.

jlaurens avatar Sep 21 '21 14:09 jlaurens

It does not work because '+(...)' has side effects.

True but you can replace the second two + by . to avoid over-incrementing the counter, then I think it does what you want however more directly I guess you want

\documentclass{beamer}
\begin{document}
\begin{frame}
\insertslidenumber\\
\only<2-\the\numexpr2+0\relax>{Should be from 2 to 2}
\only<2-\the\numexpr2+1\relax>{Should be from 2 to 3}
\only<2-\the\numexpr2+2\relax>{Should be from 2 to 4}
\end{frame}
\end{document}

which explicitly is <2-n> with n being 0 1 and 2

davidcarlisle avatar Sep 21 '21 15:09 davidcarlisle

@davidcarlisle I cannot use the dot either. What I want is something like

\only<2-:(1)>{Should be from 2 to 2}
\only<2-:(2)>{Should be from 2 to 3}
\only<2-:(3)>{Should be from 2 to 4}

In each overlay specification above, the start of the range appears exactly once, as well as the length.

In the beamer overlay specification parser,

  1. <first>-:(<length>) is replaced by < first >-<last> where <last> == <first>+<length>-1
  2. when :(<length>) does not follow a dash, or no number is before the dash, then :(n) could act exactly like .(n).

jlaurens avatar Sep 21 '21 15:09 jlaurens