[Tex/LaTex] TikZ diagonal text

rotatingtikz-pgf

Can you rotate text diagonally in TikZ / latex?

I tried

\coordinate (P) at (0,0) ;
\draw[rotate around={45:(P)}] (P) node {hello} ;

But it just draws the text straight (horizontally).

I want the text to go at a 45 degree incline.

Best Answer

There might be a confusion here relating to PSTricks habits.

First of all, \coordinate (P) (0,0); defines a coordinate at the origin with the name (P). This name is related to origin now. Then you add

\draw[rotate around={45:(P)}] (P) node {hello} ;

This command first does this bit;

\draw (P) node {hello} ;

which says that go to point (P), which is the origin now from the previous command, and put a node there with text hello. Then, the option kicks in and says that you should also rotate this path, which is going to origin and putting a node, 45 degrees. But since the path is actually not moved, as we are still at the origin, no rotation is created. If you want to rotate the node then it should be supplied to the node options and not to the path options, hence

\begin{tikzpicture}
\coordinate (P) at (0,0);
\draw (P) node[rotate=45] (N) {hello}; % The node has the name N now!
\end{tikzpicture}

is the command that you have to enter. But since you are trying to put a node and not to draw anything you can directly use

\begin{tikzpicture}
\coordinate (P) at (0,0);
\node[rotate=45] (N) at (P) {hello}; % The node has the name N now and located at (P)
\end{tikzpicture}