开发者

How to have a fixed size number that depends on the slide in latex beamer / tikz?

I have a tikz picture with a circle node which has a number inside. I want this number to change with the slides but to be of fixed size. (-> not mess up the circle).

This one isn't working, the circle gets as big as if i开发者_JAVA百科t has to hold all 3 numbers.

\tikz[baseline]
\node [fill=blue!20,draw,circle,anchor=base] (node1)
{
    \only<1-3>{3} \only<4-6>{8} \only<7->{11.5}
};

Here the values are 3 on slides 1-3, 8 on slides 4-6 and else 7.


I observed the following:

  • The spaces between \only{} are always rendered (\only, when not active, is a "zero-width character"; TeX does not discard spaces between characters)
  • Set the width of the text explicitly using "text width=...". This implicitly puts the content into a minipage.
  • Note that the "baseline" property does not work anymore as expected.
  • "text centered" ensures the alignment for the case that the content is not exactly "text-width"
  • The "overprint" environment only automatically determines the height of the content, not the width.

To conclude, this works for me (I tried it):

\tikz[baseline]
\node [fill=blue!20,draw,circle,anchor=base,text width=4ex,text centered,inner sep=0] (node1)
{
    \only<1-3>{3}\only<4-6>{8}\only<7->{11.5}
};

EDIT: This works with the correct baseline:

\tikz[baseline=(node1.base)]
    \node [fill=blue!20,draw,circle] (node1)
    {
        \begin{minipage}{4ex}
            \centering
            \only<1-3>{3}\only<4-6>{8}\only<7->{11.5}
        \end{minipage}
    };


There are a couple of ways to do this:

  • You could use a 'overlay' environment which calculates the maximum size needed.
  • You could use \makebox[width]{ }.
  • Or simply use the 'minimum width' and 'minimum height' options on the node.
  • ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