to set a node on a line the usual way should be something like this:
\begin{tikzpicture}
% place nodes
\node[draw] at (0, 0) (a) {A};
\node[draw] at (5, 0) (b) {B};
\node[draw] at (0, -2) (c) {C};
\node[draw] at (5, -2) (d) {D};
% draw edges
\draw[] (a) -- (b) node[near start, above] {$x(kT)$};
\draw[] (c) -- (d) node[near start, above] {$y(kT)$};
\end{tikzpicture}
But here i find it a little bit annoying, that the position of the node depends on the length of the line (what i try to illustrate in the above example). What i want is, that the nodes are exactly on the same position. To achieve this i have to write this:
\begin{tikzpicture}
% place nodes
\node[draw] at (0, -4) (a2) {A};
\node[draw] at (3, -4) (b2) {B};
\node[draw] at (0, -6) (c2) {C};
\node[draw] at (5, -6) (d2) {D};
% draw edges
\draw[] (a2.east) -- (b2) node[at start, above right] {$x(kT)$};
\draw[] (c2.east) -- (d2) node[at start, above right] {$y(kT)$};
\end{tikzpicture}
So my question is, is there a more intuitive way to do such things (something like the near start
/at start
node option)?
Best Answer
Maybe this is too simplistic or not automatic enough for what you're really seeking, but I think based on the question text and comments that a simple
xshift=<shift-dimension>
will do. You can (optionally) wrap it into a style (here,near start abs
) so the distance can be adjusted globally if needed.