TikZ set node label position more precisely
You can define the direction of the label by using label=<angle>:<label text>
. To specify the distance on a per node distance, you have to supply it to the label
options: label={[label distance=<distance>]<angle>:<label text>}
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
every node/.style=draw,
every label/.style=draw
]
\node [label={[label distance=1cm]30:label}] {Node};
\end{tikzpicture}
\end{document}
Good to know all the other ways to do this, but I have always used xshift=<length>
, and yshift=<length>
to move a node
or label
.
The blue is the default, and the red is with the option [xshift=1.0cm, yshift=0.3cm]
, and the green (as suggested by percusse) is using an alternate syntax to specify the x and y shift as a vector [shift={(1.0,0.3)}]
.
Code:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[blue]
\node [label={Label}] {Node};
\end{tikzpicture}
\begin{tikzpicture}[red]
\node [label={[xshift=1.0cm, yshift=0.3cm]Label}] {Node};
\end{tikzpicture}
\begin{tikzpicture}[green]
\node [label={[shift={(1.0,0.3)}]Label}] {Node};
\end{tikzpicture}
\end{document}
The simplest way is to use another node. Like you wrote, the label is a node "label". In \path ... node[⟨options⟩](⟨name⟩)at(⟨coordinate⟩){⟨text⟩} ...;
the real label is ⟨text⟩
. Now it's easy to add a node and a new label without the label
option.
\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [draw,circle ] (a) { Real label};
\node at (a.60) {$\bullet$};
\node [draw] at ([shift={(95:1)}]a.60) {Second label};
\end{tikzpicture}
\end{document}
The only problem is that you need to give the name first node but you can do what you want. In the first version of TikZ, without the label
option it was the only way.