4

I have used this awesome reply by the user cfr to edit and come up with a nice tree that I can use. However there are some small things that I wanted to change. I played with some numbers but the code for it is a little bit over my head. I couldn't make any other changes after what I have done and shown below. I feel like I am missing something but I can't figure it out.

I am trying to replicate a tree from another book but my trees don't look quite the same. I would like the first split to also be straight and I want the leaf nodes (sometimes also non-leaf nodes) to not have a box around them. I am using the book Smart Card Handbook 3rd edition by W.Rankl and W. Effing. The trees I am trying to replicate are the ones on pages 18 and 255. Here is what I currently have:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz} \usepackage[edges]{forest} \forestset{ declare dimen register=gap, gap'=10mm, declare count register=twist, twist'=1, family tree too/.style={ draw, forked edges, for tree={ fill=gray!0, rounded corners=1pt, minimum width/.wrap pgfmath arg={##1}{(\textwidth-6(gap))/3}, minimum height=4ex, font=\sffamily, text centered, edge=thick, }, where={level()<(twist)}{% parent anchor=children, l sep+=5pt, }{% draw, folder, grow'=0, if={level()==(twist)}{% before typesetting nodes={child anchor=north}, anchor=north, edge path'={% (!u.parent anchor) -- (.child anchor) }, }{ l sep'+=2pt, if level=2{ before computing xy={ l/.wrap pgfmath arg={##1}{14pt-((\textwidth-6(gap))/6)} }, }{} }, }, }, }

\begin{document} \begin{figure}[!ht] \centering \begin{forest} family tree too, [Lorem ipsum dolor sit amet con [Lorem ips [Lorem ipsum [Lorem ipsum dolor sit.] [Lorem ipsum dolor s] ] [Lorem ipsum dolor si [Lorem ipsum dolor s] [Lorem ipsum dolo] ] ] [Lorem ipsum dolor sit am [Lorem ipsum d] [Lorem ipsum] [Lorem ipsum] ] ] \end{forest} \caption{A small tree} \label{fig:smart_card_types} \end{figure} \end{document}

and here is how it looks:

The look of the taxonomy tree that I have

And here is what I am trying to replicate:

The first tree that I am trying to replicate Taken from (1) p. 18

The second tree that I am trying to replicate Taken from (1) p. 255

(1): Wolfgang Rankl and Wolfgang Effing, Smart card handbook, 3rd ed. Chichester, West Sussex, England ; Hoboken, NJ, USA: J. Wiley, 2003.

1 Answers1

1

Here is a somewhat simplified version of your code that (I think) does what you want.

enter image description here

\documentclass{article}

\usepackage{tikz} \usepackage[edges]{forest}

\begin{document} \begin{figure}[!ht] \centering \begin{forest} forked edges, folder indent=1cm, where={level()<1}{}{folder, grow'=east}, where={level()>0}{l sep+=1cm}{}, for tree={ fork sep=4mm, thick, edge=thick, font=\sffamily, if n children=0{if n=1{yshift=-5mm}{}, for parent={s sep=0mm}}{draw, minimum height=4ex, minimum width=4cm} } [Lorem ipsum dolor sit amet con, calign=edge midpoint, s sep=2cm, font=\bfseries\sffamily [Lorem ips [Lorem ipsum [Lorem ipsum dolor sit.] [Lorem ipsum dolor s] ] [Lorem ipsum dolor si [Lorem ipsum dolor s] [Lorem ipsum dolo] ] ] [Lorem ipsum dolor sit am [Lorem ipsum d] [Lorem ipsum] [Lorem ipsum] ] ] \end{forest} \caption{A small tree} \label{fig:smart_card_types} \end{figure} \end{document}

Sandy G
  • 42,558