4

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!

5

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.

1
  • @jon86 Welcome :-)
    – user11232
    Jan 15 '13 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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