Not setting the location when using tikz
I'm using tikz in LyX. I'm trying to build a basic graph. Is it possible to somehow add the path of the nodes without setting the location of each one?
For now I used:
begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) at (0,0) {$v_1$};
node[circle,draw] (B) at (4,0) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}
Output:

But is it possible to remove the at (4,0) part so tikz will generator the graph alone? I don't really care where the nodes are located, I just care about the exitness of them and the paths between them. The desired code looks something like:
begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) {$v_1$};
node[circle,draw] (B) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}
And the output should be the same (maybe 90 degree different but same logic).
The main goal is to just declare the path and tikz will do the hard work for me.
I was using the WebGraphviz (Graphviz in the Browser). There I could just declare the paths it would build the graph for me (without setting the locations). I understood that it is not possible to use Graphviz in LyX and everyone who uses it, uploads an image instead. I prefer to build the nodes so it would look better.
Is it possible to somehow create graph without declaring the coordinates for each node?
tikz-pgf lyx
add a comment |
I'm using tikz in LyX. I'm trying to build a basic graph. Is it possible to somehow add the path of the nodes without setting the location of each one?
For now I used:
begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) at (0,0) {$v_1$};
node[circle,draw] (B) at (4,0) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}
Output:

But is it possible to remove the at (4,0) part so tikz will generator the graph alone? I don't really care where the nodes are located, I just care about the exitness of them and the paths between them. The desired code looks something like:
begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) {$v_1$};
node[circle,draw] (B) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}
And the output should be the same (maybe 90 degree different but same logic).
The main goal is to just declare the path and tikz will do the hard work for me.
I was using the WebGraphviz (Graphviz in the Browser). There I could just declare the paths it would build the graph for me (without setting the locations). I understood that it is not possible to use Graphviz in LyX and everyone who uses it, uploads an image instead. I prefer to build the nodes so it would look better.
Is it possible to somehow create graph without declaring the coordinates for each node?
tikz-pgf lyx
Yes, it seems to me you are looking for thechainslibrary.
– marmot
Jan 20 at 22:53
add a comment |
I'm using tikz in LyX. I'm trying to build a basic graph. Is it possible to somehow add the path of the nodes without setting the location of each one?
For now I used:
begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) at (0,0) {$v_1$};
node[circle,draw] (B) at (4,0) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}
Output:

But is it possible to remove the at (4,0) part so tikz will generator the graph alone? I don't really care where the nodes are located, I just care about the exitness of them and the paths between them. The desired code looks something like:
begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) {$v_1$};
node[circle,draw] (B) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}
And the output should be the same (maybe 90 degree different but same logic).
The main goal is to just declare the path and tikz will do the hard work for me.
I was using the WebGraphviz (Graphviz in the Browser). There I could just declare the paths it would build the graph for me (without setting the locations). I understood that it is not possible to use Graphviz in LyX and everyone who uses it, uploads an image instead. I prefer to build the nodes so it would look better.
Is it possible to somehow create graph without declaring the coordinates for each node?
tikz-pgf lyx
I'm using tikz in LyX. I'm trying to build a basic graph. Is it possible to somehow add the path of the nodes without setting the location of each one?
For now I used:
begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) at (0,0) {$v_1$};
node[circle,draw] (B) at (4,0) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}
Output:

But is it possible to remove the at (4,0) part so tikz will generator the graph alone? I don't really care where the nodes are located, I just care about the exitness of them and the paths between them. The desired code looks something like:
begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) {$v_1$};
node[circle,draw] (B) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}
And the output should be the same (maybe 90 degree different but same logic).
The main goal is to just declare the path and tikz will do the hard work for me.
I was using the WebGraphviz (Graphviz in the Browser). There I could just declare the paths it would build the graph for me (without setting the locations). I understood that it is not possible to use Graphviz in LyX and everyone who uses it, uploads an image instead. I prefer to build the nodes so it would look better.
Is it possible to somehow create graph without declaring the coordinates for each node?
tikz-pgf lyx
tikz-pgf lyx
edited Jan 20 at 22:08
vesii
asked Jan 20 at 22:02
vesiivesii
785
785
Yes, it seems to me you are looking for thechainslibrary.
– marmot
Jan 20 at 22:53
add a comment |
Yes, it seems to me you are looking for thechainslibrary.
– marmot
Jan 20 at 22:53
Yes, it seems to me you are looking for the
chains library.– marmot
Jan 20 at 22:53
Yes, it seems to me you are looking for the
chains library.– marmot
Jan 20 at 22:53
add a comment |
2 Answers
2
active
oldest
votes
The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).

documentclass[tikz,border=5mm]{standalone}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}
graph[grow right=30mm,nodes={circle,draw}] {
1 ->[edge label={a}] 2 ->[edge label={b}] 3;
1 -- [bend right,edge label'={c}] 3;
};
end{tikzpicture}
end{document}
add a comment |
A very minimal realization of your suggestion might be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains}
begin{document}
begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
node [c,on chain] {A};
node [c,on chain] {B};
end{tikzpicture}
end{document}

