0

I think all of the problems has been asked by me or others in the past. But my over all problem is that I am not able to combine all this solutions to the real picture I want to draw. Normally it is nice to seperate a complex problem into more simple ones and ask. But here I try to ask the complex question because I experienced that the solutions influence (in my case negativ) each other.

enter image description here

Description of the needs/prolems:

  1. The left nodes (Phase) should be rotaed. I would prefere a solution with \rotatebox (node contents={\rotatebox{90}{#1}}}).
  2. The nodes (better would be rows) on the right are centered horizontal.
  3. Logical the picture have four rows and the nodes on the left and right need to display that. This means that one node (e.g. right of B) is centered vertical against its left node. Please see that PhaseC belongs to C1, C2 and long C3, so that the vertical alignment should represent that. (discussed here)
  4. Connecting the nodes with arrow shouldn't be so hard I think.
  5. All have to be done relative. That means no cm, mm, pt or something like that.
  6. The number of nodes is not fixed. It could be that in row one are less nodes then in row four.

Some solutions:

\documentclass[tikz]{standalone}
\usepackage{xltxtra}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=new]{german}
\usepackage{tikz}
\usetikzlibrary{scopes,matrix,positioning,chains}

\begin{document}
\begin{tikzpicture}
    [
        items/.style = {
            draw,
            align=center},
        phase/.style = {
            items,
            fill=red!20,
            node contents={\rotatebox{90}{#1}}}
    ]
    {[
        start chain=P going below
    ]
        \node [on chain,phase=PhaseA];
        {[
            start branch=A going right,
            every on chain/.append style=items,
            every node/.style=on chain
        ]
            \node {One};
            \node {Two};
            \node {Three};
            \node {Four};
        }
        \node [on chain,phase=PhaseB];
        \node [on chain,phase=PhaseC];
        \node [on chain,phase=PhaseD];
        {[
            start branch=D going right,
            every on chain/.append style=items,
            every node/.style=on chain
        ]
            \node {D1};
            \node {D2};
        }
    }

    % B
    \node [right=of P-2,items] {right of B};

    % C
    \matrix (C) [
        matrix of nodes,
        row sep=5pt, %2\textheight doesn't work here, maybe a \nodeheight exists?
        every node/.append style=items,
        right=of P-3]
    {
        C1 \\
        C2 \\
        long C3\\
    };
\end{tikzpicture}
\end{document}

Produce this

enter image description here

Number 2 and 5 are not fullfilled. And I think number 6 would make problems in the future.

8
  • It is not a duplicate of the question you marked. Please note that I also added this duplicate question to my own. All my points are not possible with the solution provided be the answer of the other question. As I described in the beginning of my question. Comining my needs is the problem here. #3 is full-filled with the duplicate answer but #2 is against it.
    – buhtz
    Feb 6, 2016 at 18:29
  • 1
    I think at this point one of two things is happening. Possibility 1: we just do not understand what you are trying to do. Since you've asked several versions of several questions about this and people have tried several things in several answers to several understandings of each of those versions of each of those questions, I doubt that a new question which seems to start from scratch with no code is likely to clarify things. Possibility 2: you might want something which just cannot be done. Possibility 1 seems definitely true: we don't get it. Possibility 2 may also be true: I'm not sure.
    – cfr
    Feb 6, 2016 at 23:51
  • You seem to want a solution to a problem with various ill-specified parameters. I think the issue may be that you just haven't thought about what you want, where what you want needs to be specific in input you expect to give for particular output. What exactly should LaTeX do? Do you have an algorithm for solving the generic problem you want solved? There are various ways this might work. I can imagine some of them. But I suspect that any answer I gave won't be the one you imagined. It won't be your dream and so will be unacceptable. Remember, you need to implement it. Be realistic.
    – cfr
    Feb 6, 2016 at 23:57
  • I think you are right. Problems depend on the way I think and work - e.g. my old WYSIWYG-brain.
    – buhtz
    Feb 7, 2016 at 10:15
  • Your question is direct duplicate to your previous questions: tex.stackexchange.com/questions/289896/… and tex.stackexchange.com/questions/263737/flowchart-tikz with small differences: number of nodes. In answer for this your questions you got all tools and explanations, how to draw similar diagrams. So, it is seems, that you not willing to draw yourself and that you just waiting, that someone will draw voluntary all variants of your images instead you.
    – Zarko
    Feb 7, 2016 at 10:57

2 Answers 2

3

Here's how I would probably actually do this. I don't suggest this is an obvious solution, but the code is succinct and can be easily tweaked for the entire diagram.

labelled diagram

If anybody wishes to try this at home, let me know and I will give you a copy of the experimental package it uses. (I hope to get its sister to CTAN shortly, and maybe this one as well, but it is not there yet.)

This uses forest version 2. It is not tested with version 1.

\documentclass[tikz, border=10pt, multi]{standalone}
\usepackage{justtrees}% version 0.07; forest version 2
\begin{document}
\forestset{%
  grouped/.style={
    !u.l sep=2.5pt,
    l=2.5pt,
    no edge
  }
}
\begin{justtree}
{
    for tree={
      draw,
      text height=1.5ex,
      l+=10mm,
      edge={->, thick},
      thick,
      font=\sffamily
    },
    just format={fill=red!20, rotate=90, anchor=south, yshift=2.5mm, xshift=.75ex, font=\sffamily}
}
  [one, left just=PhaseA]
  [two]
  [
    [right of B, left just=PhaseB, no edge, tikz+={\foreach \i in {1,2,4,5} \draw [<-, thick] (.child anchor) -- (!uu\i.parent anchor); }
      [C1
        [C2, left just=PhaseC, grouped
          [long C3, grouped
            [D1, left just=PhaseD]
            [D2]
          ]
        ]
      ]
    ]
  ]
  [three]
  [four]
\end{justtree}
\end{document}
16
  • +1 .. now is really time that I start with learning forest ...
    – Zarko
    Feb 9, 2016 at 2:41
  • 1
    I like its conciseness - saves typing ;). And justtrees almost worked with version 2 of forest. Only a minor change, though it took a while to track down. (Unlike prooftrees which is broken.) Though probably it could be done better using some of the new gubbins in 2....
    – cfr
    Feb 9, 2016 at 2:47
  • 1
    @buhtz chat.stackexchange.com/rooms/35533/justtrees-v-0-07
    – cfr
    Feb 10, 2016 at 0:24
  • 1
    Mostly, yes. It can automatically position the nodes on the left (or the right, if you wanted them there, or both, if you wanted both) without having to do it manually, and these labels can be specified as part of the tree specification itself. That's basically it. It is a simplified version of code I wrote to typeset tree proofs in logic, where things are a bit more complicated.
    – cfr
    Feb 11, 2016 at 16:41
  • 1
    @buhtz Else I think you are asking for an entirely different package. Unless you can find one which already exists, you would probably need to write it, though. Maybe somebody has written one already. There's a lot of stuff out there which never makes it to CTAN. But bear in mind the amount of time you are spending searching for your dream solution, when that might not (yet) exist. You might prefer to spend that time trying to create such a solution. But, again, how many of these diagrams do you need to draw to be worth that investment? (If you want to do it to learn more, that's different.)
    – cfr
    Feb 11, 2016 at 16:49
2

Your MWE compile without error but result seems to be different from your sketch ... Since you already got answer on your similar questions, which answer also solve problems you emphasized in question, I made (on basis of mine previous answers) the following flowchart:

enter image description here

with following code:

\documentclass{article}
    \usepackage{tikz}
    \usetikzlibrary{arrows.meta,calc,chains,fit,positioning,scopes}
%%%% for show flowchart only
    \usepackage[active,tightpage]{preview}
    \PreviewEnvironment{tikzpicture}
    \setlength\PreviewBorder{3mm}

    \begin{document}
%---------------------------------------------------------------%
%   forth example                                               %
%---------------------------------------------------------------%
    \begin{tikzpicture}
%---------------------------------------------------------------%
suspend join/.code={\def\tikz@after@path{}},
    node distance = 7mm and 5mm,
      start chain = MR going right,
      start chain = MB going below,
      base/.style = {% common parameters
            draw, minimum size=4ex, inner sep=1mm},
        MR/.style = {% My Row nodes
            base, on chain=MR},
        MB/.style = {% My right Branch nodes
            base, on chain=MB},
        ML/.style = {% My Left branch nodes
            draw=cyan!60!black, rounded corners, fill=cyan!30,
            minimum size=4ex,
            label=center:\rotatebox{90}{#1},
            node contents={\rotatebox{90}{\phantom{#1}}}},
     arrow/.style = {thick,-{Triangle[]}},
       }
%---------------------------------------------------------------%
% FIRST ROW, names MR-1 ... MR-4
\node [MR] {one};
\node [MR] {two};
\node [MR] {tree};
\node [MR] {four};
% RIGHT BRANCH, names MB-1 ... MB-4
%   start point is below of middle of the first row
    \begin{scope}[every node/.style={MB,join=by arrow}]
\node[below=15mm of $(MR-1.south west)!0.5!(MR-4.south east)$] 
        {belong to Phase B}; % name=MB-1,
\node   {belong to Phase C};
\node   {belong to Phase C};
\node   {also belong to Phase C};% name=MB-4,
    \end{scope}
% LAST ROW, names MR-5 ... MR-6
\node[MR,below  left=of MB-4.south]   {D1};% name=MR-5,
\node[MR,below right=of MB-4.south]   {D2};
% LEFT BRANCH, 
\node (ML1) [ML=Phase A,left=of MR-1.west];
\node (ML2) [ML=Phase B,left=of MR-1.west |- MB-1];
\node (ML3) [ML=Phase C, inner ysep=0pt,
             fit=(ML1 |- MB-2.north) (ML1 |- MB-4.south)];
\node (ML4) [ML=Phase D,left=of MR-1.west |- MR-5];
% ARROWS NOT DETERMINED BY "JOIN" MACRO
\foreach \i in {1,2,3,4}
\draw[arrow]    (MR-\i) -- (MB-1);
\draw[arrow]    (MB-4) -- (MR-5);
\draw[arrow]    (MB-4) -- (MR-6);
    \end{tikzpicture}
\end{document}

The code for it is designed in the following assumptions:

  • the widest row in right branch is the top row, so the left branch i aligned with its left side
  • nodes in the first row in right chains are in chain going right
  • right branch are below of center of the first row. It can be simply determined by $(MR-1.south west)!0.5!(MR-4.south east)$. Nodes in it are in chain and going below
  • in the last row are only two nodes, so they are positioned relatively to node above it
  • blue nodes in the left branch are positioned in respect to left side of the first row and positioning of belonging nodes in right branch with exception of node, "Phase C", which is fit on coordinates determined by (ML1 |- MB-2.north)and (ML1 |- MB-4.south) whre ML1 is coordinate of the top blue node and MB-2 and MB-4 names of belonging nodes in the right branch
  • nodes are not in grid
  • nodes in the top row, right branch haw own style, which differ in chain name
  • blue nodes also have own style. Since text in nodes, which fit some coordinates is not centering anymore, for text is exploited label positioned in node center.

In case, that text in nodes in the right branch will have text in more lines, than you can add to node style text width and align=center (or left, depends on what you like to be aligned).

7
  • I am sorry, but #5 is not fullfilled and I see problems with #1.
    – buhtz
    Feb 9, 2016 at 18:12
  • - At some points you use fixed values for node distance, minimu size, below=15mm of. Killing this lines everything falls apart. Using fixed values make the whole construct unflexible for needs/changes in the future.
    – buhtz
    Feb 9, 2016 at 18:13
  • - You use a workaround to draw PhaseC which cause problem for \rotatebox which in the next consequence cause the need to find a solution (label=) for that problem. This make the code unusefull complex.
    – buhtz
    Feb 9, 2016 at 18:15
  • I see some lines of TeX code in it. What is the functionality behind it? And I couldn't find the string suspend join/.code in the documentation. What does this mean?
    – buhtz
    Feb 9, 2016 at 18:17
  • I found this code on SE. It suspend join functionality of nodes in chain (in node, where is present this parameter, the join is suspend (see my answers on your older questions). Above example work also without it (it is remnant of previous my answer on your question). For clarity, I will erase it.
    – Zarko
    Feb 9, 2016 at 18:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .