Drawing a centrally aligned tree using LaTeX
up vote
2
down vote
favorite
I am trying to draw a tree in LaTeX via following code. It works; however, it is always aligned to the left. How I can make it aligned to the centre?
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{.style={for tree={parent anchor=south, child anchor=north,align=center,inner sep=2pt}}}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
Note: The code is taken from https://msu.edu/~amunn/latex/sharelatex-trees-forest-v1.pdf (Link deprecated; new version here)
diagrams forest trees
add a comment |
up vote
2
down vote
favorite
I am trying to draw a tree in LaTeX via following code. It works; however, it is always aligned to the left. How I can make it aligned to the centre?
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{.style={for tree={parent anchor=south, child anchor=north,align=center,inner sep=2pt}}}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
Note: The code is taken from https://msu.edu/~amunn/latex/sharelatex-trees-forest-v1.pdf (Link deprecated; new version here)
diagrams forest trees
Welcome to TeX.SE! Please -- as usual here -- complete your given code snippet to be compilable ...
– Kurt
Dec 3 at 16:18
There's a new version of the document you link to. I've removed the old one and added a new link.
– Alan Munn
Dec 3 at 17:12
Either you have a fairly outdated version of Forest or your settings are not being applied to your trees.
– cfr
Dec 4 at 0:15
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am trying to draw a tree in LaTeX via following code. It works; however, it is always aligned to the left. How I can make it aligned to the centre?
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{.style={for tree={parent anchor=south, child anchor=north,align=center,inner sep=2pt}}}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
Note: The code is taken from https://msu.edu/~amunn/latex/sharelatex-trees-forest-v1.pdf (Link deprecated; new version here)
diagrams forest trees
I am trying to draw a tree in LaTeX via following code. It works; however, it is always aligned to the left. How I can make it aligned to the centre?
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{.style={for tree={parent anchor=south, child anchor=north,align=center,inner sep=2pt}}}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
Note: The code is taken from https://msu.edu/~amunn/latex/sharelatex-trees-forest-v1.pdf (Link deprecated; new version here)
diagrams forest trees
diagrams forest trees
edited Dec 3 at 17:11
Alan Munn
158k27423696
158k27423696
asked Dec 3 at 16:12
woody
1135
1135
Welcome to TeX.SE! Please -- as usual here -- complete your given code snippet to be compilable ...
– Kurt
Dec 3 at 16:18
There's a new version of the document you link to. I've removed the old one and added a new link.
– Alan Munn
Dec 3 at 17:12
Either you have a fairly outdated version of Forest or your settings are not being applied to your trees.
– cfr
Dec 4 at 0:15
add a comment |
Welcome to TeX.SE! Please -- as usual here -- complete your given code snippet to be compilable ...
– Kurt
Dec 3 at 16:18
There's a new version of the document you link to. I've removed the old one and added a new link.
– Alan Munn
Dec 3 at 17:12
Either you have a fairly outdated version of Forest or your settings are not being applied to your trees.
– cfr
Dec 4 at 0:15
Welcome to TeX.SE! Please -- as usual here -- complete your given code snippet to be compilable ...
– Kurt
Dec 3 at 16:18
Welcome to TeX.SE! Please -- as usual here -- complete your given code snippet to be compilable ...
– Kurt
Dec 3 at 16:18
There's a new version of the document you link to. I've removed the old one and added a new link.
– Alan Munn
Dec 3 at 17:12
There's a new version of the document you link to. I've removed the old one and added a new link.
– Alan Munn
Dec 3 at 17:12
Either you have a fairly outdated version of Forest or your settings are not being applied to your trees.
– cfr
Dec 4 at 0:15
Either you have a fairly outdated version of Forest or your settings are not being applied to your trees.
– cfr
Dec 4 at 0:15
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
align=center only centres text within nodes. It does not centre the forest relative to the page.
A more fundamental problem is that the settings in .style will not be applied with current Forest. To see this, try adding, blue and notice that your tree stays determinedly black.
Current Forest provides default preamble instead.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

Obviously, you should delete the blue in your real document.
You might, however, want to use
usepackage[linguistics]{forest}
instead which will apply a nice (for linguistics!) set of defaults to your trees without your having to specify them.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[linguistics]{forest}
% forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

This should be the accepted answer. The original code was a hack for forest v1 and was needed because Sharelatex was out of date I forgot that I had that version documented on my web page.
– Alan Munn
Dec 4 at 0:40
@AlanMunn Another answer was accepted before I posted this, so I don't know. Ignasi's answer does answer the actual question. It just repeats the no-longer-working hack.
– cfr
Dec 4 at 1:11
Thanks @cfr, I also think this is the correct answer (I changed the correct answer to this one)
– woody
Dec 4 at 7:18
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
align=center only centres text within nodes. It does not centre the forest relative to the page.
A more fundamental problem is that the settings in .style will not be applied with current Forest. To see this, try adding, blue and notice that your tree stays determinedly black.
Current Forest provides default preamble instead.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

Obviously, you should delete the blue in your real document.
You might, however, want to use
usepackage[linguistics]{forest}
instead which will apply a nice (for linguistics!) set of defaults to your trees without your having to specify them.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[linguistics]{forest}
% forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

