2

I have a problem just getting started with TikZ. I want to use it in beamer but I have the same problem with minimal so I just give the beamer test.

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}{}
\tikz\node (A){$A$};\hspace{1cm}
\tikz\node (B){$B$};\hspace{1cm}
\tikz\node (C){$C$};
\begin{tikzpicture}
       \draw[<->] (A) -- (B);
       \draw[<->] (A) -- (C);
\end{tikzpicture}
\end{frame}
\end{document}

And here is the result: result

What could be the problem? Thanks!

3

The problem is that the scope of node names is (roughly speaking) the surrounding tikzpicture, so when you issue the \draw commands the names are not attached to any entity. There is no need to space the nodes outside the tikzpicture as you can directly do:

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}{}
    \begin{tikzpicture}
       \node (A){$A$};
       \node (B) at (1,0) {$B$};
       \node (C) at (2,0) {$C$};
       \draw[<->] (A) -- (B);
       \draw[<->] (B) -- (C);
    \end{tikzpicture}
\end{frame}
\end{document}

There are cases where you need to reference names outside the picture and that's what the option remember picture is for (see Section 16.13 of the manual).

  • great, thanks!Was it different in previous versions? – Wilmerton Nov 14 '13 at 13:03

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.