2

I'm curious by the two tikzpictures below behave differently.

\documentclass{article}
\usepackage{tikz} 

\begin{document}

\begin{tikzpicture} 
  \node[circle,draw,inner sep=2pt] (t1)  at  (0,0)   {};
  \node[circle,draw,inner sep=2pt] (t2)  at  (1,0.5) {};
  \node[circle,draw,inner sep=2pt] (t3)  at  (3,4)   {};
  \draw[color=red,line width=4pt] (t1) -- (t2) -- (t3) -- cycle;
\end{tikzpicture}
\hspace*{\fill}
versus
\hspace*{\fill}
\begin{tikzpicture} 
  \draw[color=blue,line width=4pt] (0,0) -- (1,0.5) -- (3,4) -- cycle;
\end{tikzpicture}

\end{document}

enter image description here

egreg
  • 1,121,712
A.Ellett
  • 50,533
  • cycle makes sense for points and coordinates but not on nodes. Add coordinate to the options of nodes with no inner sep and they are same. –  Dec 16 '13 at 23:53
  • If you use nodes, TikZ applies a little magic so that the lines are only connected to the border of the nodes. The red path consists of several move-tos and line-tos. The function of -- cycle is the same as in \path (<some coordinate>) -- cycle. You can either use coordinates instead of nodes, add (t1) instead of cycle or use .center with every node depending on what you want to do. The same problem arises if you want to fill that triangle which corners are the nodes. It won’t work because you only have two simple lines. – Qrrbrbirlbel Dec 17 '13 at 00:00

0 Answers0