我在 tikz 中制作一个图形,其中不同的图层相互叠加,最后一层需要我将矩形旋转 90 度。我的问题是如何使文本左对齐?对齐选项不会改变任何东西,它仍然居中。
\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}
答案1
将text width
-option 添加到 TikZ-node!
梅威瑟:
\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}