2

How do I align tikz nodes which are rotated?

how to align these nodes?

\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}
  • 4
    You are almost there. Just add .south twice after step1 and step2: \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};. – Schrödinger's cat Aug 23 '19 at 20:44
  • 1
    Your solution worked and now I see why. Would you like to answer or I do? – Marc Kees Aug 23 '19 at 20:46
  • Whatever you prefer. – Schrödinger's cat Aug 23 '19 at 20:49
3

A solution is to use south anchor because, although rotate, node's anchors do not change:

\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}
  • 1
    Following @Schrödinger's cat 's good idea. – Marc Kees Aug 23 '19 at 20:53

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.