2

How to use \visible when its contents is enclosed by multlined which in turns contains nested \visible?

MWE

The following MWE does not compile because of multlined.

\documentclass[12pt,beamer,preview,multi={math},border=12pt]{standalone}
\usefonttheme[onlymath]{serif}
\usepackage{mathtools}
\newcommand{\foo}[1]{\visible<+->{#1}}
\begin{document}
\begin{standaloneframe}
    \begin{math}
        \displaystyle
        \begin{aligned}
        \foo{\int_a^b}\foo{f(x)}\foo{\, \mathrm{d}x}
            \foo{&=}\foo{F(b)}\foo{-F(a)}\\
            \foo{&=}\foo{\cos a}\foo{\sin b}\foo{+}\foo{\sin a }\foo{\cos b}\\
            \foo{&=}
                \foo{\begin{multlined}[t]}
                \foo{ax^4}\foo{+bx^3}\\\foo{+cx^2}\foo{+dx}\foo{+e}\\
                \foo{\end{multlined}}
        \end{aligned}
        \end{math}
\end{standaloneframe}
\end{document}

The code above was stolen from Marmot's idea.

Edit

If I removed the foo for both \begin{multlined} and \end{multlined}, I got blank frames inserted as you can see from the following animation. Some delays represents the blank frames.

\documentclass[12pt,beamer,preview,multi={math},border=12pt]{standalone}
\usefonttheme[onlymath]{serif}
\usepackage{mathtools}
\newcommand{\foo}[1]{\visible<+->{#1}}
\begin{document}
\begin{standaloneframe}
    \begin{math}
        \displaystyle
        \begin{aligned}
        \foo{\int_a^b}\foo{f(x)}\foo{\, \mathrm{d}x}
            \foo{&=}\foo{F(b)}\foo{-F(a)}\\
            \foo{&=}\foo{\cos a}\foo{\sin b}\foo{+}\foo{\sin a }\foo{\cos b}\\
            \foo{&=}
                \begin{multlined}[t]
                \foo{ax^4}\foo{+bx^3}\\\foo{+cx^2}\foo{+dx}\foo{+e}\\
                \end{multlined}
    \end{aligned}
        \end{math}
\end{standaloneframe}
\end{document}

enter image description here

  • 1
    You cannot wrap \begin{...} and \end{...} in separate macros, they must be within the same \visible. – user36296 Mar 10 at 12:41
  • @samcarter: I thought so but how? – Artificial Hairless Armpit Mar 10 at 12:44
4

This is a combination of two problems:

  • the \begin{} and \end{} of an environment must be on the same overlay

  • multiline processes the code two times. This is a problem if you combine this with your use of <+-> because twice as many overlays are created than necessary.

I suggest the following workaround:

\documentclass[12pt,beamer,preview,multi={math},border=12pt]{standalone}
\usefonttheme[onlymath]{serif}
\usepackage{mathtools}
\newcommand{\foo}[1]{\visible<+->{#1}}


\begin{document}
\begin{standaloneframe}
    \begin{math}
        \displaystyle
        \begin{aligned}
        \foo{\int_a^b}\foo{f(x)}\foo{\, \mathrm{d}x}
            \foo{=&}\foo{F(b)}\foo{-F(a)}\\
            \foo{=&}\foo{\cos a}\foo{\sin b}\foo{+}\foo{\sin a }\foo{\cos b}\\
            \foo{=& }
            \foo{ ax^4}\foo{+bx^3}\\
            \foo{&+cx^2}\foo{+dx}\foo{+e}\\
        \end{aligned}
        \end{math}
\end{standaloneframe}
\end{document}

enter image description here

  • be careful with a strange spacing before the first term of the polynomial. – Artificial Hairless Armpit Mar 10 at 13:00
  • @TheInventorofGod well, insert some space. I'm sure this is easier than adapting multiline to play nice with beamer overlays.... Or change the point of alignment from the = sign to the start of the right hand term – user36296 Mar 10 at 13:04
  • Why did use =& instead of &=? Are you sure? – Artificial Hairless Armpit Mar 10 at 15:22
  • @TheInventorofGod I swapped & and = because otherwise the + would be aligned with the equal signs and I though you wanted it to be aligned with the right hand parts of the equation? – user36296 Mar 10 at 15:26
  • If you swap then the spacing after = becomes uneven (compared to the left one). – Artificial Hairless Armpit Mar 10 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.