Create command that uses a foreach to be used in a barycentric cs
I'm trying create a command that will be used in a barycentric cs:
.
I will use the barycentric cs
a lot of time to get a node the middle of others, so I'm trying to make it less painfull for myself. It will also be used in another command that uses a list as its parameter.
Let's say I have this code:
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
end{tikzpicture}
end{document}
I'm trying to create a command so that, instead of using node (bc#) at (barycentric cs:a=1,b=1,c=1,d=1,<...>) {text};
, I only have to write node (x) at (baricentric cs:listforbarycentrics{a,b,c,d}) {text};
.
I tried with this command code:
newcommand{listforbarycentrics}[1]{foreach n in {#1}{
n=1,
};
}
However, it doesn't works. It may be because a comma at the end of the list in the barycentric cs:
(like thisbarycentric cs:a=1,b=1,c=1,d=1,
) creates an error, however I'm not sure.
tikz-pgf foreach
add a comment |
I'm trying create a command that will be used in a barycentric cs:
.
I will use the barycentric cs
a lot of time to get a node the middle of others, so I'm trying to make it less painfull for myself. It will also be used in another command that uses a list as its parameter.
Let's say I have this code:
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
end{tikzpicture}
end{document}
I'm trying to create a command so that, instead of using node (bc#) at (barycentric cs:a=1,b=1,c=1,d=1,<...>) {text};
, I only have to write node (x) at (baricentric cs:listforbarycentrics{a,b,c,d}) {text};
.
I tried with this command code:
newcommand{listforbarycentrics}[1]{foreach n in {#1}{
n=1,
};
}
However, it doesn't works. It may be because a comma at the end of the list in the barycentric cs:
(like thisbarycentric cs:a=1,b=1,c=1,d=1,
) creates an error, however I'm not sure.
tikz-pgf foreach
Your strategy works in principle if you do something likenewcommand{listforbarycentrics}[1]{foreach n [count=m] in {#1}{ ifnumm=1 xdefmybary{n=1} else xdefmybary{mybary,n=1} fi}} listforbarycentrics{a,b,c,d} node (x) at (barycentric cs:mybary) {text};
but I would use a style for that.
– marmot
2 hours ago
add a comment |
I'm trying create a command that will be used in a barycentric cs:
.
I will use the barycentric cs
a lot of time to get a node the middle of others, so I'm trying to make it less painfull for myself. It will also be used in another command that uses a list as its parameter.
Let's say I have this code:
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
end{tikzpicture}
end{document}
I'm trying to create a command so that, instead of using node (bc#) at (barycentric cs:a=1,b=1,c=1,d=1,<...>) {text};
, I only have to write node (x) at (baricentric cs:listforbarycentrics{a,b,c,d}) {text};
.
I tried with this command code:
newcommand{listforbarycentrics}[1]{foreach n in {#1}{
n=1,
};
}
However, it doesn't works. It may be because a comma at the end of the list in the barycentric cs:
(like thisbarycentric cs:a=1,b=1,c=1,d=1,
) creates an error, however I'm not sure.
tikz-pgf foreach
I'm trying create a command that will be used in a barycentric cs:
.
I will use the barycentric cs
a lot of time to get a node the middle of others, so I'm trying to make it less painfull for myself. It will also be used in another command that uses a list as its parameter.
Let's say I have this code:
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
end{tikzpicture}
end{document}
I'm trying to create a command so that, instead of using node (bc#) at (barycentric cs:a=1,b=1,c=1,d=1,<...>) {text};
, I only have to write node (x) at (baricentric cs:listforbarycentrics{a,b,c,d}) {text};
.
I tried with this command code:
newcommand{listforbarycentrics}[1]{foreach n in {#1}{
n=1,
};
}
However, it doesn't works. It may be because a comma at the end of the list in the barycentric cs:
(like thisbarycentric cs:a=1,b=1,c=1,d=1,
) creates an error, however I'm not sure.
tikz-pgf foreach
tikz-pgf foreach
asked 3 hours ago
Vinccool96Vinccool96
32810
32810
Your strategy works in principle if you do something likenewcommand{listforbarycentrics}[1]{foreach n [count=m] in {#1}{ ifnumm=1 xdefmybary{n=1} else xdefmybary{mybary,n=1} fi}} listforbarycentrics{a,b,c,d} node (x) at (barycentric cs:mybary) {text};
but I would use a style for that.
– marmot
2 hours ago
add a comment |
Your strategy works in principle if you do something likenewcommand{listforbarycentrics}[1]{foreach n [count=m] in {#1}{ ifnumm=1 xdefmybary{n=1} else xdefmybary{mybary,n=1} fi}} listforbarycentrics{a,b,c,d} node (x) at (barycentric cs:mybary) {text};
but I would use a style for that.
– marmot
2 hours ago
Your strategy works in principle if you do something like
newcommand{listforbarycentrics}[1]{foreach n [count=m] in {#1}{ ifnumm=1 xdefmybary{n=1} else xdefmybary{mybary,n=1} fi}} listforbarycentrics{a,b,c,d} node (x) at (barycentric cs:mybary) {text};
but I would use a style for that.– marmot
2 hours ago
Your strategy works in principle if you do something like
newcommand{listforbarycentrics}[1]{foreach n [count=m] in {#1}{ ifnumm=1 xdefmybary{n=1} else xdefmybary{mybary,n=1} fi}} listforbarycentrics{a,b,c,d} node (x) at (barycentric cs:mybary) {text};
but I would use a style for that.– marmot
2 hours ago
add a comment |
1 Answer
1
active
oldest
votes
Something like this?
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
},
barycentric setup/.code={foreach X [count=Y] in {#1}
{ifnumY=1
xdefbaryarg{X=1}
else
xdefbaryarg{baryarg,X=1}
fi}},
barycentric list/.style={barycentric setup={#1},insert path={%
(barycentric cs:baryarg)}}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
path[barycentric list={a,b,c,d}] node {center};
end{tikzpicture}
end{document}
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%2f480374%2fcreate-command-that-uses-a-foreach-to-be-used-in-a-barycentric-cs%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
Something like this?
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
},
barycentric setup/.code={foreach X [count=Y] in {#1}
{ifnumY=1
xdefbaryarg{X=1}
else
xdefbaryarg{baryarg,X=1}
fi}},
barycentric list/.style={barycentric setup={#1},insert path={%
(barycentric cs:baryarg)}}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
path[barycentric list={a,b,c,d}] node {center};
end{tikzpicture}
end{document}
add a comment |
Something like this?
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
},
barycentric setup/.code={foreach X [count=Y] in {#1}
{ifnumY=1
xdefbaryarg{X=1}
else
xdefbaryarg{baryarg,X=1}
fi}},
barycentric list/.style={barycentric setup={#1},insert path={%
(barycentric cs:baryarg)}}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
path[barycentric list={a,b,c,d}] node {center};
end{tikzpicture}
end{document}
add a comment |
Something like this?
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
},
barycentric setup/.code={foreach X [count=Y] in {#1}
{ifnumY=1
xdefbaryarg{X=1}
else
xdefbaryarg{baryarg,X=1}
fi}},
barycentric list/.style={barycentric setup={#1},insert path={%
(barycentric cs:baryarg)}}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
path[barycentric list={a,b,c,d}] node {center};
end{tikzpicture}
end{document}
Something like this?
documentclass[border=5mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix}
usetikzlibrary{positioning}
begin{document}
tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
},
barycentric setup/.code={foreach X [count=Y] in {#1}
{ifnumY=1
xdefbaryarg{X=1}
else
xdefbaryarg{baryarg,X=1}
fi}},
barycentric list/.style={barycentric setup={#1},insert path={%
(barycentric cs:baryarg)}}
}
begin{tikzpicture}
matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
node(a){text}; & node(c){text}; \
node(b){text}; & node(d){text}; \
% Loads of other nodes
};
path[barycentric list={a,b,c,d}] node {center};
end{tikzpicture}
end{document}
answered 2 hours ago
marmotmarmot
110k5136255
110k5136255
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%2f480374%2fcreate-command-that-uses-a-foreach-to-be-used-in-a-barycentric-cs%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
Your strategy works in principle if you do something like
newcommand{listforbarycentrics}[1]{foreach n [count=m] in {#1}{ ifnumm=1 xdefmybary{n=1} else xdefmybary{mybary,n=1} fi}} listforbarycentrics{a,b,c,d} node (x) at (barycentric cs:mybary) {text};
but I would use a style for that.– marmot
2 hours ago