# Changing display angle of a node label

I'm trying to draw a diagram in TikZ with 45-degree lines, and I want to label these lines in such a way that the text of the label is also angled at 45 degrees. However I'm also interested in how to set it to a general angle. Basic example:

\documentclass{report}
\usepackage{tikz}
\begin{document}
\draw[thick] (-3,3) -- (3,-3)
\end{document}


I want to create labels at either end of this line, which have been rotated -45 degrees from horizontal, and which lie above-right of the line. Can anybody help me, please?

-
Welcome to TeX.SX! Please add a minimal working example (MWE) that shows your attempts. It will be much easier for us to reproduce your situation and provide a solution when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Peter Jansson May 26 '13 at 11:10
@Stromael Please take a look at tex.stackexchange.com/questions/43894/… – Papiro May 26 '13 at 11:24
@Papiro The linked question isn't a duplicated one. – Marco Daniel May 26 '13 at 11:50

I guess you are searching the option sloped:

Here an example:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw[thick] (-3,3) -- (3,-3) node[at end,sloped,anchor=west] {foobar};
\end{tikzpicture}
\end{document}


To specify the position of the label you can use the option pos:

\draw[thick] (-3,3) -- (3,-3) node[pos=0.7,sloped,anchor=west] {foobar};


You can also use the library decoration to add material to a path:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[label/.style={%
postaction={ decorate,transform shape,
decoration={ markings, mark=at position .7 with \node #1;}}}]
\draw[,label={[above]{$r=0$}}]  (0,2.5) to [out=0,in=220] (3.25,3.75);
\end{tikzpicture}
\end{document}


-
Thanks, that's nearly what I need. Is there a way to alter at which point/node the label is fixed? (i.e., not just the start or end point of the line, but some point in the middle) – Stromael May 26 '13 at 11:40
Great, thanks very much! :) – Stromael May 26 '13 at 11:43
Is there a way to apply the same command to a curve? E.g., {\draw[thick] (0,2.5) to [out=0,in=220] (3.25,3.75) node[pos=0.7, sloped, anchor=west] {$r=0$};} – Stromael May 26 '13 at 12:29
Is there any way of just fixing a node and rotating the label around it by a desired angle? It's just that I have several curves to label in a similar way, and I am unsure how to adapt your code to an example with more than one curve and label. – Stromael May 26 '13 at 13:31
@Stromael: You should ask a new question. – Marco Daniel May 26 '13 at 13:32