I'm trying to draw a tree with tikz
I've tried this:
\documentclass{report}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[nodes={draw, circle}]
\path
(0, 0) node (1a) {5};
(-2, -1) node (2a) {12};
\draw
(1a)--(2a)
\end{tikzpicture}
\end{document}
I get ! Package pgf Error: No shape named `2a' is known.
How can I fix it?
I would also like to tweak the links.
If I omit the \draw
part, only the first node is drawn. How can I draw 2 nodes without any link?
Is there any way to draw with a thicker line?
Best Answer
You are terminating the
\path
with a semicolon after making the1a
node but not starting a new path, so the secondnode
invocation does nothing.If you check the log the error is preceded by
indicating the
(-2, -1) node (2a) {12};
line is trying to be printed rather than parsed.You also need a semicolon to terminate the
\draw
command.Depending on your use case though
might be easier to write.