1

Minimal example:

\begin{frame}

\newcommand \ovStepA 1 \newcommand \ovStepB 4 \newcommand \ovStepC 9

\newcommand \predOf[1] {% % ??? } \newcommand \succOf[1] {% % ??? }

\only<-\predOf\ovStepB>{visible until step B (excluded)} % should expand to \only<-3>{...} \only<\ovStepB->{visible from step B (included)}

\only<-\ovStepC>{visible up to step C (included)} \only<\succOf\ovStepC->{visible after step C (excluded)} % should expand to \only<10->{...}

\end{frame}

Do overlay specifications have a syntax for that (similarly to how Git lets you refer to the predecessor of HEAD as HEAD^, for instance), or otherwise how to have \predOf and \succOf run some basic arithmetic?

Maëlan
  • 256
  • https://tex.stackexchange.com/questions/154521/relative-overlay-specification-in-beamer perhaps? It seems you are trying to recreate the idea of relative overlays without using the tools in beamer. – Joseph Wright Apr 25 '22 at 06:07
  • 1
    Off topic: please don't use e.g. \newcommand \ovStepA 1, which relies on how \newcommand is defined to add the braces that TeX requires: this should be \newcommand\ovStepA{1}. – Joseph Wright Apr 25 '22 at 06:08
  • Off-topic (bis): TeX is so hopeless… Not only { } are not just parentheses, now I’m learning that spaces are significant syntax tokens. Why, why, why… – Maëlan May 10 '22 at 19:56

1 Answers1

2

You can use \inteval (from xfp pakage):

\documentclass{beamer}
\usepackage{xfp}
\newcommand\predOf[1]{\inteval{#1-1}}
\newcommand\succOf[1]{\inteval{#1+1}}
\begin{document}
\begin{frame}

\newcommand\ovStepA{1} \newcommand\ovStepB{4} \newcommand\ovStepC{9}

\only<-\predOf{\ovStepB}>{visible until step B (excluded)} \only<\ovStepB->{visible from step B (included)}

\only<-\ovStepC>{visible up to step C (included)} \only<\succOf{\ovStepC}->{visible after step C (excluded)} \end{frame} \end{document}

enter image description here

Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283