Consider the following MWE
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0)--(1,1) node[auto,midway] {$A$}
-- (2,0) node[auto,midway] {$B$};
\end{tikzpicture}
\end{document}
I am using auto
here to get automatic left/right positioning. However, I am not satisfied with the distance between the edge labels and the edge itself, which is a bit too large (my real example is a picture with much more nodes in it, so there is room for confusion if they are not very close).
Is there a way to alter this distance? I tried adding node distance=something
almost everywhere, but it seems to be ignored.
Best Answer
There's no gap between the nodes and the lines (
node distance
applies to a different positioning mechanism). You can see this if you activatedraw
for the nodesThere are two things you can do to move the text closer to the line: Either you decrease the
inner sep
, for example usinginner sep=1pt
, or you set theouter sep
to a negative value, for example usingouter sep=-3pt
: