Arguments and functions in latex
up vote
2
down vote
favorite
I would like to use argurments of a first tizkset to give them to a second tikset.This is my code
documentclass{article}
usepackage{tikz}
tikzset{pics/message/.style={code={
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
pic at (1,3) {message={1,2,3,4}};
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
end{tikzpicture}
end{document}
To draw me this:
I would like to call rectangle like that:
pic at (0,0) {broadcast={1,2,3,4}};
While changing this line in the broadcast method:
pic at (1,3) {message={1,2,3,4}}; %actually
pic at (1,3) {message={%every param of broadcast%}}; % What I want
How can I do this?
tikz-pgf
add a comment |
up vote
2
down vote
favorite
I would like to use argurments of a first tizkset to give them to a second tikset.This is my code
documentclass{article}
usepackage{tikz}
tikzset{pics/message/.style={code={
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
pic at (1,3) {message={1,2,3,4}};
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
end{tikzpicture}
end{document}
To draw me this:
I would like to call rectangle like that:
pic at (0,0) {broadcast={1,2,3,4}};
While changing this line in the broadcast method:
pic at (1,3) {message={1,2,3,4}}; %actually
pic at (1,3) {message={%every param of broadcast%}}; % What I want
How can I do this?
tikz-pgf
For me it is not very clear what you want : inside yourbroadcast
pic you have a nestedmessage
pic, do you want to be able to passe the parameters ofbroadcast
to the nestedmessage
? If this is the case you can simply remove yourscope
(with the unusedlocal bounding box=#1
) and replacepic at (1,3) {message={1,2,3,4}};
withpic at (1,3) {message={#1}};
.
– Kpym
Oct 7 at 13:15
@Kpym Did you try what you are suggesting?
– marmot
Oct 7 at 15:19
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I would like to use argurments of a first tizkset to give them to a second tikset.This is my code
documentclass{article}
usepackage{tikz}
tikzset{pics/message/.style={code={
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
pic at (1,3) {message={1,2,3,4}};
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
end{tikzpicture}
end{document}
To draw me this:
I would like to call rectangle like that:
pic at (0,0) {broadcast={1,2,3,4}};
While changing this line in the broadcast method:
pic at (1,3) {message={1,2,3,4}}; %actually
pic at (1,3) {message={%every param of broadcast%}}; % What I want
How can I do this?
tikz-pgf
I would like to use argurments of a first tizkset to give them to a second tikset.This is my code
documentclass{article}
usepackage{tikz}
tikzset{pics/message/.style={code={
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
pic at (1,3) {message={1,2,3,4}};
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
end{tikzpicture}
end{document}
To draw me this:
I would like to call rectangle like that:
pic at (0,0) {broadcast={1,2,3,4}};
While changing this line in the broadcast method:
pic at (1,3) {message={1,2,3,4}}; %actually
pic at (1,3) {message={%every param of broadcast%}}; % What I want
How can I do this?
tikz-pgf
tikz-pgf
edited Oct 7 at 9:44
CarLaTeX
28.6k446122
28.6k446122
asked Oct 7 at 9:37
Kokodelo
296
296
For me it is not very clear what you want : inside yourbroadcast
pic you have a nestedmessage
pic, do you want to be able to passe the parameters ofbroadcast
to the nestedmessage
? If this is the case you can simply remove yourscope
(with the unusedlocal bounding box=#1
) and replacepic at (1,3) {message={1,2,3,4}};
withpic at (1,3) {message={#1}};
.
– Kpym
Oct 7 at 13:15
@Kpym Did you try what you are suggesting?
– marmot
Oct 7 at 15:19
add a comment |
For me it is not very clear what you want : inside yourbroadcast
pic you have a nestedmessage
pic, do you want to be able to passe the parameters ofbroadcast
to the nestedmessage
? If this is the case you can simply remove yourscope
(with the unusedlocal bounding box=#1
) and replacepic at (1,3) {message={1,2,3,4}};
withpic at (1,3) {message={#1}};
.
– Kpym
Oct 7 at 13:15
@Kpym Did you try what you are suggesting?
– marmot
Oct 7 at 15:19
For me it is not very clear what you want : inside your
broadcast
pic you have a nested message
pic, do you want to be able to passe the parameters of broadcast
to the nested message
? If this is the case you can simply remove your scope
(with the unused local bounding box=#1
) and replace pic at (1,3) {message={1,2,3,4}};
with pic at (1,3) {message={#1}};
.– Kpym
Oct 7 at 13:15
For me it is not very clear what you want : inside your
broadcast
pic you have a nested message
pic, do you want to be able to passe the parameters of broadcast
to the nested message
? If this is the case you can simply remove your scope
(with the unused local bounding box=#1
) and replace pic at (1,3) {message={1,2,3,4}};
with pic at (1,3) {message={#1}};
.– Kpym
Oct 7 at 13:15
@Kpym Did you try what you are suggesting?
– marmot
Oct 7 at 15:19
@Kpym Did you try what you are suggesting?
– marmot
Oct 7 at 15:19
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Here is a proposal. It is not absolutely fool proof. In its present form, if you call a message pic and a broadcast pic afterwards, the message gets broadcasted. To intercept broadcasting, use broadcastfalse
after the message pic.
documentclass{article}
usepackage{tikz}
newififbroadcast
broadcastfalse
tikzset{pics/message/.style={code={xdefLastMessage{#1}
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
ifbroadcast
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in #1 %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
else
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
fi
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
ifxLastMessageempty
pic at (1,3) {message};
else
broadcasttrue
pic at (1,3) {message=LastMessage};
fi
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
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',
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%2f454210%2farguments-and-functions-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
up vote
0
down vote
Here is a proposal. It is not absolutely fool proof. In its present form, if you call a message pic and a broadcast pic afterwards, the message gets broadcasted. To intercept broadcasting, use broadcastfalse
after the message pic.
documentclass{article}
usepackage{tikz}
newififbroadcast
broadcastfalse
tikzset{pics/message/.style={code={xdefLastMessage{#1}
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
ifbroadcast
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in #1 %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
else
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
fi
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
ifxLastMessageempty
pic at (1,3) {message};
else
broadcasttrue
pic at (1,3) {message=LastMessage};
fi
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
end{tikzpicture}
end{document}
add a comment |
up vote
0
down vote
Here is a proposal. It is not absolutely fool proof. In its present form, if you call a message pic and a broadcast pic afterwards, the message gets broadcasted. To intercept broadcasting, use broadcastfalse
after the message pic.
documentclass{article}
usepackage{tikz}
newififbroadcast
broadcastfalse
tikzset{pics/message/.style={code={xdefLastMessage{#1}
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
ifbroadcast
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in #1 %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
else
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
fi
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
ifxLastMessageempty
pic at (1,3) {message};
else
broadcasttrue
pic at (1,3) {message=LastMessage};
fi
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
end{tikzpicture}
end{document}
add a comment |
up vote
0
down vote
up vote
0
down vote
Here is a proposal. It is not absolutely fool proof. In its present form, if you call a message pic and a broadcast pic afterwards, the message gets broadcasted. To intercept broadcasting, use broadcastfalse
after the message pic.
documentclass{article}
usepackage{tikz}
newififbroadcast
broadcastfalse
tikzset{pics/message/.style={code={xdefLastMessage{#1}
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
ifbroadcast
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in #1 %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
else
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
fi
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
ifxLastMessageempty
pic at (1,3) {message};
else
broadcasttrue
pic at (1,3) {message=LastMessage};
fi
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
end{tikzpicture}
end{document}
Here is a proposal. It is not absolutely fool proof. In its present form, if you call a message pic and a broadcast pic afterwards, the message gets broadcasted. To intercept broadcasting, use broadcastfalse
after the message pic.
documentclass{article}
usepackage{tikz}
newififbroadcast
broadcastfalse
tikzset{pics/message/.style={code={xdefLastMessage{#1}
draw (0,0) rectangle (4,1);
draw foreach X in {1,2,3} {(X,0) -- (X,1)};
%someone gave me two lines and i can't figure out how they work
ifbroadcast
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in #1 %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
else
foreach X [count=Y,evaluate=Y as Z using {Y-0.5}] in {#1} %1
{node at (Z,0.5) {X}; %2
ifnumY=4
breakforeach
fi}
fi
}}}
tikzset{pics/broadcast/.style={code={begin{scope}[local bounding box=#1]
draw (0,0) rectangle (6,5);
ifxLastMessageempty
pic at (1,3) {message};
else
broadcasttrue
pic at (1,3) {message=LastMessage};
fi
end{scope}
}}}
begin{document}
begin{tikzpicture}
pic at (0,0) {message={1,2,3,4}}; %instead it should be the params of broadcast
pic at (0,3) {broadcast};
end{tikzpicture}
end{document}
answered Oct 7 at 15:19
marmot
82.9k493177
82.9k493177
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.
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%2f454210%2farguments-and-functions-in-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
For me it is not very clear what you want : inside your
broadcast
pic you have a nestedmessage
pic, do you want to be able to passe the parameters ofbroadcast
to the nestedmessage
? If this is the case you can simply remove yourscope
(with the unusedlocal bounding box=#1
) and replacepic at (1,3) {message={1,2,3,4}};
withpic at (1,3) {message={#1}};
.– Kpym
Oct 7 at 13:15
@Kpym Did you try what you are suggesting?
– marmot
Oct 7 at 15:19