6

When using Claudio Fiandrino's fantastic aobs-tikz library, I realized that there is an interesting feature in connection with matrices from the matrix library: if one places matrices with \matrix, their delimiters won't hide. This is illustrated by the following MWE, in which I also present two possible workarounds.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}
\usetikzlibrary{positioning} %<- not important here
\begin{document}
 \begin{frame}[t]
 \frametitle{Matrix delimiters won't hide}
  \begin{tikzpicture}[ampersand replacement=\&]
   \matrix [matrix of nodes,left delimiter=(,right delimiter=)] (m1)
     {
       a \\
       b \\
     };
   \matrix [right=1cm of m1,visible on=<2->,matrix of nodes,
    left delimiter=(,right delimiter=)] (m2)
     {
       x \\
       y \\
     };
   \matrix [right=1cm of m2,visible on=<3->,matrix of nodes] (m3)
     {
       u \\
       v \\
     };
   \begin{scope}[visible on=<4->]  
    \matrix [right=1cm of m3,matrix of nodes,left delimiter=(,right delimiter=)] (m4)
      {
        p \\
        q \\
      };
   \end{scope}
   \path[visible on=<5->] 
   node[matrix,right=1cm of m4,matrix of nodes,left delimiter=(,right delimiter=)] 
   (m5)
     {
       r \\
       s \\
     };
   \node[visible on=<6->,matrix,right=1cm of m5,matrix of nodes,left delimiter=(,right delimiter=)] 
   (m6)
     {
       c \\
       d \\
     };  
  \end{tikzpicture}
 \end{frame}
\end{document}

enter image description here

The vector x y illustrates the problem: the brackets won't hide, even though the matrix is supposed to be visible only from overlay 2 on, i.e. when x and y appear. u v shows that matrices without delimiters are fine. p q and r s indicate two possible workarounds: either use a scope or just \path[visible on=<...>] node[matrix ,.... Finally, c d shows that
\node[visible on=<...>,matrix,... has the same problem as \matrix[visible on=<...>,....

COMMENT ON THE ORIGIN OF THE PROBLEM: The problem is that the delimiters are not really part of the matrix (node), as the following MWE shows.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,fit}
\usetikzlibrary{positioning} %<- not important here
\begin{document}
 \begin{frame}[t]
 \frametitle{Comment on the origin of the problem}
  \begin{tikzpicture}[ampersand replacement=\&]
   \matrix [matrix of nodes,left delimiter=(,right delimiter=)] (m1)
     {
       a \\
       b \\
     };
   \matrix [right=1cm of m1,matrix of nodes,
    left delimiter=(,right delimiter=)] (m2)
     {
       c \\
       d \\
     };
   \path[local bounding box=m3] node[matrix,right=1cm of m2,matrix of nodes,
    left delimiter=(,right delimiter=)] 
     {
       u \\
       v \\
     };  
   \path[local bounding box=m4] node[matrix,right=1cm of m3,matrix of nodes,
    left delimiter=(,right delimiter=)] 
     {
       x \\
       y \\
     }; 
   \node[fit=(m1)(m2),draw]{};    
   \node[fit=(m3)(m4),draw]{};
  \end{tikzpicture}
 \end{frame}
\end{document}

enter image description here

QUESTION: Is there a better workaround or even a solution using a simple \tikzset{...}?

0
3
+500

Some other possible workarounds (not saying they are better):

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}
\usetikzlibrary{positioning} %<- not important here
\begin{document}
 \begin{frame}[t]
 \frametitle{Matrix delimiters won't hide}

  \begin{tikzpicture}[ampersand replacement=\&]
   \matrix [matrix of nodes,left delimiter=(,right delimiter=)] (m1)
     {
       a \\
       b \\
     };

   \tikzset{every delimiter/.append style={visible on=<2->}}
   \matrix [right=1cm of m1,visible on=<2->,matrix of nodes,
    left delimiter=(,right delimiter=)] (m2)
     {
       x \\
       y \\
     };
   \visible<3->{
      \matrix [right=1cm of m2,matrix of nodes,
       left delimiter=(,right delimiter=)] (m2)
        {
          x \\
          y \\
        };
   } 
  \end{tikzpicture}
 \end{frame}
\end{document}
0

Your Answer

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