Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
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. –  Jubobs 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 Answer 1

up vote 1 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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