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 tried the following codesnipped:

\begin{frame}
\begin{tikzpicture}
\tikzstyle{every node} = [draw, align=center,circle, scale = 0.5, thick]
\begin{tabular}{ccc}
\tikz\node (n1) {N1}; &
& 
\tikz\node (n2) {N2}; \\
& 
\tikz\node (n3) {N3};& 
\tikz\node (n4) {N4}; \\
\tikz\node (n5) {N5}; & 
\tikz\node (n6) {N6}; & 
\tikz\node (n7) {N7};\\
\end{tabular}

\path<1>[blue,->] (n1.south) edge [out= 60, in= 135] (n2.north west);
\path<2>[red,->] (n1.south) edge [out=-70, in=-110] (n3.south);
\end{tikzpicture}
\end{frame}

i does not behave as i expect it to. The paths do not get placed at the nodes but rather somewhere strange.

enter image description here

How can i fix this and still arrange the notes neatly like they are arranged now?

share|improve this question
1  
are you sure this has anything to do with beamer? I tried your code in an article and got the same 'unexpected' result... –  cmhughes Jan 25 '13 at 18:35
4  
The reason is due to a few problems. First tabular inside a tikzpicture should not work due to various text resets. So you need to take the tabular out. But then you still need to reference each individual tikzpicture and those require the remember picture,overlay mechanism or you can search for tikzmark word on this site. Lastly you might be better off if you just use a matrix node with one tikzpicture in one shot. –  percusse Jan 25 '13 at 20:26
add comment

1 Answer

up vote 4 down vote accepted

I think this is the perfect job for a matrix of nodes. Be warned however that inserting tikz matrices in a beamer frame require the [fragile] option.

This is the code:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}
\tikzstyle{every node} = [draw, align=center,circle, scale = 0.5, thick]
\node[draw=none, matrix of nodes, row sep=1em, column sep=1em] (N) {
N1 &    & N2 \\
   & N3 & N4 \\
N5 & N6 & N7 \\
};
\path<1>[blue,->] (N-1-1.south) edge [out= 60, in= 135] (N-1-3.north west);
\path<2>[red,->]  (N-1-1.south) edge [out=-70, in=-110] (N-2-2.south);
\end{tikzpicture}
\end{frame}
\end{document}

And this the result:

Result

Note that the code only gives a name (N) to the \matrix node. Automatically all the cells of the matrix have also a name, which is the name of the matrix followed by the row and column number.

You can also give particular names to some of the nodes, using the following syntax:

\node[draw=none, matrix of nodes, row sep=1em, column sep=1em] (N) {
|(N1)| N1 &           & |(N2)| N2 \\
          & |(N3)| N3 & |(N4)| N4 \\
|(N5)| N5 & |(N6)| N6 & |(N7)| N7 \\
};
\path<1>[blue,->] (N1.south) edge [out= 60, in= 135] (N2.north west);
\path<2>[red,->]  (N1.south) edge [out=-70, in=-110] (N3.south);

In each cell you can specify anything between | and that is passed to the \node being built. You can use this also to pass [options].

share|improve this answer
    
If you switch to ampersand replacement=\& and use \& as the column separator you can skip the fragile requirement. –  percusse Jan 26 '13 at 1:38
add comment

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.