1

I'm doing a figure in tikz with different layers on top of each other and the last layer requires me to rotate the rectangle 90 degrees. My problem is how do I make the text left-aligned? The align option doesn't change anything, it's still centred.

\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usetikzlibrary[positioning]
\usetikzlibrary{patterns, arrows.meta, shapes.geometric, calc, shadows}
\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}
        \tikzstyle{up}=[align=left, draw, rectangle,  minimum height=.8cm, minimum width=5cm, fill=red!20,anchor=north west, rotate=90]
        \node[up] (rewiring) {Rewiring};
    \end{tikzpicture}
\end{figure}
\end{document}
thomas
  • 13
  • Note that [align=...] behaves the same as inserting a tabular inside the node, and [text width=...] behaves the same as inserting a \parbox into the node. Combining the two behaves like \parbox{\raggedright ...} (for example). The options are for your convenience, but you don't HAVE to limit yourself to them. – John Kormylo Mar 11 '20 at 15:25

1 Answers1

1

Add the text width-option to the TikZ-node!


MWE:

\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usetikzlibrary[positioning]
\usetikzlibrary{patterns, arrows.meta, shapes.geometric, calc, shadows}
\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}
      \tikzstyle{up}=[text width=5cm, align=left, draw, rectangle,  minimum height=.8cm, minimum width=5cm, fill=red!20,anchor=north west, rotate=90]
        \node[up] (rewiring) {Rewiring};
    \end{tikzpicture}
\end{figure}
\end{document}

enter image description here

Tim Hilt
  • 848
  • 6
  • 18