[Tex/LaTex] Text alignment and form of connectors (edges) in tikz tree

tikz-pgftikz-trees

I'm completely new to tikz and try to draw a tree structure.

I have tried different options, but could not modify it as I wanted it to look like.
It currently looks like that:

Tikz code

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{trees} % this is to allow the fork right path

\usepackage[utf8]{inputenc}

\begin{document}

\begin{tikzpicture}[grow'=right,sibling distance=0.1cm]
  \tikzstyle{level 1} = [level distance=3cm, text width = 2cm]
  \tikzstyle{level 2} = [level distance=3cm, text width = 2cm]
  \tikzstyle{level 3} = [level distance=3cm, text width = 2cm]
\Tree 
    [
    [.{Pressen}
            [.{uniaxiales Pressen} ]
            [.{isostatisches Pressen} ]
            [.{Vibrationspressen} ]
            [.{Stampfen} ]
        ]
        [.{Plastisches Formen}
            [.{Extrudieren} ]
            [.{Drehen} ]
        ] 
        [.Gießen 
            [.{Schlickergießen} ]
            [.{Druckgießen} ]
            [.{Spritzgießen} ]
            [.{Foliengießen} ]
]
    ]
\end{tikzpicture}
\end{document}

The resulting pdf output:

(red line drawn by hand, see below)

enter image description here

I'd like to achieve the following

  • linebreak in node "Plastisches Formen"
  • edges not straight but horizontal/vertical – like sketched in red for one edge
  • text of each level aligned left
  • is it possible to adjust the level distances automatically to the width of the largest node in the level, so that I do not have to set "level distance" by hand?

Best Answer

If forest is an option:

\documentclass[tikz,border=3mm]{standalone}

\usepackage{forest}
\usepackage[utf8]{inputenc}

\begin{document}

\begin{forest}
for tree={grow'=0,
anchor=west, child anchor=west, fit=band, parent anchor=east, edge path={\noexpand\path[\forestoption{edge}](!u.parent anchor)|-(.child anchor)\forestoption{edge label};}, l sep=1cm,}
[, calign=child,  calign child=2
    [Pressen
           [uniaxiales Pressen]
            [isostatisches Pressen]
            [Vibrationspressen]
            [Stampfen]
        ]
        [Plastisches\\Formen, align=center
            [Extrudieren]
            [Drehen]
        ] 
        [Gießen 
            [Schlickergießen ]
            [Druckgießen ]
            [Spritzgießen ]
            [Foliengießen ]
]
    ]
\end{forest}
\end{document}

enter image description here

2nd version:

I'm not sure to understand what all nodes "raggedright" means, but may be option align=right does it.

The other comment about aligning all same level nodes can be done with tier/.pgfmath=level() option.

\documentclass[tikz,border=3mm]{standalone}

\usepackage{forest}
\usepackage[utf8]{inputenc}

\begin{document}

\begin{forest}
for tree={grow'=0, l=0, l sep=2em, 
         child anchor=west, anchor=west,  
          parent anchor=east, 
          tier/.pgfmath=level(),
          align=right,
          edge path={\noexpand\path[\forestoption{edge}](!u.parent anchor)|-(.child anchor)\forestoption{edge label};},
          }
[, calign=child,  calign child=2
    [Pressen
           [uniaxiales\\ Pressen]
            [isostatisches Pressen]
            [Vibrationspressen]
            [Stampfen]
        ]
        [Plastisches\\Formen
            [Extrudieren]
            [Drehen]
        ] 
        [Gießen 
            [Schlickergießen ]
            [Druckgießen ]
            [Spritzgießen ]
            [Foliengießen ]
]
    ]
\end{forest}
\end{document}

enter image description here