0

I am trying to change a node color of Tikz node with only option as:

\documentclass[10pt,xcolor=dvipsnames,xcolor=table]{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{frame}
    \centering
    \begin{tikzpicture}[sibling distance=12em, level distance=3em,
        every node/.style = {shape=rectangle, rounded corners,
          draw, align=center, font=\footnotesize,
    top color=Red, bottom color=Red, color=white}]]
    \node {Foo}
    child {node{Bar1}}
    \only<1>{child {node{Bar2}}
    \only<2>{child[top color=Blue] {node{Bar2}}
      child {node{bar21}}
    child {node{bar22}}};
  \end{tikzpicture}

\end{frame}
\end{document}

This works fine when no only thing is involved, but with only, its giving error:

Runaway argument?
\centering \begin {tikzpicture}[sibling distance=12em, level distance\ETC.
! File ended while scanning use of \frame.
<inserted text> 
                \par 
<*> mwe.tex

What I am doing wrong here? Please help.

BaRud
  • 2,179
  • 1
    There is a TikZ library for beamer overlay specifications. I just forget the name every time... – Skillmon May 01 '18 at 14:46
  • 1
    @Skillmon \usetikzlibrary{overlay-beamer-styles} :) – samcarter_is_at_topanswers.xyz May 01 '18 at 14:49
  • https://ctan.org/pkg/aobs-tikz – Skillmon May 01 '18 at 14:51
  • @samcarter thank you. Why must it have such a horrible name. I always think: It has beamer and overlay in its name. Must be tikz-beamer-overlay. No, wrong. Or perhaps... – Skillmon May 01 '18 at 14:52
  • @Skillmon Me too! I can only remember that the letters b, s, o and a are in the package name. I then usually use texdoc and try as many combinations of these until a pdf opens :) – samcarter_is_at_topanswers.xyz May 01 '18 at 14:56
  • @BaRud Could you please add an example code that shows how the second overlay should look like? (without the only) I tried to remove the \only from your code but I don't get any blue colour in the nodes. – samcarter_is_at_topanswers.xyz May 01 '18 at 15:06
  • @BaRud While you wait for an answer to this question, can you go back to your previous ones and look if the answers solve your problems and accept them, if they do? – samcarter_is_at_topanswers.xyz May 01 '18 at 15:07
  • Hi, thanks for your reply, the accepted answer of question https://tex.stackexchange.com/questions/6135/how-to-make-beamer-overlays-with-tikz-node solves my problem. – BaRud May 01 '18 at 15:13
  • @samcarter: you just asked for a mwe in a comment, not an answer. I agree mwe is necessary, but for that case, its very complicated to make one. so I leave that as of now. – BaRud May 01 '18 at 15:14

0 Answers0