\draw (0,0) -- node{a} (2,0) -- node{b} (2,1) -- node{c} (0,1) -- cycle;
I can't find a simple way to make a label on the last edge. What I want is something like
\draw (0,0) -- node{a} (2,0) -- node{b} (2,1) -- node{c} (0,1) -- node{d} cycle;
but it doesn't work.
\draw (0,0) coordinate(A) -- node{a} (2,0) -- node{b} (2,1) --
node{c} (0,1) coordinate(D) -- cycle;
\draw (A) -- node{d} (D);
This works, but seems too complicated for such a simple task and I think I'm missing something.
Best Answer
The problem is that the
cycle
option short circuits the system for putting nodes on paths. The usual path operations have a system whereby they record their path component so that TikZ can figure out where to put nodes afterwards. The--
(lineto) component is no exception to this. The problem is that thecycle
interrupts the lineto before it can record the necessary information.A fix would be to put this information back in. I don't know how robust this fix is, but it works for your example.