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)











share|improve this question
























  • 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















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)











share|improve this question
























  • 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













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)











share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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










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}


blue tree



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}


with <code>linguistics</code>






share|improve this answer





















  • 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











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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}


blue tree



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}


with <code>linguistics</code>






share|improve this answer





















  • 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















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}


blue tree



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}


with <code>linguistics</code>






share|improve this answer





















  • 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













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}


blue tree



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}


with <code>linguistics</code>






share|improve this answer












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}


blue tree



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}


with <code>linguistics</code>







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to send String Array data to Server using php in android

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Is anime1.com a legal site for watching anime?