如何通过旋转垂直对齐 tikz 节点

如何通过旋转垂直对齐 tikz 节点

我如何对齐旋转的 tikz 节点?

如何对齐这些节点?

\documentclass{beamer}            
\usepackage{tikz}                                                        
\usetikzlibrary{shapes.geometric,positioning,matrix,fit,tikzmark}

\begin{document}                                                         
\begin{frame}\frametitle{Flow}
\begin{tikzpicture}                                                      
  \node (doc) {Doc};
  \node[draw, trapezium, rotate=90, right=.5cm of doc, anchor=north] (step1) {reductin step 1};
  \node[draw, trapezium, rotate=90, right=.5cm of step1, anchor=north] (step2) {reduction step 2};
  \node[draw, right= of step2, text width=2cm] (step3) {Non-reducing};   
  \node[draw, text width=4cm, right= of step3] (comment) {Long comment:\\all nodes should aligned by their vertical centers};

  \draw[->] (doc) to (step1); 
  \draw[->] (step1) to (step2);
  \draw[->] (step2) to (step3);                 
  \draw[->] (step3) to (comment);                                                                                                                 
\end{tikzpicture}
\end{frame} 
\end{document}

答案1

一种解决方案是使用南锚点,因为虽然旋转,但节点的锚点不会改变:

\documentclass{beamer}            
\usepackage{tikz}                                                        
\usetikzlibrary{shapes.geometric,positioning,matrix,fit,tikzmark}

\begin{document}                                                         
\begin{frame}\frametitle{Flow}
\begin{tikzpicture}                                                      
  \node (doc) {Doc};
  \node[draw, trapezium, rotate=90, right=.5cm of doc, anchor=north] (step1) {reductin step 1};
  \node[draw, trapezium, rotate=90, right=.5cm of step1.south, anchor=north] (step2) {reduction step 2};
  \node[draw, right= of step2.south, text width=2cm] (step3) {Non-reducing};   
  \node[draw, text width=4cm, right= of step3] (comment) {Long comment:\\all nodes should aligned by their vertical centers};

  \draw[->] (doc) to (step1); 
  \draw[->] (step1) to (step2);
  \draw[->] (step2) to (step3);                 
  \draw[->] (step3) to (comment);                                                                                                                 
\end{tikzpicture}
\end{frame} 
\end{document}

相关内容