4

In this TikZ code

\documentclass[tikz,border=1.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}

\begin{document}

\begin{tikzpicture}
\draw (0,0) -- node[midway,below,rotate=90] {label} (0,5);
\end{tikzpicture}

\end{document}

I would also like to set a custom distance between the label and the line.

I tried to set below = 5pt, but it moves the label down, towards the point (0,0): instead, I would like to move it towards right, increasing the distance between the label and the line.

How to do this?

1 Answer 1

4

something like this:

\documentclass[tikz,border=1.5cm]{standalone}
\usetikzlibrary{angles,quotes}

\begin{document}

\begin{tikzpicture}
\draw (0,0) -- node[below=5pt,sloped] {label} +(0,4);
\draw (2,0) -- node[right=5pt,anchor=north,rotate=90] {label} +(0,4);
\end{tikzpicture}

\end{document}

enter image description here

edit:

  • see the difference between how label is rotated in the above mwe and how you tried to rotate it;
  • rotating of nodes also rotates the meaning of above, right etc.;
  • using rotate option require to change the node options as shown for the second line;
  • it is sufficient to load tikz ones;
  • if you have a node in the middle of coordinates as in your example (and in the above mwe), it isn't necessary to explicitly define the position, so you can left out midway from the node options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.