newcommand inside a tikz node
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
In this example
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
newcommandelement[1][draw, rectangle] #1
usepackagetikz
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west](c) at ($(a.east) + (0.3, 0)$)
elementc;
endtikzpicture
enddocument
at node c
I try to use newcommand
element
that should construct node c
in the same way as nodes a
and b
are constructed.
Is such an approach possible? Assume I need to construct multiple nodes in a repetitive and nontrivial way.
tikz-pgf macros nodes
add a comment |Â
up vote
1
down vote
favorite
In this example
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
newcommandelement[1][draw, rectangle] #1
usepackagetikz
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west](c) at ($(a.east) + (0.3, 0)$)
elementc;
endtikzpicture
enddocument
at node c
I try to use newcommand
element
that should construct node c
in the same way as nodes a
and b
are constructed.
Is such an approach possible? Assume I need to construct multiple nodes in a repetitive and nontrivial way.
tikz-pgf macros nodes
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In this example
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
newcommandelement[1][draw, rectangle] #1
usepackagetikz
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west](c) at ($(a.east) + (0.3, 0)$)
elementc;
endtikzpicture
enddocument
at node c
I try to use newcommand
element
that should construct node c
in the same way as nodes a
and b
are constructed.
Is such an approach possible? Assume I need to construct multiple nodes in a repetitive and nontrivial way.
tikz-pgf macros nodes
In this example
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
newcommandelement[1][draw, rectangle] #1
usepackagetikz
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west](c) at ($(a.east) + (0.3, 0)$)
elementc;
endtikzpicture
enddocument
at node c
I try to use newcommand
element
that should construct node c
in the same way as nodes a
and b
are constructed.
Is such an approach possible? Assume I need to construct multiple nodes in a repetitive and nontrivial way.
tikz-pgf macros nodes
tikz-pgf macros nodes
asked 3 hours ago
Viesturs
1,2452921
1,2452921
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
Perhaps you should define a tikz style for nodes:
for one argument
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style=draw,rectangle,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
for 3 arguments
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style n args=3draw=#2,shape=#3,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
How to changeelement=c
if I have more than 1 argument to element?
– Viesturs
2 hours ago
I will reedit my answer considering your new requirement soon
– Hafid Boukhoulda
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
Perhaps you should define a tikz style for nodes:
for one argument
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style=draw,rectangle,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
for 3 arguments
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style n args=3draw=#2,shape=#3,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
How to changeelement=c
if I have more than 1 argument to element?
– Viesturs
2 hours ago
I will reedit my answer considering your new requirement soon
– Hafid Boukhoulda
1 hour ago
add a comment |Â
up vote
4
down vote
Perhaps you should define a tikz style for nodes:
for one argument
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style=draw,rectangle,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
for 3 arguments
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style n args=3draw=#2,shape=#3,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
How to changeelement=c
if I have more than 1 argument to element?
– Viesturs
2 hours ago
I will reedit my answer considering your new requirement soon
– Hafid Boukhoulda
1 hour ago
add a comment |Â
up vote
4
down vote
up vote
4
down vote
Perhaps you should define a tikz style for nodes:
for one argument
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style=draw,rectangle,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
for 3 arguments
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style n args=3draw=#2,shape=#3,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
Perhaps you should define a tikz style for nodes:
for one argument
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style=draw,rectangle,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
for 3 arguments
documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
usepackagetikz
tikzset
element/.style n args=3draw=#2,shape=#3,node contents=#1
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;
endtikzpicture
enddocument
edited 1 hour ago
answered 2 hours ago
Hafid Boukhoulda
714313
714313
How to changeelement=c
if I have more than 1 argument to element?
– Viesturs
2 hours ago
I will reedit my answer considering your new requirement soon
– Hafid Boukhoulda
1 hour ago
add a comment |Â
How to changeelement=c
if I have more than 1 argument to element?
– Viesturs
2 hours ago
I will reedit my answer considering your new requirement soon
– Hafid Boukhoulda
1 hour ago
How to change
element=c
if I have more than 1 argument to element?– Viesturs
2 hours ago
How to change
element=c
if I have more than 1 argument to element?– Viesturs
2 hours ago
I will reedit my answer considering your new requirement soon
– Hafid Boukhoulda
1 hour ago
I will reedit my answer considering your new requirement soon
– Hafid Boukhoulda
1 hour ago
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f453575%2fnewcommand-inside-a-tikz-node%23new-answer', 'question_page');
);
Post as a guest
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
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
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