How to draw a node with two options using TikZ graphs in LaTeX












3















I'm trying to draw a node optionA with two options option1 and option3 which should appear in 45 degrees from the center. Actually, I tried to change this:



tikz graph [grow right=2cm] { optionA -> option1 -> option2 };


to



tikz graph [grow right=2cm] { optionA -> {option1, option2} };


But option1 and option2 should equally distanced (45/-45 degrees) from optionA.



Thanks for any suggestion.



Edit:



Here is this within a document:



documentclass{article}
usepackage{tikz}
usetikzlibrary{graphs}

begin{document}
tikz graph [grow right=2cm] { optionA -> {option1, option2} };
end{document}









share|improve this question

























  • @marmot, Binary trees appears in a vertical manner. I wanted just 2 options that will appear horizontally.

    – user4712458
    Feb 24 at 12:18
















3















I'm trying to draw a node optionA with two options option1 and option3 which should appear in 45 degrees from the center. Actually, I tried to change this:



tikz graph [grow right=2cm] { optionA -> option1 -> option2 };


to



tikz graph [grow right=2cm] { optionA -> {option1, option2} };


But option1 and option2 should equally distanced (45/-45 degrees) from optionA.



Thanks for any suggestion.



Edit:



Here is this within a document:



documentclass{article}
usepackage{tikz}
usetikzlibrary{graphs}

begin{document}
tikz graph [grow right=2cm] { optionA -> {option1, option2} };
end{document}









share|improve this question

























  • @marmot, Binary trees appears in a vertical manner. I wanted just 2 options that will appear horizontally.

    – user4712458
    Feb 24 at 12:18














3












3








3


0






I'm trying to draw a node optionA with two options option1 and option3 which should appear in 45 degrees from the center. Actually, I tried to change this:



tikz graph [grow right=2cm] { optionA -> option1 -> option2 };


to



tikz graph [grow right=2cm] { optionA -> {option1, option2} };


But option1 and option2 should equally distanced (45/-45 degrees) from optionA.



Thanks for any suggestion.



Edit:



Here is this within a document:



documentclass{article}
usepackage{tikz}
usetikzlibrary{graphs}

begin{document}
tikz graph [grow right=2cm] { optionA -> {option1, option2} };
end{document}









share|improve this question
















I'm trying to draw a node optionA with two options option1 and option3 which should appear in 45 degrees from the center. Actually, I tried to change this:



tikz graph [grow right=2cm] { optionA -> option1 -> option2 };


to



tikz graph [grow right=2cm] { optionA -> {option1, option2} };


But option1 and option2 should equally distanced (45/-45 degrees) from optionA.



Thanks for any suggestion.



Edit:



Here is this within a document:



documentclass{article}
usepackage{tikz}
usetikzlibrary{graphs}

begin{document}
tikz graph [grow right=2cm] { optionA -> {option1, option2} };
end{document}






tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 24 at 12:20







user4712458

















asked Feb 24 at 11:57









user4712458user4712458

926




926













  • @marmot, Binary trees appears in a vertical manner. I wanted just 2 options that will appear horizontally.

    – user4712458
    Feb 24 at 12:18



















  • @marmot, Binary trees appears in a vertical manner. I wanted just 2 options that will appear horizontally.

    – user4712458
    Feb 24 at 12:18

















@marmot, Binary trees appears in a vertical manner. I wanted just 2 options that will appear horizontally.

– user4712458
Feb 24 at 12:18





@marmot, Binary trees appears in a vertical manner. I wanted just 2 options that will appear horizontally.

– user4712458
Feb 24 at 12:18










1 Answer
1






active

oldest

votes


















5














binary tree layout gives you such graphs. The following example requires lualatex.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{graphs, graphdrawing}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm,
grow=right] { optionA -> {option1, option2} };
end{tikzpicture}

begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm] { optionA -> {option1, option2} };
end{tikzpicture}
end{document}


enter image description here



For trees you may want to consider using forest, which, unlike the above, does not require lualatex, and is really powerful.



documentclass[tikz,border=3.14mm]{standalone}
usepackage[edges]{forest}
begin{document}
begin{forest}
for tree={grow'=east,edge = {-latex},
s sep=2cm,l sep=2cm
}
[optionA
[option1]
[option2]
]
end{forest}
end{document}


enter image description here






share|improve this answer


























  • The first option is exactly how I want to appear them. The graphdrawing requires to run LuaLaTex, is it any way that I can avoid to use it :/

    – user4712458
    Feb 24 at 12:34






  • 1





    @user4712458 Honestly, if you want to draw such trees you will IMHO be much better off with forest, which does not require lualatex. AFAIK the graph drawing libraries, on the other hand, do require lualatex.

    – marmot
    Feb 24 at 12:35








  • 1





    Yes, using the forest now it's perfect! Thank you!!

    – user4712458
    Feb 24 at 12:44












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',
autoActivateHeartbeat: false,
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%2f476447%2fhow-to-draw-a-node-with-two-options-using-tikz-graphs-in-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









5














binary tree layout gives you such graphs. The following example requires lualatex.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{graphs, graphdrawing}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm,
grow=right] { optionA -> {option1, option2} };
end{tikzpicture}

begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm] { optionA -> {option1, option2} };
end{tikzpicture}
end{document}


enter image description here



For trees you may want to consider using forest, which, unlike the above, does not require lualatex, and is really powerful.



documentclass[tikz,border=3.14mm]{standalone}
usepackage[edges]{forest}
begin{document}
begin{forest}
for tree={grow'=east,edge = {-latex},
s sep=2cm,l sep=2cm
}
[optionA
[option1]
[option2]
]
end{forest}
end{document}


enter image description here






