Rotate custom shape
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 |
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
Nov 27 '18 at 17:04
add a comment |
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 '18 at 20:06
lucky1928lucky1928
1,2411816
1,2411816
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
Nov 27 '18 at 17:04
add a comment |
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
Nov 27 '18 at 17:04
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
Nov 27 '18 at 17:04
One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
Nov 27 '18 at 17:04
add a comment |
2 Answers
2
active
oldest
votes
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 |
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 '18 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 '18 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 '18 at 21:00
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%2f461729%2frotate-custom-shape%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
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 |
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 |
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 '18 at 20:21
marmotmarmot
106k4127242
106k4127242
add a comment |
add a comment |
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 '18 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 '18 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 '18 at 21:00
add a comment |
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 '18 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 '18 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 '18 at 21:00
add a comment |
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 '18 at 20:27
ZarkoZarko
126k868165
126k868165
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 '18 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 '18 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 '18 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 '18 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 '18 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 '18 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 '18 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 '18 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 '18 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 '18 at 20:37
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 '18 at 21:00
@lucky1928, indeed. you should stick with nice marmot answer.
– Zarko
Nov 25 '18 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.
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
Nov 27 '18 at 17:04