Rotate custom shape
up vote
3
down vote
favorite
Below code create a custom shape 'N'. It works fine with 0 rotation,but if rotate 90 degree, it doesn't work:
documentclass[margin=10pt]{standalone}
usepackage{tikz}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle,minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
path picture={
draw(path picture bounding box.south west) --
(path picture bounding box.north west)
(path picture bounding box.south east) --
(path picture bounding box.north east)
(path picture bounding box.north east) -- (path picture bounding box.south west);
}
},
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
In this example, C1 is good. C2 is the rotated version:
Two issues:
- The line width not the same, the middle line looks like more wider.
- The rotation function doesn't work.
tikz-pgf
add a comment |
up vote
3
down vote
favorite
Below code create a custom shape 'N'. It works fine with 0 rotation,but if rotate 90 degree, it doesn't work:
documentclass[margin=10pt]{standalone}
usepackage{tikz}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle,minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
path picture={
draw(path picture bounding box.south west) --
(path picture bounding box.north west)
(path picture bounding box.south east) --
(path picture bounding box.north east)
(path picture bounding box.north east) -- (path picture bounding box.south west);
}
},
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
In this example, C1 is good. C2 is the rotated version:
Two issues:
- The line width not the same, the middle line looks like more wider.
- The rotation function doesn't work.
tikz-pgf
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
2 days ago
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Below code create a custom shape 'N'. It works fine with 0 rotation,but if rotate 90 degree, it doesn't work:
documentclass[margin=10pt]{standalone}
usepackage{tikz}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle,minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
path picture={
draw(path picture bounding box.south west) --
(path picture bounding box.north west)
(path picture bounding box.south east) --
(path picture bounding box.north east)
(path picture bounding box.north east) -- (path picture bounding box.south west);
}
},
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
In this example, C1 is good. C2 is the rotated version:
Two issues:
- The line width not the same, the middle line looks like more wider.
- The rotation function doesn't work.
tikz-pgf
Below code create a custom shape 'N'. It works fine with 0 rotation,but if rotate 90 degree, it doesn't work:
documentclass[margin=10pt]{standalone}
usepackage{tikz}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle,minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
path picture={
draw(path picture bounding box.south west) --
(path picture bounding box.north west)
(path picture bounding box.south east) --
(path picture bounding box.north east)
(path picture bounding box.north east) -- (path picture bounding box.south west);
}
},
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
In this example, C1 is good. C2 is the rotated version:
Two issues:
- The line width not the same, the middle line looks like more wider.
- The rotation function doesn't work.
tikz-pgf
tikz-pgf
asked Nov 25 at 20:06
lucky1928
1,1091716
1,1091716
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
2 days ago
add a comment |
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
2 days ago
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
2 days ago
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
Yes, path picture
s are not without subtleties. For this purpose I would, rather than playing with pgftransformreset
and the like, argue that pic
s may be more straightforward to deal with. Using local bounding box
es one can make them almost behave like nodes.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{positioning}
tikzset{
pics/.cd,
N/.style={code={draw[very thick] (-0.1,0.2) -- (-0.1,-0.2)
-- (0.1,0.2) -- (0.1,-0.2);
}}
}
begin{document}
begin{tikzpicture}
pic[local bounding box=C1] {N};
pic[local bounding box=C2,rotate=45,below=0.4 of C1] {N};
end{tikzpicture}
end{document}
add a comment |
up vote
3
down vote
your expectation how path picture bounding box
is wrong. in your case instead it you can use append after command
and add your drawings as follows:
documentclass[tikz, margin=10pt]{standalone}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle, minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
append after command={
pgfextra{letLNtikzlastnode
draw (LN.south west) -- (LN.north west) --
(LN.south east) -- (LN.north east);
}
},
}% end of cap style
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
Great, thanks, but sounds like the rotate is not around center. if rotate C2 with 90 degree, you will find it's not center aligned with C1.
– lucky1928
Nov 25 at 20:32
@lucky1928 The pgfmanual says on p. 162 : "Note that this operation should only be used by real experts and should only be used deep inside clever macros, not on normal paths." I have made too many experiences that suggest that this is to be taken seriously. (You can usepgfextra
fortypeouts
and the like without problems, though, according to what I find, but if you use it for paths the outcome is sometimes unpredictable, meaning it can depend on what you've done earlier.)
– marmot
Nov 25 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 at 21:00
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Yes, path picture
s are not without subtleties. For this purpose I would, rather than playing with pgftransformreset
and the like, argue that pic
s may be more straightforward to deal with. Using local bounding box
es one can make them almost behave like nodes.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{positioning}
tikzset{
pics/.cd,
N/.style={code={draw[very thick] (-0.1,0.2) -- (-0.1,-0.2)
-- (0.1,0.2) -- (0.1,-0.2);
}}
}
begin{document}
begin{tikzpicture}
pic[local bounding box=C1] {N};
pic[local bounding box=C2,rotate=45,below=0.4 of C1] {N};
end{tikzpicture}
end{document}
add a comment |
up vote
3
down vote
accepted
Yes, path picture
s are not without subtleties. For this purpose I would, rather than playing with pgftransformreset
and the like, argue that pic
s may be more straightforward to deal with. Using local bounding box
es one can make them almost behave like nodes.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{positioning}
tikzset{
pics/.cd,
N/.style={code={draw[very thick] (-0.1,0.2) -- (-0.1,-0.2)
-- (0.1,0.2) -- (0.1,-0.2);
}}
}
begin{document}
begin{tikzpicture}
pic[local bounding box=C1] {N};
pic[local bounding box=C2,rotate=45,below=0.4 of C1] {N};
end{tikzpicture}
end{document}
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Yes, path picture
s are not without subtleties. For this purpose I would, rather than playing with pgftransformreset
and the like, argue that pic
s may be more straightforward to deal with. Using local bounding box
es one can make them almost behave like nodes.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{positioning}
tikzset{
pics/.cd,
N/.style={code={draw[very thick] (-0.1,0.2) -- (-0.1,-0.2)
-- (0.1,0.2) -- (0.1,-0.2);
}}
}
begin{document}
begin{tikzpicture}
pic[local bounding box=C1] {N};
pic[local bounding box=C2,rotate=45,below=0.4 of C1] {N};
end{tikzpicture}
end{document}
Yes, path picture
s are not without subtleties. For this purpose I would, rather than playing with pgftransformreset
and the like, argue that pic
s may be more straightforward to deal with. Using local bounding box
es one can make them almost behave like nodes.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{positioning}
tikzset{
pics/.cd,
N/.style={code={draw[very thick] (-0.1,0.2) -- (-0.1,-0.2)
-- (0.1,0.2) -- (0.1,-0.2);
}}
}
begin{document}
begin{tikzpicture}
pic[local bounding box=C1] {N};
pic[local bounding box=C2,rotate=45,below=0.4 of C1] {N};
end{tikzpicture}
end{document}
answered Nov 25 at 20:21
marmot
79.4k488166
79.4k488166
add a comment |
add a comment |
up vote
3
down vote
your expectation how path picture bounding box
is wrong. in your case instead it you can use append after command
and add your drawings as follows:
documentclass[tikz, margin=10pt]{standalone}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle, minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
append after command={
pgfextra{letLNtikzlastnode
draw (LN.south west) -- (LN.north west) --
(LN.south east) -- (LN.north east);
}
},
}% end of cap style
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
Great, thanks, but sounds like the rotate is not around center. if rotate C2 with 90 degree, you will find it's not center aligned with C1.
– lucky1928
Nov 25 at 20:32
@lucky1928 The pgfmanual says on p. 162 : "Note that this operation should only be used by real experts and should only be used deep inside clever macros, not on normal paths." I have made too many experiences that suggest that this is to be taken seriously. (You can usepgfextra
fortypeouts
and the like without problems, though, according to what I find, but if you use it for paths the outcome is sometimes unpredictable, meaning it can depend on what you've done earlier.)
– marmot
Nov 25 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 at 21:00
add a comment |
up vote
3
down vote
your expectation how path picture bounding box
is wrong. in your case instead it you can use append after command
and add your drawings as follows:
documentclass[tikz, margin=10pt]{standalone}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle, minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
append after command={
pgfextra{letLNtikzlastnode
draw (LN.south west) -- (LN.north west) --
(LN.south east) -- (LN.north east);
}
},
}% end of cap style
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
Great, thanks, but sounds like the rotate is not around center. if rotate C2 with 90 degree, you will find it's not center aligned with C1.
– lucky1928
Nov 25 at 20:32
@lucky1928 The pgfmanual says on p. 162 : "Note that this operation should only be used by real experts and should only be used deep inside clever macros, not on normal paths." I have made too many experiences that suggest that this is to be taken seriously. (You can usepgfextra
fortypeouts
and the like without problems, though, according to what I find, but if you use it for paths the outcome is sometimes unpredictable, meaning it can depend on what you've done earlier.)
– marmot
Nov 25 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 at 21:00
add a comment |
up vote
3
down vote
up vote
3
down vote
your expectation how path picture bounding box
is wrong. in your case instead it you can use append after command
and add your drawings as follows:
documentclass[tikz, margin=10pt]{standalone}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle, minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
append after command={
pgfextra{letLNtikzlastnode
draw (LN.south west) -- (LN.north west) --
(LN.south east) -- (LN.north east);
}
},
}% end of cap style
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
your expectation how path picture bounding box
is wrong. in your case instead it you can use append after command
and add your drawings as follows:
documentclass[tikz, margin=10pt]{standalone}
usetikzlibrary{positioning}
tikzset{
cap/.style={
rotate=#1,very thick,rectangle, minimum width=2mm,minimum height=4mm,
inner sep=0,outer sep=0,
append after command={
pgfextra{letLNtikzlastnode
draw (LN.south west) -- (LN.north west) --
(LN.south east) -- (LN.north east);
}
},
}% end of cap style
}
begin{document}
begin{tikzpicture}
node[cap=0] (C1) {};
node[cap=45,below=0.2 of C1] (C2) {};
end{tikzpicture}
end{document}
answered Nov 25 at 20:27
Zarko
117k865155
117k865155
Great, thanks, but sounds like the rotate is not around center. if rotate C2 with 90 degree, you will find it's not center aligned with C1.
– lucky1928
Nov 25 at 20:32
@lucky1928 The pgfmanual says on p. 162 : "Note that this operation should only be used by real experts and should only be used deep inside clever macros, not on normal paths." I have made too many experiences that suggest that this is to be taken seriously. (You can usepgfextra
fortypeouts
and the like without problems, though, according to what I find, but if you use it for paths the outcome is sometimes unpredictable, meaning it can depend on what you've done earlier.)
– marmot
Nov 25 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 at 21:00
add a comment |
Great, thanks, but sounds like the rotate is not around center. if rotate C2 with 90 degree, you will find it's not center aligned with C1.
– lucky1928
Nov 25 at 20:32
@lucky1928 The pgfmanual says on p. 162 : "Note that this operation should only be used by real experts and should only be used deep inside clever macros, not on normal paths." I have made too many experiences that suggest that this is to be taken seriously. (You can usepgfextra
fortypeouts
and the like without problems, though, according to what I find, but if you use it for paths the outcome is sometimes unpredictable, meaning it can depend on what you've done earlier.)
– marmot
Nov 25 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 at 21:00
Great, thanks, but sounds like the rotate is not around center. if rotate C2 with 90 degree, you will find it's not center aligned with C1.
– lucky1928
Nov 25 at 20:32
Great, thanks, but sounds like the rotate is not around center. if rotate C2 with 90 degree, you will find it's not center aligned with C1.
– lucky1928
Nov 25 at 20:32
@lucky1928 The pgfmanual says on p. 162 : "Note that this operation should only be used by real experts and should only be used deep inside clever macros, not on normal paths." I have made too many experiences that suggest that this is to be taken seriously. (You can use
pgfextra
for typeouts
and the like without problems, though, according to what I find, but if you use it for paths the outcome is sometimes unpredictable, meaning it can depend on what you've done earlier.)– marmot
Nov 25 at 20:37
@lucky1928 The pgfmanual says on p. 162 : "Note that this operation should only be used by real experts and should only be used deep inside clever macros, not on normal paths." I have made too many experiences that suggest that this is to be taken seriously. (You can use
pgfextra
for typeouts
and the like without problems, though, according to what I find, but if you use it for paths the outcome is sometimes unpredictable, meaning it can depend on what you've done earlier.)– marmot
Nov 25 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 at 21:00
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 at 21:00
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%2f461729%2frotate-custom-shape%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
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
2 days ago