This should be the accepted answer. The original code was a hack for forest v1 and was needed because Sharelatex was out of date I forgot that I had that version documented on my web page.
– Alan Munn
Dec 4 at 0:40
@AlanMunn Another answer was accepted before I posted this, so I don't know. Ignasi's answer does answer the actual question. It just repeats the no-longer-working hack.
– cfr
Dec 4 at 1:11
Thanks @cfr, I also think this is the correct answer (I changed the correct answer to this one)
– woody
Dec 4 at 7:18
add a comment |
up vote
3
down vote
accepted
align=center only centres text within nodes. It does not centre the forest relative to the page.
A more fundamental problem is that the settings in .style will not be applied with current Forest. To see this, try adding, blue and notice that your tree stays determinedly black.
Current Forest provides default preamble instead.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

Obviously, you should delete the blue in your real document.
You might, however, want to use
usepackage[linguistics]{forest}
instead which will apply a nice (for linguistics!) set of defaults to your trees without your having to specify them.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[linguistics]{forest}
% forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

This should be the accepted answer. The original code was a hack for forest v1 and was needed because Sharelatex was out of date I forgot that I had that version documented on my web page.
– Alan Munn
Dec 4 at 0:40
@AlanMunn Another answer was accepted before I posted this, so I don't know. Ignasi's answer does answer the actual question. It just repeats the no-longer-working hack.
– cfr
Dec 4 at 1:11
Thanks @cfr, I also think this is the correct answer (I changed the correct answer to this one)
– woody
Dec 4 at 7:18
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
align=center only centres text within nodes. It does not centre the forest relative to the page.
A more fundamental problem is that the settings in .style will not be applied with current Forest. To see this, try adding, blue and notice that your tree stays determinedly black.
Current Forest provides default preamble instead.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

Obviously, you should delete the blue in your real document.
You might, however, want to use
usepackage[linguistics]{forest}
instead which will apply a nice (for linguistics!) set of defaults to your trees without your having to specify them.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[linguistics]{forest}
% forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

align=center only centres text within nodes. It does not centre the forest relative to the page.
A more fundamental problem is that the settings in .style will not be applied with current Forest. To see this, try adding, blue and notice that your tree stays determinedly black.
Current Forest provides default preamble instead.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{forest}
forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

Obviously, you should delete the blue in your real document.
You might, however, want to use
usepackage[linguistics]{forest}
instead which will apply a nice (for linguistics!) set of defaults to your trees without your having to specify them.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[linguistics]{forest}
% forestset{default preamble={for tree={blue,parent anchor=children, child anchor=parent,align=center,inner sep=2pt}}}
begin{document}
begin{center}
begin{forest}
[TP
[DP [D\the] [NP [N\man ]]]
[T'
[T\will ]
[VP
[V\eat ]
[DP [D\a ] [NP [N\burger ]]]
]
]
]
end{forest}
end{center}
end{document}

answered Dec 4 at 0:14
cfr
156k7183377
156k7183377
This should be the accepted answer. The original code was a hack for forest v1 and was needed because Sharelatex was out of date I forgot that I had that version documented on my web page.
– Alan Munn
Dec 4 at 0:40
@AlanMunn Another answer was accepted before I posted this, so I don't know. Ignasi's answer does answer the actual question. It just repeats the no-longer-working hack.
– cfr
Dec 4 at 1:11
Thanks @cfr, I also think this is the correct answer (I changed the correct answer to this one)
– woody
Dec 4 at 7:18
add a comment |
This should be the accepted answer. The original code was a hack for forest v1 and was needed because Sharelatex was out of date I forgot that I had that version documented on my web page.
– Alan Munn
Dec 4 at 0:40
@AlanMunn Another answer was accepted before I posted this, so I don't know. Ignasi's answer does answer the actual question. It just repeats the no-longer-working hack.
– cfr
Dec 4 at 1:11
Thanks @cfr, I also think this is the correct answer (I changed the correct answer to this one)
– woody
Dec 4 at 7:18
This should be the accepted answer. The original code was a hack for forest v1 and was needed because Sharelatex was out of date I forgot that I had that version documented on my web page.
– Alan Munn
Dec 4 at 0:40
This should be the accepted answer. The original code was a hack for forest v1 and was needed because Sharelatex was out of date I forgot that I had that version documented on my web page.
– Alan Munn
Dec 4 at 0:40
@AlanMunn Another answer was accepted before I posted this, so I don't know. Ignasi's answer does answer the actual question. It just repeats the no-longer-working hack.
– cfr
Dec 4 at 1:11
@AlanMunn Another answer was accepted before I posted this, so I don't know. Ignasi's answer does answer the actual question. It just repeats the no-longer-working hack.
– cfr
Dec 4 at 1:11
Thanks @cfr, I also think this is the correct answer (I changed the correct answer to this one)
– woody
Dec 4 at 7:18
Thanks @cfr, I also think this is the correct answer (I changed the correct answer to this one)
– woody
Dec 4 at 7:18
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462998%2fdrawing-a-centrally-aligned-tree-using-latex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to TeX.SE! Please -- as usual here -- complete your given code snippet to be compilable ...
– Kurt
Dec 3 at 16:18
There's a new version of the document you link to. I've removed the old one and added a new link.
– Alan Munn
Dec 3 at 17:12
Either you have a fairly outdated version of Forest or your settings are not being applied to your trees.
– cfr
Dec 4 at 0:15