# Tag Info

## New answers tagged trees

2

I know this is quite an old topic, but I've came to this problem recently. This is my solution, but remember I do not master Latex or Tikz. So I'm sure many things could be done in a better way... \documentclass[11pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[portuguese]{babel} \usepackage[T1]{fontenc} \usepackage{amsmath} ...

1

Inserting a blank line in the solution environment to create a new paragraph before the newicktree environment did the trick. See below for full code. % Compile with XeLaTeX to deal with EPS graphics in trees. \documentclass[letterpaper,12pt,addpoints]{exam} \usepackage{newicktree} \printanswers \begin{document} \begin{questions} \question[5] The tree is ...

4

Setting the trees to use 12pt font means they take more space than default. (Standard classes default to 10pt. standalone, which is often used to create graphics, defaults to 11pt.) Here is a forest version with no adjustments: \documentclass[12pt,tikz]{standalone} \usepackage{forest} \begin{document} \begin{forest} [{$b$}, name=z [{$b_1$}, ...

5

What about using a package that is dedicated to drawing trees such as these? If you're open to this, there are two main such packages: forest and tikz-qtree, both of which are built on top of TikZ. Here is your tree using the forest package. The tikz-qtree package uses a similar syntax, but, as @cfr mentioned in a comment, forest is better at making trees ...

1

forest documentation has some examples where different trees are aligned being all of them children from a phantom parent. This solution can be also applied in this case. Once both trees are only branches, there's no need for overlay or tikzmark. I understand that this solution is not always valid, but it is for this particular example. ...

4

As @cfr suggested in the comment section, this can be done by making use of the tikzmark library. You need to add \usetikzlibrary{tikzmark} to your preamble. Then, you can put a \tikzmark in each forest environment and then add a tikzpicture after that with the options overlay and remember picture. When you issue the \draw command, you need to prefix the ...

2

You do not need no edge in addition to phantom. You can align the two Ns by using another tier option: \documentclass{article} \usepackage{forest} \forestset{ dg edges/.style={% for tree={% parent anchor=south, child anchor=north, align=center, base=bottom, where n children=0{% tier=word, edge=dotted, ...

3

Here's a forest solution which numbers the nodes automatically: \documentclass[tikz,border=5pt]{standalone} \usepackage{forest} \begin{document} \bracketset{action character=@}% based on code from page 22 of forest's manual \newcount\xcount \def\x{@@\advance\xcount1 \edef\xtemp{$\noexpand{\the\xcount}$}% \expandafter\bracketResume\xtemp } ...

1

The calign with current edge option did the trick: \documentclass{article} \usepackage{forest} \forestset{ dg edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom,where n children=0{tier=word,edge=dotted,calign with current edge}{}}}, } \begin{document} \begin{forest} dg edges [V [N [D [the] ] [child] ] ...

3

You could try the new graphs stuff in the latest PGF with lualatex: \documentclass[tikz,border=5]{standalone} \usetikzlibrary{graphs,graphdrawing,arrows.meta} \usegdlibrary{trees} \begin{document} \begin{tikzpicture}[>=Stealth] \graph [tree layout, grow=down]{ 1 <- 2 <- { 3 <- { 5 <- {10,11,12}, 6 <- {13,14}, 7 <- {,15} ...

3

A bit kludgy, but shows how to specify a custom growth function and a sneaky way of duplicating the words at the bottom. I pinched a couple of styles from from Jesse's answer: \documentclass[tikz, border=5]{standalone} % An (incomplete) growth function \makeatletter \def\tikz@grow@tree{% \tikzset{shift=(270:\tikzleveldistance)}% ...

5

This is an attempt where tikz tree is used. To align the text at the bottom a dfont style is defined. Code \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes,trees,calc} \begin{document} \tikzset{ treenode/.style = {inner sep=0pt, outer sep=2pt, font=\sffamily}, edge from parent/.style={draw, edge from parent path= ...

10

The most recent release of PGF has a number of graph drawing algorithms (requiring lualatex) including a version of the Reingold–Tilford method and can easily handle large numbers of nodes. In the simplest case a tree can be specified like this: \documentclass[tikz,border=5]{standalone} \usetikzlibrary{graphs,graphdrawing,arrows.meta} \usegdlibrary{trees} ...

Top 50 recent answers are included