Search code examples
latexbeamer

Showing entries of a vector one after another


Overflow Community! I'm working on a Latex Beamer - Document and I cant think of a nice looking solution for what I am planning to do.

So I have a vector, which entries I want to show one after another. But the right bracket is missing in the first steps when I'm using \pause in my equation, which looks quite ugly. So what I want is both brackets to be visible, while the vectors entries are not. Do you guys have a solution for this?

\documentclass[mathserif, 10pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,bm,amsthm,graphicx,skmath}
\begin{document}
\begin{frame}
    \frametitle{Function $g$}
\[
g(x)=\begin{pmatrix} 
g_1(x)\\ \vdots \\ g_n(x) \\ g_{n+1}(x) \\ \vdots \\ g_{2n}(x) \\ g_{2n+1}(x)\\ \vdots \\ g_{3n}(x) 
\end{pmatrix} 
\pause = \begin{pmatrix} 
x_1^2 + x_{n+1}^2 - 1 \\ \vdots \\ x_n^2 + x_{2n}^2 - 1\\ \pause -x_{2n+1}\\ \vdots \\ -x_{3n} \\ \pause x_{2n+1}-L \\ \vdots \\x_{3n}-L
\end{pmatrix}
\]
\end{frame}
\end{document}

Solution

  • \pause is a very crude command, for more fine control you can use commands like \visible<...>{...}.

    Please note that you don't need graphicx, amsmath or amsthm with beamer and that the mathserif option is obsolete. This should have caused a warning with a detailed description how this option should be replaced, please don't ignore such warnings.

    \documentclass[10pt]{beamer}
    \usepackage[utf8]{inputenc}
    \usefonttheme[onlymath]{serif}
    \usepackage{amsmath,bm,amsthm,
    %graphicx,
    skmath}
    \begin{document}
    \begin{frame}
        \frametitle{Function $g$}
    \[
    g(x)=\begin{pmatrix} 
    g_1(x)\\ \vdots \\ g_n(x) \\ g_{n+1}(x) \\ \vdots \\ g_{2n}(x) \\ g_{2n+1}(x)\\ \vdots \\ g_{3n}(x) 
    \end{pmatrix} 
    \visible<2->{ = \begin{pmatrix} 
    x_1^2 + x_{n+1}^2 - 1 \\ \vdots \\ x_n^2 + x_{2n}^2 - 1\\ \visible<3->{ -x_{2n+1}}\\ \visible<3->{\vdots} \\ \visible<3->{-x_{3n}} \\ \visible<4->{x_{2n+1}-L} \\ \visible<4->{\vdots} \\\visible<4->{x_{3n}-L}
    \end{pmatrix}}
    \]
    \end{frame}
    \end{document}