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 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!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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).

share|improve this answer
    
great, thanks!Was it different in previous versions? –  Wilmerton Nov 14 '13 at 13:03

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.