如何独立于旋转text
中的?现在我正在使用。我尝试的另一个选项是有两个重叠节点。有没有更好的方法可以做到这一点?node
node
tikz
rotatebox
\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}
答案1
您可以使用shape border rotate=<anbgle>
来旋转形状。组合 rotate=90, shape border rotate=180
会产生按所需方向旋转的形状和文本(如第一幅图所示):
代码:
\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}