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.

I would like to know how I can get a linebreak inside a rotated node using tikz. I tried to use the align=center option together with \rotatebox{}{}, but i get an error. Here is an example of a working code but without the linebreak:

\begin{figure}[h!tp]
\begin{tikzpicture}[generaloptions/.style 2 args={
draw,ultra thick,font={\bfseries},inner sep=0,outer sep=0,minimum height=#1,minimum width=#2}]
\node[generaloptions={3.5cm}{1.5cm},align=center,anchor=south west,font=\footnotesize\bfseries] (l1) at ([xshift=-1.5cm]big.south west) {\rotatebox{90}{Line Break}};
\end{tikzpicture}
\end{figure} 

I would like something like this but instead i get an error:

\begin{figure}[h!tp]
\begin{tikzpicture}[generaloptions/.style 2 args={
 draw,ultra thick,font={\bfseries},inner sep=0,outer sep=0,minimum height=#1,minimum width=#2}]
 \node[generaloptions={3.5cm}{1.5cm},align=center,anchor=south west,font=\footnotesize\bfseries] (l1) at ([xshift=-1.5cm]big.south west) {\rotatebox{90}{Line \\ Break}};
 \end{tikzpicture}
 \end{figure}

I am I missing something? Thanks!

share|improve this question

1 Answer 1

up vote 5 down vote accepted

rotatebox tries to rotate every thing inside as if it were a box. Hence you can't expect a line break. You may put the content inside a parbox

\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[generaloptions/.style 2 args={
 draw,ultra thick,font={\bfseries},inner sep=0,outer sep=0,minimum height=#1,minimum width=#2}]
 \node[generaloptions={3.5cm}{1.5cm},align=center,anchor=south west,font=\footnotesize\bfseries] (l1) at (0,0) {\rotatebox{90}{\parbox[c]{1.5cm}{\centering Line  Break}}};
 \end{tikzpicture}
\end{document}

enter image description here

If you want to rotate the text alone and have line break, you may use the option rotate=90,text width = 1.5cm (and ditch the rotatebox):

\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[generaloptions/.style 2 args={
 draw,ultra thick,font={\bfseries},inner sep=0,outer sep=0,minimum height=#1,minimum width=#2}]
 \node[generaloptions={1.5cm}{3.5cm},text width = 1.5cm,align=center,anchor=south west,font=\footnotesize\bfseries,rotate=90] (l1) at (0,0) {Line  Break and break yes };
 \end{tikzpicture}
\end{document}

enter image description here

You may have to interchange the minimum height and minimum width though.

share|improve this answer
    
Thank you very much for your answer! –  jon86 Jan 15 '13 at 10:14
    
@jon86 Welcome :-) –  Harish Kumar Jan 15 '13 at 10:18

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.