4
\documentclass{standalone}
\usepackage{forest}
\usepackage{rotating}

\begin{document}

\centering
\begin{forest}
for tree={
  if level=0{
      align=center,
      l sep=20mm,
  }{%
      align={@{}C{1.5em}@{}}, 
      edge path={
        \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(0,-5mm) -| (.child anchor)\forestoption{edge label};
      },
  },
  draw,
  font=\sffamily\bfseries,
  parent anchor=south,
  child anchor=north,
  l sep=10mm, 
  edge={thick, rounded corners=1pt},
  thick,
  inner color=gray!5,
  outer color=gray!20,
  rounded corners=2pt,
  %drop shadow,
  fzr/.style={
      alias=fzr,
      align=center,
      child anchor=west,
      fill=green!25,
      edge path={
         \noexpand\path[\forestoption{edge}]
         ([yshift=-1em]!u.parent anchor) -- (.child anchor)\forestoption{edge label};
      },
  },
 }
[manager, alias=master, align=center
 % [expatriate,fzr]
  [\rotatebox{90}{bureau}]
  [\rotatebox{90}{production}
    [\rotatebox{90}{line}]
  ]
  [\rotatebox{90}{finance}]
  [\rotatebox{90}{quality},align=center
    %[quality supervisor,fzr]
    [\rotatebox{90}{laboratory}]
    [\rotatebox{90}{review}]
  ]
  [\rotatebox{90}{supply}
    [\rotatebox{90}{material}]
    [\rotatebox{90}{\parbox{2.5cm}{Semi-finished\\ products}}]
    [\rotatebox{90}{\parbox{2.5cm}{Finished\\ product}}]
  ]
]
\node [draw,font=\sffamily\bfseries,thick,fill=green!25,rounded corners=2pt,xshift=25mm,] (fuzeren) [yshift=-1.3em,] {expatriate};
\path [draw,thick] ([yshift=-.5em]!master.south) -- (fuzeren);
\end{forest}
\end{document}

It appears to be something like this:

tree_structure

In fact I modified the code from someone and I don't really understand everything inside the code. The diagram I desire is:

  1. The 'manager' aligns with 'quality' and the 'supply' aligns with 'semi finished products' (I already let the 'quality' align = center. I don't know why it doesn't align with manager).
  2. The turnings of the connecting line should not have fillet, to let the intersection to be straight right.
  3. It should spare some place for the 'expatriat' for that it doesn't touch the horizontal line.
  4. The frame of each level should be aligned by the upper border.

Anyway, would someone give a solution to help achieve my desired tree-diagram?

  • Who's someone? Please attribute code and provide a link to the original. – cfr Mar 30 '17 at 12:27
  • See the Forest manual for better ways to rotate nodes. You don't want to use \rotatebox here, I don't think. – cfr Mar 30 '17 at 13:47
  • Don't you get a compilation error? If we had the original source, we might at least be able to compare them. – cfr Mar 30 '17 at 23:34
  • You didn't test this before uploading, did you? How is the C column type defined? – cfr Mar 30 '17 at 23:35
  • The original code uses ctex, a chinese language package and all contents are in chinese. The original code, if you want, is here : paste.ubuntu.com/24288316 Thanks a lot. – jiexiang wen Mar 31 '17 at 14:53
6

Without working code, with no clue where the original source with missing stuff might be found, it is easier to just start from scratch.

Use the edges library for forked edges. Have Forest do the rotation. Have Forest place the expatriate. Then the code is much simpler, cleaner and more straightforward.

If you don't understand something in the code, look it up in the manual. If you don't understand the explanation, ask. If you use code from somebody else, attribute it. People have names. They are not anonymous some-bodies.

\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shadows.blur}
\begin{document}
\begin{forest}
  forked edges,
  for tree={
    edge+={thick},
    inner color=gray!5,
    outer color=gray!20,
    rounded corners=2pt,
    draw,
    thick,
    tier/.option=level,
    align=center,
    font=\sffamily,
    blur shadow,
  },
  where level<=1{}{
    rotate=90,
    anchor=east,
  },
  [manager
    [, coordinate, calign with current
      [bureau]
      [production
        [line]
      ]
      [finance]
      [quality, calign with current
        [laboratory]
        [review]
      ]
      [supply
        [material]
        [Semi-finished\\products, calign with current]
        [Finished\\product]
      ]
    ]
    [expatriate, inner color=green!10, outer color=green!25, child anchor=west, edge path'={(!u.parent anchor) -| (.child anchor)}, before drawing tree={y'+=7.5pt} ]
  ]
\end{forest}

\end{document}

fixed tree

  • Thank you. I have provided the original code in comment. – jiexiang wen Mar 31 '17 at 14:57
  • And the source is a friend, he wanted to do this and his code does't run neither, I modified into english and post here for an answer. – jiexiang wen Mar 31 '17 at 15: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.