2

I have a beamer frame with a large matrix. I want to add some annotations to it, for which I use tikz overlays. However, the matrix (I suppose that it is the resizebox, actually) changes its width from frame to frame, which is highly undesired. Here is a minimum working example:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node(#1) {};}

\frame
{
    \resizebox{\textwidth}{!}
    {
        $\left(\begin{array}{rrrrrrrrrrrrrrrrrrrrrrrrrr}a & b & c & d & e & f & g & h & i & j & k & l & m & n & o & p & q & r & s & t & u & v & w & x & y & z\\ a & \tikzmark{b}b & c & d & e & f & g & h & i & j & k & l & m & n & o & p & q & r & s & t & u & v & w & x & y & z\end{array}\right)$
        \only<1>
        {
            \begin{tikzpicture}[overlay,remember picture,-latex]
                \draw[->] (b.east) -- +(1,-0.5) node[below] (btext) {This is b};
            \end{tikzpicture}
        }
    }
    \only<2>
    {
        \begin{tikzpicture}[overlay,remember picture,-latex]
            \node[at=(btext)] {More text};
        \end{tikzpicture}
    }
}

\end{document}

The (undesired) effect looks like this:

enter image description here

I am using the overlay because I do not want the matrix to change its width from slide to slide. I am aware that my second text is outside of the resizebox - I want it to be overlayed with normal text size, i.e., so that it is unaffected by the resizebox.

What can I do to keep the width of the matrix unchanged between slides?

1 Answers1

4

You have a lot of spurious spaces. When I remove them all, it works fine.

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node(#1) {};}

\frame
{%
    \resizebox{\textwidth}{!}
    {%
        $\left(\begin{array}{rrrrrrrrrrrrrrrrrrrrrrrrrr}a & b & c & d & e & f & g & h & i & j & k & l & m & n & o & p & q & r & s & t & u & v & w & x & y & z\\ a & \tikzmark{b}b & c & d & e & f & g & h & i & j & k & l & m & n & o & p & q & r & s & t & u & v & w & x & y & z\end{array}\right)$%
        \only<1>
        {%
            \begin{tikzpicture}[overlay,remember picture,-latex]
                \draw[->] (b.east) -- +(1,-0.5) node[below] (btext) {This is b};
            \end{tikzpicture}%
        }%
    }%
    \only<2>
    {%
        \begin{tikzpicture}[overlay,remember picture,-latex]
            \node[at=(btext)] {More text};
        \end{tikzpicture}%
    }%
}

\end{document}
Ulrike Fischer
  • 327,261
  • Thanks, that was it. I never quite understood why certain lines are o.k. without the % and why some are not. I'll certainly have to read up on that. – Andreas Unterweger May 05 '16 at 14:10
  • 2
    @AndreasUnterweger You can start with http://tex.stackexchange.com/questions/7453/what-is-the-use-of-percent-signs-at-the-end-of-lines – Ignasi May 05 '16 at 14:21