1

I am using a tree like:

\begin{figure}
{\scriptsize
\begin{forest}
  for tree={
    font=\ttfamily,
    grow'=0,
    child anchor=west,
    parent anchor=south,
    anchor=west,
    calign=first,
    edge path={
      \noexpand\path [draw, \forestoption{edge}]
      (!u.south west) +(7.5pt,0) |- node[fill,inner sep=1.25pt] {} (.child anchor)\forestoption{edge label};
    },
    before typesetting nodes={
      if n=1
        {insert before={[,phantom]}}
        {}
    },
    fit=band,
    before computing xy={l=15pt},
  }
[Evaluation Setups, Test Sets and Models
  [Closed w/ Closed Hyper-Parameters optimised from Test Set 1
    [Test Set 1: Textual Patterns Output Test Set
      [Distantly Supervised Classifier]
      [Cost Sensitive Classifier]
      [Textual Patterns Baseline]
      [Naive Baselines]
    ] 
  [Test Set 2: Freshly Annotated Claim Labels
    [Distantly Supervised Classifier]
    [Cost Sensitive Classifier]
    [Textual Patterns Baseline]
    [Naive Baselines]
  ]  
 ]
  [Open w/ Closed Hyper-Parameters optimised from Test Set 1
    [Test Set 1: Textual Patterns Output Test Set
        [Distantly Supervised Classifier]
        [Cost Sensitive Classifier]
        [Textual Patterns Baseline]
        [Naive Baselines]
    ] 
    [Test Set 2: Freshly Annotated Claim Labels
        [Distantly Supervised Classifier]
        [Cost Sensitive Classifier]
        [Textual Patterns Baseline]
        [Naive Baselines]
    ]  
  ]
  [Open w/ Open Hyper-Parameters optimised from Test Set 1
     [Test Set 1: Textual Patterns Output Test Set
        [Distantly Supervised Classifier]
        [Cost Sensitive Classifier]
        [Textual Patterns Baseline]
        [Naive Baselines]
    ] 
  [Test Set 2: Freshly Annotated Claim Labels
    [Distantly Supervised Classifier]
      [Cost Sensitive Classifier]
      [Textual Patterns Baseline]
      [Naive Baselines]
    ]  
  ]
]
\end{forest}
}
\caption{Summary of Experiments}
\end{figure}

Adapted from:

Changing font size in forest decision tree

And:

Making a (simple) directory tree

Why is this figure not compiling? I am pretty sure the square brackets do line up.

  • No, really. Not like that. You surely have a class and a document environment and some package we need to make it work! Otherwise, no wonder you get errors! When asking about an error, always include the exact text of the error message, together with the code required to reproduce it. – cfr Sep 11 '16 at 00:07

2 Answers2

3

Trees can take , within their nodes. I don't understand the suggestion to use \. Certainly \, will not do the same thing!

The only issue when including commas is that Forest reads what is in the node as a comma-separated key list of the form

<node content>, <key>=<value>, <key>=<value>, ...

In order to prevent Forest from trying to read

Evaluation Setups, Test Sets and Models

as a node with content Evaluation Setups to which the Test Sets and Models option should be applied, you just need to protect the contents with curly brackets.

{Evaluation Setups, Test Sets and Models}

comma in root node

However, I strongly recommend using the updated options provided by current Forest, including the edges library.

This greatly simplifies the tree's preamble and provides a more flexible and robust solution.

\documentclass[border=10pt,multi,tikz]{standalone}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
  for tree={%
    folder,
    font=\ttfamily,
    grow'=0,
    edge label={node [midway, inner sep=1.25pt, fill] {}},
  }
  [{Evaluation Setups, Test Sets and Models}
    [Closed w/ Closed Hyper-Parameters optimised from Test Set 1
      [Test Set 1: Textual Patterns Output Test Set
        [Distantly Supervised Classifier]
        [Cost Sensitive Classifier]
        [Textual Patterns Baseline]
        [Naive Baselines]
      ]
    [Test Set 2: Freshly Annotated Claim Labels
      [Distantly Supervised Classifier]
      [Cost Sensitive Classifier]
      [Textual Patterns Baseline]
      [Naive Baselines]
    ]
   ]
    [Open w/ Closed Hyper-Parameters optimised from Test Set 1
      [Test Set 1: Textual Patterns Output Test Set
          [Distantly Supervised Classifier]
          [Cost Sensitive Classifier]
          [Textual Patterns Baseline]
          [Naive Baselines]
      ]
      [Test Set 2: Freshly Annotated Claim Labels
          [Distantly Supervised Classifier]
          [Cost Sensitive Classifier]
          [Textual Patterns Baseline]
          [Naive Baselines]
      ]
    ]
    [Open w/ Open Hyper-Parameters optimised from Test Set 1
       [Test Set 1: Textual Patterns Output Test Set
          [Distantly Supervised Classifier]
          [Cost Sensitive Classifier]
          [Textual Patterns Baseline]
          [Naive Baselines]
      ]
    [Test Set 2: Freshly Annotated Claim Labels
      [Distantly Supervised Classifier]
        [Cost Sensitive Classifier]
        [Textual Patterns Baseline]
        [Naive Baselines]
      ]
    ]
  ]
\end{forest}
\end{document}

current version

cfr
  • 198,882
2

I figured this out. Trees cannot take , within their nodes. The solution was to comment this out using \.