Suppose one defines coordinates a
and b
. One may draw a line connecting these two coordinates (\draw (a) -- (b)
). Suppose one desires to draw a line that is shifted upward 1 unit relative to a
and b
. A first guess is the command \draw (a){}+(0,1) -- (b){}+(0,1)
. This command, however, connects the point a+(0,1)
to the point b
, presumably because addition is subsequent to the draw command. How does one obtain the desired result (drawing from a+(0,1)
to b+(0,1)
?
MWE:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[fill] (0,0) circle (2pt) coordinate (a);
\draw[fill] (5,0) circle (2pt) coordinate (b);
\draw (a) -- (b);
\draw (a){}+(0,1) -- (b){}+(0,1);
\end{tikzpicture}
\end{document}
Edit: How does one draw coordinates at a point shifted relative to the arithmetic average of the coordinates of two points (something akin to \node at ($(((s1)+(s2))/2)+(0,1)$)
).
Best Answer
You can try this, using the
calc
library (See Section 13.5 Coordinate Calculations of the pgf manual):To answer the follow-up, you can use partway modifiers (Section 13.5.3 of the manual). For example, the meaning of
is "the coordinate that is three quarters on the way from (1,2) to (3,4)." A little complete example: