[Tex/LaTex] Family tree with two different line style using forest package

forest

I'm trying to use forest package to draw a family tree in similar fashion like a folder. I'd like some children to be marked with dashed lines, because they are not descendents of the person, but are his/her children's (half) brothers/sisters.

The example of the family tree:
enter image description here

And the code used to create it:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage{forest}
\begin{document}
\forestset{
  my tier/.style={% align all nodes on a given level
    tier/.wrap pgfmath arg={level##1}{level()},
  },
}
\begin{forest}
  for tree={
    grow'=0,
    child anchor=west,
    parent anchor=south,
    anchor=west,
    calign=first,
    s sep+=-5pt,
    inner sep=2.5pt,
    edge path={
      \noexpand\path [draw, \forestoption{edge}]
      (!u.south west) +(7.5pt,0) |- (.child anchor)\forestoption{edge label};
    },
    before typesetting nodes={
      if n=1{
        insert before={[, phantom, my tier]},
      }{},
    },
    my tier,
    fit=band,
    before computing xy={% change the value of l to alter the distance between levels
      l=30pt,
    },
  }
[Grandma+Steve. Steve later remarried with Betty
    [Child of Grandma+Steve
        [Grandchild]
        [Grandchild]
    ]
    [Child of Grandma+Steve
        [Grandchild of Grandma+Steve]
        [Half brother/sister]
    ]
    [Child of Steve+Betty]
]
    \end{forest}
\end{document}

I'd like to have a dashed line from Child of Steve+Betty up to the second child of Steve. If I put [draw, dashed, \forestoption{edge}] all the lines will be dashed.

Is there an easy way to have dashed line style to only some child nodes? The line style should be solid for the children of Steve+Betty.

I hope the problem is clearly presented.

Best Answer

You can use the edge key to change the default edge style for the desired childs. A little example:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage{forest}
\begin{document}
\forestset{
  my tier/.style={% align all nodes on a given level
    tier/.wrap pgfmath arg={level##1}{level()},
  },
}
\begin{forest}
  for tree={
    grow'=0,
    child anchor=west,
    parent anchor=south,
    anchor=west,
    calign=first,
    s sep+=-5pt,
    inner sep=2.5pt,
    edge path={
      \noexpand\path [draw, \forestoption{edge}]
      (!u.south west) +(7.5pt,0) |- (.child anchor)\forestoption{edge label};
    },
    before typesetting nodes={
      if n=1{
        insert before={[, phantom, my tier]},
      }{},
    },
    my tier,
    fit=band,
    before computing xy={% change the value of l to alter the distance between levels
      l=30pt,
    },
  }
[Grandma+Steve. Steve later remarried with Betty
    [Child of Grandma+Steve
        [Grandchild]
        [Grandchild]
    ]
    [Child of Grandma+Steve,edge={densely dashed}
        [Grandchild of Grandma+Steve]
        [Half brother/sister,edge={densely dashed}]
    ]
    [Child of Steve+Betty]
]
    \end{forest}
\end{document}

The output:

enter image description here

Related Question