Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
I think you are somewhat used to PSTricks syntax. It goes as \coordinate (P) at (0,0) ; \node[rotate around={45:(P)}] {hello} ; in TikZ. –  percusse Aug 9 '12 at 23:20
    
Oh, ok, that is the right answer then! Thanks. –  bobobobo Aug 9 '12 at 23:22
    
Should we close this then? The best would be you voting for deletion as this is a little too localized for a question. –  percusse Aug 9 '12 at 23:23
    
Well, I don't think so, but you can close it if you like. It's a nice link to correct diagonal text syntax. See if it gets search engine hits. –  bobobobo Aug 9 '12 at 23:24
    
@percusse \node doesn't actually work! It doesn't translate the node to (P) if you move it, it is stuck at the origin. –  bobobobo Aug 9 '12 at 23:28
add comment

1 Answer

up vote 12 down vote accepted

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}
share|improve this answer
    
Oh, ok. I didn't realize I had to apply the rotate command to the node! \draw (P) node[rotate=45] {hello} ; is a more familiar look for drawing for me. –  bobobobo Aug 10 '12 at 0:37
1  
@bobobobo In TikZ \draw is an action on a path. A node is not exactly a part of a path, it's an object and it's possible to add it to a path. You can draw a node inside a path without drawing the path. More natural in Tikz is \node[draw] at (0,0) {hello}; instead of \draw (0,0) node {hello}; –  Alain Matthes Aug 11 '12 at 7:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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