Consider the following TikZ
code:
\filldraw[fill=black!40!white,thick] (0,1.5) node[above left] {start} rectangle (3.2,2) node[below right] {end} node [midway] {cp} ;
It produces a rectangle at the required co-ordinates, with text cp
inside the rectangle. I require text labels to the left and the right of the rectangle. I have attempted to produce these with the text attached to the above left
and below right
nodes. However, the end
label is positioned slightly lower than the start
label. How can I fix this, or, is there a better/easier way to position text next to rectangles. I have looked through the tutorials in the first section of the 700+ TikZ
manual.
Edit: Additional information in response to percusses's answer below:
\filldraw[fill=black!40!white,thick] (0,2.5) rectangle (3.2, 3) node [midway] {cp} ;
\node[fill=black!40!white,thick,draw,minimum height=0.5cm,minimum width=3.2cm,label=0:end,label=west:start] at (0,1.5) {cp};
Note the different x positions. Your code (the second line above) places the entire structure such that start
is positioned at position 0. For some reason, the structure produced by my code is shifted to the right so that it starts in the middle of the rectangle relative to yours.
Best Answer
The manual is indeed long but it's very well structured so you can skip many irrelevant parts. For this specific example, you can use a node and put labels around it.