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.

How can I rotate the text inside a node independent of the node in tikz? Right now I am using the rotatebox. The other option I tried was to have two overlapping nodes. Is there a better way to do this?

\documentclass{standalone}
\usepackage{tikz}
    \usetikzlibrary{shapes.geometric}   % For trapezium
\usepackage{rotating}                   % For rotatebox
\begin{document}
\begin{tikzpicture}
% Text orientation is wrong
\node[draw, trapezium, rotate=-90, minimum height=1.2cm, trapezium stretches body] at (1,1.5) {Component};
% Method 1 using rotatebox
\node[draw, trapezium, rotate=-90, minimum height=1.2cm, trapezium stretches body] at (3,1.5) {\rotatebox{180}{Component}};
% Method 2 overlapping nodes
\node[draw, trapezium, rotate=-90, minimum height=1.2cm, trapezium stretches body, text=white] at (5,1.5) {Component};
\node[trapezium, rotate=90, minimum height=1.2cm, trapezium stretches body] at (5,1.5) {Component};
\end{tikzpicture}
\end{document}

Getting text orientation right

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

You can use shape border rotate=<anbgle> to rotate the shape. The combination rotate=90, shape border rotate=180 produces the shape and text rotated in the desired direction (as in first image):

enter image description here

Code:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}   % For trapezium 
\usepackage{rotating}               % For rotatebox

\begin{document}
\begin{tikzpicture}
% Text orientation is wrong
\node[draw, trapezium, rotate=90, minimum height=1.2cm, trapezium stretches body, shape border rotate=180] at (1,1.5)  {Component};
% Method 1 using rotatebox
\node[draw, trapezium, rotate=-90, minimum height=1.2cm, trapezium stretches body] at (3,1.5) {\rotatebox{180}{Component}};
% Method 2 overlapping nodes
\node[draw, trapezium, rotate=-90, minimum height=1.2cm, trapezium stretches body, text=white] at (5,1.5) {Component};
\node[trapezium, rotate=90, minimum height=1.2cm, trapezium stretches body] at (5,1.5) {Component};
\end{tikzpicture}
\end{document}
share|improve this answer
    
It works without decorate too. Any reason to include \usetikzlibrary{decorations}? –  mythealias Oct 7 '12 at 13:45
    
@mythealias: Was left over from an earlier attempt at a fix. Have updated solution to removed it. –  Peter Grill Oct 7 '12 at 18:17
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.