A slightly more sophisticated version could be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains,decorations.markings}
newcounter{eindex}
begin{document}
begin{tikzpicture}[node distance=2.4cm,start chain,%
midmark/.style={postaction={decorate,decoration={markings,
mark=at position 0.5 with {stepcounter{eindex}
node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
c/.style={circle,draw,join},every join/.style={-latex,midmark}]
node [c,on chain] {A};
node [c,on chain] {B};
node [c,on chain] {C};
end{tikzpicture}
end{document}

Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.
add a comment |
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
});
}
});
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%2f471054%2fnot-setting-the-location-when-using-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).

documentclass[tikz,border=5mm]{standalone}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}
graph[grow right=30mm,nodes={circle,draw}] {
1 ->[edge label={a}] 2 ->[edge label={b}] 3;
1 -- [bend right,edge label'={c}] 3;
};
end{tikzpicture}
end{document}
add a comment |
The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).

documentclass[tikz,border=5mm]{standalone}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}
graph[grow right=30mm,nodes={circle,draw}] {
1 ->[edge label={a}] 2 ->[edge label={b}] 3;
1 -- [bend right,edge label'={c}] 3;
};
end{tikzpicture}
end{document}
add a comment |
The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).

documentclass[tikz,border=5mm]{standalone}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}
graph[grow right=30mm,nodes={circle,draw}] {
1 ->[edge label={a}] 2 ->[edge label={b}] 3;
1 -- [bend right,edge label'={c}] 3;
};
end{tikzpicture}
end{document}
The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).

documentclass[tikz,border=5mm]{standalone}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}
graph[grow right=30mm,nodes={circle,draw}] {
1 ->[edge label={a}] 2 ->[edge label={b}] 3;
1 -- [bend right,edge label'={c}] 3;
};
end{tikzpicture}
end{document}
answered Jan 21 at 6:26
AndréCAndréC
8,78411447
8,78411447
add a comment |
add a comment |
A very minimal realization of your suggestion might be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains}
begin{document}
begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
node [c,on chain] {A};
node [c,on chain] {B};
end{tikzpicture}
end{document}

A slightly more sophisticated version could be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains,decorations.markings}
newcounter{eindex}
begin{document}
begin{tikzpicture}[node distance=2.4cm,start chain,%
midmark/.style={postaction={decorate,decoration={markings,
mark=at position 0.5 with {stepcounter{eindex}
node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
c/.style={circle,draw,join},every join/.style={-latex,midmark}]
node [c,on chain] {A};
node [c,on chain] {B};
node [c,on chain] {C};
end{tikzpicture}
end{document}

Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.
add a comment |
A very minimal realization of your suggestion might be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains}
begin{document}
begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
node [c,on chain] {A};
node [c,on chain] {B};
end{tikzpicture}
end{document}

A slightly more sophisticated version could be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains,decorations.markings}
newcounter{eindex}
begin{document}
begin{tikzpicture}[node distance=2.4cm,start chain,%
midmark/.style={postaction={decorate,decoration={markings,
mark=at position 0.5 with {stepcounter{eindex}
node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
c/.style={circle,draw,join},every join/.style={-latex,midmark}]
node [c,on chain] {A};
node [c,on chain] {B};
node [c,on chain] {C};
end{tikzpicture}
end{document}

Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.
add a comment |
A very minimal realization of your suggestion might be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains}
begin{document}
begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
node [c,on chain] {A};
node [c,on chain] {B};
end{tikzpicture}
end{document}

A slightly more sophisticated version could be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains,decorations.markings}
newcounter{eindex}
begin{document}
begin{tikzpicture}[node distance=2.4cm,start chain,%
midmark/.style={postaction={decorate,decoration={markings,
mark=at position 0.5 with {stepcounter{eindex}
node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
c/.style={circle,draw,join},every join/.style={-latex,midmark}]
node [c,on chain] {A};
node [c,on chain] {B};
node [c,on chain] {C};
end{tikzpicture}
end{document}

Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.
A very minimal realization of your suggestion might be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains}
begin{document}
begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
node [c,on chain] {A};
node [c,on chain] {B};
end{tikzpicture}
end{document}

A slightly more sophisticated version could be
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{chains,decorations.markings}
newcounter{eindex}
begin{document}
begin{tikzpicture}[node distance=2.4cm,start chain,%
midmark/.style={postaction={decorate,decoration={markings,
mark=at position 0.5 with {stepcounter{eindex}
node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
c/.style={circle,draw,join},every join/.style={-latex,midmark}]
node [c,on chain] {A};
node [c,on chain] {B};
node [c,on chain] {C};
end{tikzpicture}
end{document}

Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.
edited Jan 20 at 23:05
answered Jan 20 at 22:59
marmotmarmot
95.1k4110210
95.1k4110210
add a comment |
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.
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%2f471054%2fnot-setting-the-location-when-using-tikz%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
Yes, it seems to me you are looking for the
chainslibrary.– marmot
Jan 20 at 22:53