1

The angles should appear on the second slide, but they don't.

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{angles}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\begin{document}
\begin{frame}

\hfill \begin{tikzpicture}


\onslide<+->{
\draw[scale=1.5,rotate=118] (0,0) coordinate (A)
        --++(1,0) coordinate (B)
        --++(120:2) coordinate (C)
        --cycle ;
}

\onslide<+->{%
    \begin{pgfonlayer}{background}
    \draw pic[%
        semithick,
        fill=blue!25,
        angle radius=.7cm
        ] {angle=A--C--B} ;
    \draw pic[%
        semithick,
        fill=red!25,
        angle radius=.7cm
        ] {angle=C--B--A} ;
    \end{pgfonlayer}
    }

\end{tikzpicture}\hfill\strut
\end{frame}
\end{document}
Tarass
  • 16,912
  • On my machine, the angles appear on both slides. Or am I misinterpreting the question? –  Jan 22 '18 at 19:24
  • They should appear only on the second. Comment the 2 pgfonlayer lines, it works fine. – Tarass Jan 22 '18 at 19:25
  • \only<2-> also works fine, commenting the layer commands work only if you're using the lonely \onslide<+->{}. –  Jan 22 '18 at 19:34
  • @marmot Commenting lines is to understand what I want. But in fact I want angles under the triangle for esthetic reasons. In can draw the angle before the triangle and let them appear on the 35th slide in my current work, but I don't want to count the slide. It's why I try to use <+-> for they appear on their turn on 35th or 36th... slide depending on circumstances. – Tarass Jan 22 '18 at 19:42
  • @marmot I can put the triangle in the onslide. See the edit. This on <2-> change nothing, angles are drawn from slide 1. – Tarass Jan 22 '18 at 19:44

1 Answers1

2

Instead of \onslide you could use the visible on option from https://tex.stackexchange.com/a/55849/36296 which is conveniently available via \usetikzlibrary{overlay-beamer-styles}.

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{angles}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\usetikzlibrary{overlay-beamer-styles}

\begin{document}
\begin{frame}

\hfill 
\begin{tikzpicture}

\draw[scale=1.5,rotate=118] (0,0) coordinate (A)
        --++(1,0) coordinate (B)
        --++(120:2) coordinate (C)
        --cycle ;

\begin{pgfonlayer}{background}
\draw pic[%
    semithick,
    fill=blue!25,
    angle radius=.7cm,
    visible on=<+(1)->
    ] {angle=A--C--B} ;
\draw pic[%
    semithick,
    fill=red!25,
    angle radius=.7cm,
    visible on=<+->
    ] {angle=C--B--A} ;
\end{pgfonlayer}

\end{tikzpicture}\hfill\strut
\end{frame}
\end{document}

enter image description here

  • Reading the answer on the link, I tried only instead of onslide and it works just fine, independetly of your answer. If you add this possibility alternatively with your answser, if will make a complete ansswer. tank you. – Tarass Jan 22 '18 at 19:52
  • @Tarass For the use inside a tikzpicture I don't like to use \only because it easily causes a jumping picture if the bounding box size changes between the overlays. (You're lucky that the angles are completely within the triangle, so you don't experience this problem) – samcarter_is_at_topanswers.xyz Jan 22 '18 at 20:01
  • I understand, and to prevent this I create an artificial rectangle as path not draw and use as bbx. Then I never think about juming image, And then, I can control that the text around the picture can overlap void space of the picture. Thank you for the remarque. – Tarass Jan 22 '18 at 20:04