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:



enter image description here



Two issues:




  1. The line width not the same, the middle line looks like more wider.

  2. The rotation function doesn't work.










share|improve this question






















  • One good example to create custom shape latex4technics.com/?note=38jy
    – beetlej
    Nov 27 at 17:04















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:



enter image description here



Two issues:




  1. The line width not the same, the middle line looks like more wider.

  2. The rotation function doesn't work.










share|improve this question






















  • One good example to create custom shape latex4technics.com/?note=38jy
    – beetlej
    Nov 27 at 17:04













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:



enter image description here



Two issues:




  1. The line width not the same, the middle line looks like more wider.

  2. The rotation function doesn't work.










share|improve this question













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:



enter image description here



Two issues:




  1. The line width not the same, the middle line looks like more wider.

  2. The rotation function doesn't work.







tikz-pgf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 25 at 20:06









lucky1928

1,1191716




1,1191716












  • One good example to create custom shape latex4technics.com/?note=38jy
    – beetlej
    Nov 27 at 17:04


















  • One good example to create custom shape latex4technics.com/?note=38jy
    – beetlej
    Nov 27 at 17:04
















One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
Nov 27 at 17:04




One good example to create custom shape latex4technics.com/?note=38jy
– beetlej
Nov 27 at 17:04










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










Yes, path pictures are not without subtleties. For this purpose I would, rather than playing with pgftransformreset and the like, argue that pics may be more straightforward to deal with. Using local bounding boxes 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}


enter image description here






share|improve this answer




























    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}


    enter image description here






    share|improve this answer





















    • 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, indeed. you should stick with nice marmot answer.
      – Zarko
      Nov 25 at 21:00











    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
    });


    }
    });














    draft saved

    draft discarded


















    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








    up vote
    3
    down vote



    accepted










    Yes, path pictures are not without subtleties. For this purpose I would, rather than playing with pgftransformreset and the like, argue that pics may be more straightforward to deal with. Using local bounding boxes 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}


    enter image description here






    share|improve this answer

























      up vote
      3
      down vote



      accepted










      Yes, path pictures are not without subtleties. For this purpose I would, rather than playing with pgftransformreset and the like, argue that pics may be more straightforward to deal with. Using local bounding boxes 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}


      enter image description here






      share|improve this answer























        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        Yes, path pictures are not without subtleties. For this purpose I would, rather than playing with pgftransformreset and the like, argue that pics may be more straightforward to deal with. Using local bounding boxes 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}


        enter image description here






        share|improve this answer












        Yes, path pictures are not without subtleties. For this purpose I would, rather than playing with pgftransformreset and the like, argue that pics may be more straightforward to deal with. Using local bounding boxes 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}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 at 20:21









        marmot

        79.8k490169




        79.8k490169






















            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}


            enter image description here






            share|improve this answer





















            • 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, indeed. you should stick with nice marmot answer.
              – Zarko
              Nov 25 at 21:00















            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}


            enter image description here






            share|improve this answer





















            • 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, indeed. you should stick with nice marmot answer.
              – Zarko
              Nov 25 at 21:00













            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}


            enter image description here






            share|improve this answer












            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}


            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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 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


















            • 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, 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


















            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents