5

I am trying to convert my word document to latex document. I have an organization chart similar to the following picture: word organization chart

I tried the following code in latex but the result is not similar to word

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{trees}
\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture}
\tikzset{ level distance=65pt, 
        edge from parent/.style=
            {thick, draw=black, edge from parent path={(\tikzparentnode.south) -- +(0,-10pt) -| (\tikzchildnode.north)}},
        every node/.style=
            {thick, draw=black, align=center, level distance=60pt, minimum height=40pt, text width=80pt}
    }
\Tree [.{multiple line\\text}
    [.text ]
    [.{very long single line text} ]
    [.text
        [.text ]
        [.text ]
        [.text ]
    ]
    [.text ]
]
\end{tikzpicture}
\end{document}

and the result is:

enter image description here

3
  • 1
    Have a look here: tex.stackexchange.com/questions/74518/… (Using boxes with two rows in a TikZ tree, answer from Gonzalo Medina). Any maybe add more code to your example so that the people here can compile it and see the result (a so called MWE). May 25 '15 at 11:48
  • @Manuel Kuehner, the problem is not about multiple line text, but the main problem is the 3rd level and many more problems... I edit my question and add my latex result to compare both of them together May 25 '15 at 12:49
  • For me there's a problem for the very long single line that tales two lines. What is it supposed to be, really?
    – Bernard
    May 25 '15 at 13:07
8

I would enjoy the fact that you are not bound by the limitations of Word ;).

forest is a powerful tree-drawing package of which I am well-known to be fond:

\documentclass[tikz,border=5pt,multi]{standalone}
\usepackage{forest,array}
\usetikzlibrary{shadows}
\newcolumntype{C}[1]{>{\centering}p{#1}}
\begin{document}

  \begin{forest}
    for tree={
      if level=0{align=center}{% allow multi-line text and set alignment
        align={@{}C{25mm}@{}},
      },
      draw,
      font=\sffamily\bfseries,
      edge path={
        \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(0,-5mm) -| (.child anchor)\forestoption{edge label};
      },
      parent anchor=south,
      child anchor=north,
      l sep=10mm,
      tier/.wrap pgfmath arg={tier #1}{level()},
      edge={ultra thick, rounded corners=2pt},
      ultra thick,
      inner color=gray!5,
      outer color=gray!20,
      rounded corners=2pt,
      drop shadow,
    }
    [multiple line\\text
      [text]
      [very long single line text]
      [text
        [text]
        [text]
        [text]
      ]
      [text]
    ]
  \end{forest}

\end{document}

forest

3
  • Exactly what I'm looking for May 28 '15 at 5:47
  • Note to self: do not upvote this answer!
    – cfr
    Dec 6 '16 at 22:18
  • @alien How do you align secondary nodes from top to bottom?
    – SolidMark
    Jun 8 '21 at 7:04
4

If the trees format doesn't quite work, and since matrix can't handle the top node, you can always arrange the nodes individually.

tree

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\tikzset{every node/.style=
            {thick, draw=black, align=center, minimum height=40pt, text width=80pt}
    }
\node(a1) {text};% start with left second level
\node[right=10pt] (a2) at (a1.east) {very long single line text};
\node[right=10pt] (a3) at (a2.east) {text};
\node[right=10pt] (a4) at (a3.east) {text};
\node[above=10pt] (top) at ($(a2.north)!.5!(a3.north)$) {multiple line\\text};
\node[below=10pt] (b2) at (a2.south) {text};
\node[below=10pt] (b3) at (a3.south) {text};
\node[below=10pt] (b4) at (a4.south) {text};
\coordinate (atop) at ($(top.south) + (0,-5pt)$);% midpoint below top
\coordinate (btop) at ($(a3.south) + (0,-5pt)$);% midoint below a3
\draw[thick] (top.south) -- (atop)
 (a1.north) |- (atop) -| (a4.north)
 (a2.north) |- (atop) -| (a3.north)
 (a3.south) -- (b3.north)
 (b2.north) |- (btop) -| (b4.north);
\end{tikzpicture}
\end{document}
2
  • Thanks, your answer is correct but it is so much difficult to arrange all charts' nodes individually May 25 '15 at 17:02
  • 2
    Sometimes OCD is useful. May 25 '15 at 21:01
0

The dot program in the graphviz program family is very handy for drawing graphs of this sort, although the formatting may not match MSWord exactly. A file named sample.dot containing...

digraph G
{
    node [shape=box];
    edge [arrowhead=none];

    1  [label="multiple line\ntext"];
    2  [label="text"];
    3  [label="very long single\nline text"];
    4  [label="text"];
    5  [label="text"];
    6  [label="text"];
    7  [label="text"];
    8  [label="text"];

    1 -> 2;
    1 -> 3;
    1 -> 4;
    1 -> 5;
    4 -> 6;
    4 -> 7;
    4 -> 8;
}

Processed with dot -Tpdf sample.dot -o sample.pdf will produce this graph. Of course the pdf file will look much better than the image shown here.

enter image description here

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.