2

I like the idea of defining a bunch of coordinates and then creating the desired diagram from them, but now I have the following problem. The MWE below demonstrates it: the arrows connecting the two nodes are partially hidden by the contents of the nodes. I want to only reveal the diagram in stages (via \onslide) which is why I havn't defined the node directly with the coordinate.

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}{MWE}

\begin{tikzpicture}

\foreach \y in {0,1,...,9}
 {
  \coordinate (A\y) at (0,{-1*\y});
  \coordinate (B\y) at (7,{-1*\y});
 }

\onslide<+->{\draw (A0) node{aaaa};}
\onslide<+->{\draw (A1) node{bbbb};}
\onslide<+->{\draw (A2) node{cccc};}
\onslide<+->{\draw[->] (A2)--(B2) node{dddd};}

\end{tikzpicture}

\end{frame}
\end{document}
  • 1
    A quick fix, in this case, would be to use shorten, as in \onslide<+->{\draw[->,shorten >=20pt,shorten <=20pt] (A2)--(B2) node{dddd};} – Gonzalo Medina May 4 '13 at 13:34
  • 1
    You could use [anchor=east] for nodes A0, A1 and A2 and [anchor=west] for node B2. – jub0bs May 4 '13 at 13:38
  • @Jubobs I did what you suggest and it works. Many thanks. – Geoff May 4 '13 at 13:52
1

The easiest way would be to use named node instead of the coordinates that helped you placed the nodes, simply chains and/or our favorite visible on style.

Code A

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}{MWE}
\begin{tikzpicture}
\foreach \y in {0,1,...,9}
 {
  \coordinate (A\y) at (0,{-1*\y});
  \coordinate (B\y) at (7,{-1*\y});
 }

\onslide<+->{\node at (A0) {aaaa};}
\onslide<+->{\node at (A1) {bbbb};}
\onslide<+->{\node at (A2) (nA2) {cccc};}
\onslide<+->{\node at (B2) {dddd} edge[<-] (nA2);}

\end{tikzpicture}
\end{frame}
\end{document}

Code B1

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\begin{frame}{MWE}
\begin{tikzpicture}[node distance=1cm and 7cm,
                    start chain=going below,
                    on grid]

\onslide<+->{\node[on chain] {aaaa};}
\onslide<+->{\node[on chain] {bbbb};}
\onslide<+->{\node[on chain] (nA2) {cccc};}
\onslide<+->{\node[right=of nA2] {dddd} edge[<-] (nA2);}
\end{tikzpicture}
\end{frame}
\end{document}

Code B2

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{chains}
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt={#1{}{invisible}}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} 
    },
}
\begin{document}
\begin{frame}{MWE}
\begin{tikzpicture}[node distance=1cm and 7cm,
                    start chain=going below,
                    on grid]

\node[visible on=<+->,on chain] {aaaa};
\node[visible on=<+->,on chain] {bbbb};
\node[visible on=<+->,on chain] (nA2) {cccc};
\path[visible on=<+->] node[right=of nA2] {dddd} edge[<-] (nA2);
\end{tikzpicture}
\end{frame}
\end{document}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.