share|improve this answer


























  • The first option is exactly how I want to appear them. The graphdrawing requires to run LuaLaTex, is it any way that I can avoid to use it :/

    – user4712458
    Feb 24 at 12:34






  • 1





    @user4712458 Honestly, if you want to draw such trees you will IMHO be much better off with forest, which does not require lualatex. AFAIK the graph drawing libraries, on the other hand, do require lualatex.

    – marmot
    Feb 24 at 12:35








  • 1





    Yes, using the forest now it's perfect! Thank you!!

    – user4712458
    Feb 24 at 12:44
















5














binary tree layout gives you such graphs. The following example requires lualatex.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{graphs, graphdrawing}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm,
grow=right] { optionA -> {option1, option2} };
end{tikzpicture}

begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm] { optionA -> {option1, option2} };
end{tikzpicture}
end{document}


enter image description here



For trees you may want to consider using forest, which, unlike the above, does not require lualatex, and is really powerful.



documentclass[tikz,border=3.14mm]{standalone}
usepackage[edges]{forest}
begin{document}
begin{forest}
for tree={grow'=east,edge = {-latex},
s sep=2cm,l sep=2cm
}
[optionA
[option1]
[option2]
]
end{forest}
end{document}


enter image description here






share|improve this answer


























  • The first option is exactly how I want to appear them. The graphdrawing requires to run LuaLaTex, is it any way that I can avoid to use it :/

    – user4712458
    Feb 24 at 12:34






  • 1





    @user4712458 Honestly, if you want to draw such trees you will IMHO be much better off with forest, which does not require lualatex. AFAIK the graph drawing libraries, on the other hand, do require lualatex.

    – marmot
    Feb 24 at 12:35








  • 1





    Yes, using the forest now it's perfect! Thank you!!

    – user4712458
    Feb 24 at 12:44














5












5








5







binary tree layout gives you such graphs. The following example requires lualatex.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{graphs, graphdrawing}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm,
grow=right] { optionA -> {option1, option2} };
end{tikzpicture}

begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm] { optionA -> {option1, option2} };
end{tikzpicture}
end{document}


enter image description here



For trees you may want to consider using forest, which, unlike the above, does not require lualatex, and is really powerful.



documentclass[tikz,border=3.14mm]{standalone}
usepackage[edges]{forest}
begin{document}
begin{forest}
for tree={grow'=east,edge = {-latex},
s sep=2cm,l sep=2cm
}
[optionA
[option1]
[option2]
]
end{forest}
end{document}


enter image description here






share|improve this answer















binary tree layout gives you such graphs. The following example requires lualatex.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{graphs, graphdrawing}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm,
grow=right] { optionA -> {option1, option2} };
end{tikzpicture}

begin{tikzpicture}
graph [binary tree layout, level distance=2cm, sibling distance=2cm] { optionA -> {option1, option2} };
end{tikzpicture}
end{document}


enter image description here



For trees you may want to consider using forest, which, unlike the above, does not require lualatex, and is really powerful.



documentclass[tikz,border=3.14mm]{standalone}
usepackage[edges]{forest}
begin{document}
begin{forest}
for tree={grow'=east,edge = {-latex},
s sep=2cm,l sep=2cm
}
[optionA
[option1]
[option2]
]
end{forest}
end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 24 at 12:40

























answered Feb 24 at 12:20









marmotmarmot

112k5144271




112k5144271













  • The first option is exactly how I want to appear them. The graphdrawing requires to run LuaLaTex, is it any way that I can avoid to use it :/

    – user4712458
    Feb 24 at 12:34






  • 1





    @user4712458 Honestly, if you want to draw such trees you will IMHO be much better off with forest, which does not require lualatex. AFAIK the graph drawing libraries, on the other hand, do require lualatex.

    – marmot
    Feb 24 at 12:35








  • 1





    Yes, using the forest now it's perfect! Thank you!!

    – user4712458
    Feb 24 at 12:44



















  • The first option is exactly how I want to appear them. The graphdrawing requires to run LuaLaTex, is it any way that I can avoid to use it :/

    – user4712458
    Feb 24 at 12:34






  • 1





    @user4712458 Honestly, if you want to draw such trees you will IMHO be much better off with forest, which does not require lualatex. AFAIK the graph drawing libraries, on the other hand, do require lualatex.

    – marmot
    Feb 24 at 12:35








  • 1





    Yes, using the forest now it's perfect! Thank you!!

    – user4712458
    Feb 24 at 12:44

















The first option is exactly how I want to appear them. The graphdrawing requires to run LuaLaTex, is it any way that I can avoid to use it :/

– user4712458
Feb 24 at 12:34





The first option is exactly how I want to appear them. The graphdrawing requires to run LuaLaTex, is it any way that I can avoid to use it :/

– user4712458
Feb 24 at 12:34




1




1





@user4712458 Honestly, if you want to draw such trees you will IMHO be much better off with forest, which does not require lualatex. AFAIK the graph drawing libraries, on the other hand, do require lualatex.

– marmot
Feb 24 at 12:35







@user4712458 Honestly, if you want to draw such trees you will IMHO be much better off with forest, which does not require lualatex. AFAIK the graph drawing libraries, on the other hand, do require lualatex.

– marmot
Feb 24 at 12:35






1




1





Yes, using the forest now it's perfect! Thank you!!

– user4712458
Feb 24 at 12:44





Yes, using the forest now it's perfect! Thank you!!

– user4712458
Feb 24 at 12:44


















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476447%2fhow-to-draw-a-node-with-two-options-using-tikz-graphs-in-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

Probability when a professor distributes a quiz and homework assignment to a class of n students.

Aardman Animations

Are they similar matrix