2

Below is my MWE and an example how it should look like. I asked a kind of similar question yesterday, see here.

Now the problem is, I need both graphs to be vertically the same height, so equally spaced apart nodes, and additionally be aligned to the top.

Getting the both minipages aligned at the top would be the most useful step forward.

\documentclass[
a4paper,            %   Papierformat A4
12pt,               %   Schrift 12-Punkt
headsepline,        %   mit Linie unter der Kopfzeile
numbers=noenddot,   %   Nummern ohne Punkt am Ende
index=totoc,        %   Index mit Nummer im Inhaltsverzeichnis
fleqn,              %   Formeln werden linksbündig statt zentriert 
angeordnet
headings=normal     %       Etwas kleinere Überschriften
]{scrbook}

\usepackage{tikz}
\usetikzlibrary{positioning,chains,arrows, decorations, patterns}
\usepackage{subcaption}

\tikzset{rounddiagram/.style={>=stealth'},
    punktchain/.style={
        rectangle, 
        rounded corners, 
        draw=black, very thick,
        text width=10em, 
        minimum height=3em, 
        text centered, 
        on chain},
    every join/.style={->, thick,shorten >=1pt}}

\begin{document}

\begin{figure}[h]
    \vspace{0pt}

    \begin{minipage}[t]{0.5\textwidth}
        \centering
        \begin{tikzpicture}
        [style=rounddiagram, node distance=.4cm, start chain=going below]
        \node[punktchain, fill=gray, text=white, join]{CbmStsFindClusters};
        \node[punktchain, join]{ProcessData};
        \node[punktchain, join]{Reset};
        \node[punktchain, join]{ProcessDigis};
        \node[punktchain, join]{ProcessBuffer};
        \node[punktchain, join]{Analyze};
        \node[punktchain, join]{RegisterClusters};
        \end{tikzpicture}
        \subcaption{Unterschritte von CbmStsFindClusters}

    \end{minipage}
    \begin{minipage}[t]{0.5\textwidth}
        \centering  
        \begin{tikzpicture}
        [style=rounddiagram, node distance=.4cm, start chain=going below]
        \node[punktchain, fill=gray, text=white, join]{CbmStsFindHits};
        \node[punktchain, join]{ProcessData};
        \node[punktchain, join]{SortClusters};
        \node[punktchain, join]{FindHitsInModules};
        \end{tikzpicture}
        \subcaption{Unterschritte von CbmStsFindHits}
    \end{minipage}
    \caption{Die Tasks CbmStsFindClusters und CbmStsFindHits}
    \label{img:tasks}
\end{figure}

\end{document}

Example

Thanks!

2

You can typeset the two chains in a box; the second one is first typeset with zero separation and then retypeset with a separation computed from the difference of total height between the two boxes.

\documentclass[
  a4paper,            %   Papierformat A4
  12pt,               %   Schrift 12-Punkt
  headsepline,        %   mit Linie unter der Kopfzeile
  numbers=noenddot,   %   Nummern ohne Punkt am Ende
  index=totoc,        %   Index mit Nummer im Inhaltsverzeichnis
  fleqn,              %   Formeln werden linksbündig statt zentriert angeordnet
  headings=normal     %   Etwas kleinere Überschriften
]{scrbook}

\usepackage{tikz}
\usetikzlibrary{positioning,chains,arrows, decorations, patterns}
\usepackage{subcaption}

\tikzset{
  rounddiagram/.style={>=stealth'},
  punktchain/.style={
    rectangle, 
    rounded corners, 
    draw=black,
    very thick,
    text width=10em, 
    minimum height=3em, 
    text centered, 
    on chain
  },
  every join/.style={->, thick,shorten >=1pt},
}

\newsavebox{\leftbox}
\newsavebox{\rightbox}
\newlength{\compute}

\begin{document}

\begin{figure}[htp]

\sbox{\leftbox}{%
  \begin{tikzpicture}[style=rounddiagram, node distance=.4cm, start chain=going below]
    \node[punktchain, fill=gray, text=white, join]{CbmStsFindClusters};
    \node[punktchain, join]{ProcessData};
    \node[punktchain, join]{Reset};
    \node[punktchain, join]{ProcessDigis};
    \node[punktchain, join]{ProcessBuffer};
    \node[punktchain, join]{Analyze};
    \node[punktchain, join]{RegisterClusters};
  \end{tikzpicture}%
}
\newcommand{\rightpicture}[1]{%
  \begin{tikzpicture}[style=rounddiagram, node distance=#1, start chain=going below]
    \node[punktchain, fill=gray, text=white, join]{CbmStsFindHits};
    \node[punktchain, join]{ProcessData};
    \node[punktchain, join]{SortClusters};
    \node[punktchain, join]{FindHitsInModules};
  \end{tikzpicture}%
}
\sbox{\rightbox}{\rightpicture{0cm}}
\setlength{\compute}{\dimexpr(\ht\leftbox+\dp\leftbox-\ht\rightbox-\dp\rightbox)/3}

\begin{subfigure}{0.5\textwidth}
  \centering
  \usebox{\leftbox}
  \subcaption{Unterschritte von CbmStsFindClusters}
\end{subfigure}%
\begin{subfigure}{0.5\textwidth}
  \centering
  \rightpicture{\compute}
  \subcaption{Unterschritte von CbmStsFindHits}
\end{subfigure}

\caption{Die Tasks CbmStsFindClusters und CbmStsFindHits}\label{img:tasks}

\end{figure}

\end{document}

enter image description here

|improve this answer|||||
  • Wow thats crazy, but still simple and immediatly comprehensive! – Rhynden May 13 '19 at 22:38
2

There are many possibilities, this is one: adjustbox. And then you can compute the node sep analogously to the previous answer.

\documentclass[
a4paper,            %   Papierformat A4
12pt,               %   Schrift 12-Punkt
headsepline,        %   mit Linie unter der Kopfzeile
numbers=noenddot,   %   Nummern ohne Punkt am Ende
index=totoc,        %   Index mit Nummer im Inhaltsverzeichnis
fleqn,              %   Formeln werden linksbündig statt zentriert 
angeordnet
headings=normal     %       Etwas kleinere Überschriften
]{scrbook}

\usepackage{tikz}
\usetikzlibrary{positioning,chains,arrows, decorations, patterns}
\usepackage{subcaption}
\usepackage{adjustbox}

\tikzset{rounddiagram/.style={>=stealth'},
    punktchain/.style={outer sep=0pt,
        rectangle, 
        rounded corners, 
        draw=black, very thick,
        text width=10em, 
        minimum height=3em, 
        text centered, 
        on chain},
    every join/.style={->, thick,shorten >=1pt}}

\begin{document}

\begin{figure}[h]
    \vspace{0pt}

    \adjustbox{valign=t,minipage={0.49\textwidth}}{%
        \centering
        \begin{tikzpicture}[style=rounddiagram, node distance=.4cm, start chain=going below]
        \node[punktchain, fill=gray, text=white, join]{CbmStsFindClusters};
        \node[punktchain, join]{ProcessData};
        \node[punktchain, join]{Reset};
        \node[punktchain, join]{ProcessDigis};
        \node[punktchain, join]{ProcessBuffer};
        \node[punktchain, join]{Analyze};
        \node[punktchain, join]{RegisterClusters};
        \end{tikzpicture}
        \subcaption{Unterschritte von CbmStsFindClusters}}
    \adjustbox{valign=t,minipage={0.49\textwidth}}{%
        \centering  
        \begin{tikzpicture}[style=rounddiagram, start chain=going below]
        \pgfmathsetmacro{\mydist}{(((7-4)*3em+6*0.4cm)/3}
        \begin{scope}[node distance=\mydist*1pt]
        \node[punktchain, fill=gray, text=white, join]{CbmStsFindHits};
        \node[punktchain, join]{ProcessData};
        \node[punktchain, join]{SortClusters};
        \node[punktchain, join]{FindHitsInModules};
        \end{scope}
        \end{tikzpicture}
        \subcaption{Unterschritte von CbmStsFindHits}}
    \caption{Die Tasks CbmStsFindClusters und CbmStsFindHits}
    \label{img:tasks}
\end{figure}

\end{document}

enter image description here

|improve this answer|||||
  • I believe that the right column should have the same height as the left one, with equally spaced boxes. – egreg May 13 '19 at 22:15
  • Yes they should. I tried modifying your code from the answer you gave me here tex.stackexchange.com/questions/490541/…. The only thing is I need the equivalent of \textwidth for minipage height, or figure height. Is there anything like that? – Rhynden May 13 '19 at 22:22
  • @Rhynden Sorry, I was offline. It is straightforward to compute this distance, see my updated answer. – user121799 May 13 '19 at 22:45
  • No problem! Ah right, by using the minimum height of each node we can compute the total height of the left box and then take that for the right box. Thanks! Wow LaTeX can be pretty simple and easy actually haha. – Rhynden May 14 '19 at 7:05

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.