TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why this code works


\draw (pi,.5)--(pi,-.5)--(-pi,-.5)--(-pi,.5)--cycle node[above]{vv} ;


But when I change the node[above] to node[above,pos=.5] I get error?

share|improve this question

It's because cycle makes the path timer undefined. This is a soft spot of TikZ that it cannot move over corners when computing the percentage of the path for node placement. It automatically looks for the last input segment to interpolate e.g. in your example the left side of the rectangle. Here is the problem removed but the functionality is still limited. Also there might be another reason why the developers of TikZ decided to make it as such so better to stay away.


\def\tikz@close c{%
  \pgfutil@ifnextchar o{\tikz@collect@coordinate@onpath\tikz@lineto@mid c}% oops, a coordinate
  {\tikz@@close c}}%
\def\tikz@@close cycle{%
%  \let\tikz@timer=\@undefined% <-- This is the problem ! Uncomment to have the problem again.

\draw (pi,.5)--(pi,-.5)--(-pi,-.5)--(-pi,.5)--cycle node[above,pos=0.5]{vv} ;

enter image description here

You also need to avoid such constructions and place the node in the corresponding input segment. For example:

\draw (pi,.5)--(pi,-.5) node[pos=0.5]{vv} --(-pi,-.5)--(-pi,.5)--cycle ;

Lastly, it might be the case that you wanted to demonstrate this problem but just for the sake of completeness, use rectangle instead of going around four corners and cycle.

share|improve this answer

Your Answer


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.