Similar Triangles

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I am looking to improve my programming skills with this question. I believe I am making a mistake placing a tikzpicture within a tikzpicture? Any suggestions how to make this better and more flexible so one can vary the output according to ones needs? This is exactly what I want but I want to improve the programming.



documentclassarticle
usepackagetikz

begindocument
begincenter
begintikzpicture
node at (-3,0) begintikzpicture[scale=2]%,cap=round,>=latex]
coordinate [label=left:$B$] (B) at (0:0cm);
coordinate [label=above:$A$] (A) at (60:1.5cm);
coordinate [label=right:$C$] (C) at (20:1.8cm);
filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
node[above right] b (C) -- node[below] a (B);
endtikzpicture;
node at (3,0) begintikzpicture[scale=2]%,cap=round,>=latex]
coordinate [label=left:$Y$] (Y) at (0:0cm);
coordinate [label=above:$X$] (X) at (60:.5cm);
coordinate [label=right:$Z$] (Z) at (20:.6cm);
filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
node[above right] y (Z) -- node[below] x (Y);
endtikzpicture;
endtikzpicture
endcenter

enddocument


This outputs:



enter image description here










share|improve this question





















  • Yes, you should not nest tikzpictures, and all you need is to use pics.
    – marmot
    5 hours ago










  • I remember you saying this. How can I give them names? Should I use the def command ?
    – MathScholar
    5 hours ago










  • I appended two pics examples to my answer.
    – marmot
    4 hours ago














up vote
2
down vote

favorite












I am looking to improve my programming skills with this question. I believe I am making a mistake placing a tikzpicture within a tikzpicture? Any suggestions how to make this better and more flexible so one can vary the output according to ones needs? This is exactly what I want but I want to improve the programming.



documentclassarticle
usepackagetikz

begindocument
begincenter
begintikzpicture
node at (-3,0) begintikzpicture[scale=2]%,cap=round,>=latex]
coordinate [label=left:$B$] (B) at (0:0cm);
coordinate [label=above:$A$] (A) at (60:1.5cm);
coordinate [label=right:$C$] (C) at (20:1.8cm);
filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
node[above right] b (C) -- node[below] a (B);
endtikzpicture;
node at (3,0) begintikzpicture[scale=2]%,cap=round,>=latex]
coordinate [label=left:$Y$] (Y) at (0:0cm);
coordinate [label=above:$X$] (X) at (60:.5cm);
coordinate [label=right:$Z$] (Z) at (20:.6cm);
filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
node[above right] y (Z) -- node[below] x (Y);
endtikzpicture;
endtikzpicture
endcenter

enddocument


This outputs:



enter image description here










share|improve this question





















  • Yes, you should not nest tikzpictures, and all you need is to use pics.
    – marmot
    5 hours ago










  • I remember you saying this. How can I give them names? Should I use the def command ?
    – MathScholar
    5 hours ago










  • I appended two pics examples to my answer.
    – marmot
    4 hours ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am looking to improve my programming skills with this question. I believe I am making a mistake placing a tikzpicture within a tikzpicture? Any suggestions how to make this better and more flexible so one can vary the output according to ones needs? This is exactly what I want but I want to improve the programming.



documentclassarticle
usepackagetikz

begindocument
begincenter
begintikzpicture
node at (-3,0) begintikzpicture[scale=2]%,cap=round,>=latex]
coordinate [label=left:$B$] (B) at (0:0cm);
coordinate [label=above:$A$] (A) at (60:1.5cm);
coordinate [label=right:$C$] (C) at (20:1.8cm);
filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
node[above right] b (C) -- node[below] a (B);
endtikzpicture;
node at (3,0) begintikzpicture[scale=2]%,cap=round,>=latex]
coordinate [label=left:$Y$] (Y) at (0:0cm);
coordinate [label=above:$X$] (X) at (60:.5cm);
coordinate [label=right:$Z$] (Z) at (20:.6cm);
filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
node[above right] y (Z) -- node[below] x (Y);
endtikzpicture;
endtikzpicture
endcenter

enddocument


This outputs:



enter image description here










share|improve this question













I am looking to improve my programming skills with this question. I believe I am making a mistake placing a tikzpicture within a tikzpicture? Any suggestions how to make this better and more flexible so one can vary the output according to ones needs? This is exactly what I want but I want to improve the programming.



documentclassarticle
usepackagetikz

begindocument
begincenter
begintikzpicture
node at (-3,0) begintikzpicture[scale=2]%,cap=round,>=latex]
coordinate [label=left:$B$] (B) at (0:0cm);
coordinate [label=above:$A$] (A) at (60:1.5cm);
coordinate [label=right:$C$] (C) at (20:1.8cm);
filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
node[above right] b (C) -- node[below] a (B);
endtikzpicture;
node at (3,0) begintikzpicture[scale=2]%,cap=round,>=latex]
coordinate [label=left:$Y$] (Y) at (0:0cm);
coordinate [label=above:$X$] (X) at (60:.5cm);
coordinate [label=right:$Z$] (Z) at (20:.6cm);
filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
node[above right] y (Z) -- node[below] x (Y);
endtikzpicture;
endtikzpicture
endcenter

enddocument


This outputs:



enter image description here







tikz-pgf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 5 hours ago









MathScholar

2076




2076











  • Yes, you should not nest tikzpictures, and all you need is to use pics.
    – marmot
    5 hours ago










  • I remember you saying this. How can I give them names? Should I use the def command ?
    – MathScholar
    5 hours ago










  • I appended two pics examples to my answer.
    – marmot
    4 hours ago
















  • Yes, you should not nest tikzpictures, and all you need is to use pics.
    – marmot
    5 hours ago










  • I remember you saying this. How can I give them names? Should I use the def command ?
    – MathScholar
    5 hours ago










  • I appended two pics examples to my answer.
    – marmot
    4 hours ago















Yes, you should not nest tikzpictures, and all you need is to use pics.
– marmot
5 hours ago




Yes, you should not nest tikzpictures, and all you need is to use pics.
– marmot
5 hours ago












I remember you saying this. How can I give them names? Should I use the def command ?
– MathScholar
5 hours ago




I remember you saying this. How can I give them names? Should I use the def command ?
– MathScholar
5 hours ago












I appended two pics examples to my answer.
– marmot
4 hours ago




I appended two pics examples to my answer.
– marmot
4 hours ago










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










In this case, the simplest way is to replace the inner tikzpictures by scopes and implement the position by simple shifts.



documentclassarticle
usepackagetikz

begindocument
begincenter
begintikzpicture
beginscope[xshift=-3cm,scale=2]%,cap=round,>=latex]
coordinate [label=left:$B$] (B) at (0:0cm);
coordinate [label=above:$A$] (A) at (60:1.5cm);
coordinate [label=right:$C$] (C) at (20:1.8cm);
filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
node[above right] b (C) -- node[below] a (B);
endscope
beginscope[xshift=3cm,scale=2]%,cap=round,>=latex]
coordinate [label=left:$Y$] (Y) at (0:0cm);
coordinate [label=above:$X$] (X) at (60:.5cm);
coordinate [label=right:$Z$] (Z) at (20:.6cm);
filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
node[above right] y (Z) -- node[below] x (Y);
endscope
endtikzpicture
endcenter
enddocument


enter image description here



If you have the same thing and want to place it all over, use pics, but since these are only two triangles here with different labels, it is perhaps easier to use scopes. However, as you asked in the comments, here is the pics variant.



documentclassarticle
usepackagetikz
tikzsetpics/.cd,
3angle/.style n args=6code=coordinate [label=left:$#2$] (B) at (0:0cm);
coordinate [label=above:$#1$] (A) at (60:1.5cm);
coordinate [label=right:$#3$] (C) at (20:1.8cm);
filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #6 (A) --
node[midway,above right] #5 (C) -- node[midway,below] #4 (B);
begindocument
begincenter
begintikzpicture
pic[scale=2] at (-3,0) 3angle=ABCabc;
pic[scale=0.75] at (3,0) 3angle=XYZxyz;
endtikzpicture
endcenter
enddocument


enter image description here



Notice that one might be able to cook down the number of parameters to 3 if you always label the edge opposite a given corner by the lowercase letter.



documentclassarticle
usepackagetikz
tikzsetpics/.cd,
3angle/.style n args=3code=coordinate [label=left:$MakeUppercase#2$] (B) at (0:0cm);
coordinate [label=above:$MakeUppercase#1$] (A) at (60:1.5cm);
coordinate [label=right:$MakeUppercase#3$] (C) at (20:1.8cm);
filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #3 (A) --
node[midway,above right] #2 (C) -- node[midway,below] #1 (B);
begindocument
begincenter
begintikzpicture
pic[scale=2] at (-3,0) 3angle=abc;
pic[scale=0.75] at (3,0) 3angle=xyz;
endtikzpicture
endcenter
enddocument





share|improve this answer






















    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: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f455999%2fsimilar-triangles%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    In this case, the simplest way is to replace the inner tikzpictures by scopes and implement the position by simple shifts.



    documentclassarticle
    usepackagetikz

    begindocument
    begincenter
    begintikzpicture
    beginscope[xshift=-3cm,scale=2]%,cap=round,>=latex]
    coordinate [label=left:$B$] (B) at (0:0cm);
    coordinate [label=above:$A$] (A) at (60:1.5cm);
    coordinate [label=right:$C$] (C) at (20:1.8cm);
    filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
    node[above right] b (C) -- node[below] a (B);
    endscope
    beginscope[xshift=3cm,scale=2]%,cap=round,>=latex]
    coordinate [label=left:$Y$] (Y) at (0:0cm);
    coordinate [label=above:$X$] (X) at (60:.5cm);
    coordinate [label=right:$Z$] (Z) at (20:.6cm);
    filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
    node[above right] y (Z) -- node[below] x (Y);
    endscope
    endtikzpicture
    endcenter
    enddocument


    enter image description here



    If you have the same thing and want to place it all over, use pics, but since these are only two triangles here with different labels, it is perhaps easier to use scopes. However, as you asked in the comments, here is the pics variant.



    documentclassarticle
    usepackagetikz
    tikzsetpics/.cd,
    3angle/.style n args=6code=coordinate [label=left:$#2$] (B) at (0:0cm);
    coordinate [label=above:$#1$] (A) at (60:1.5cm);
    coordinate [label=right:$#3$] (C) at (20:1.8cm);
    filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #6 (A) --
    node[midway,above right] #5 (C) -- node[midway,below] #4 (B);
    begindocument
    begincenter
    begintikzpicture
    pic[scale=2] at (-3,0) 3angle=ABCabc;
    pic[scale=0.75] at (3,0) 3angle=XYZxyz;
    endtikzpicture
    endcenter
    enddocument


    enter image description here



    Notice that one might be able to cook down the number of parameters to 3 if you always label the edge opposite a given corner by the lowercase letter.



    documentclassarticle
    usepackagetikz
    tikzsetpics/.cd,
    3angle/.style n args=3code=coordinate [label=left:$MakeUppercase#2$] (B) at (0:0cm);
    coordinate [label=above:$MakeUppercase#1$] (A) at (60:1.5cm);
    coordinate [label=right:$MakeUppercase#3$] (C) at (20:1.8cm);
    filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #3 (A) --
    node[midway,above right] #2 (C) -- node[midway,below] #1 (B);
    begindocument
    begincenter
    begintikzpicture
    pic[scale=2] at (-3,0) 3angle=abc;
    pic[scale=0.75] at (3,0) 3angle=xyz;
    endtikzpicture
    endcenter
    enddocument





    share|improve this answer


























      up vote
      3
      down vote



      accepted










      In this case, the simplest way is to replace the inner tikzpictures by scopes and implement the position by simple shifts.



      documentclassarticle
      usepackagetikz

      begindocument
      begincenter
      begintikzpicture
      beginscope[xshift=-3cm,scale=2]%,cap=round,>=latex]
      coordinate [label=left:$B$] (B) at (0:0cm);
      coordinate [label=above:$A$] (A) at (60:1.5cm);
      coordinate [label=right:$C$] (C) at (20:1.8cm);
      filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
      node[above right] b (C) -- node[below] a (B);
      endscope
      beginscope[xshift=3cm,scale=2]%,cap=round,>=latex]
      coordinate [label=left:$Y$] (Y) at (0:0cm);
      coordinate [label=above:$X$] (X) at (60:.5cm);
      coordinate [label=right:$Z$] (Z) at (20:.6cm);
      filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
      node[above right] y (Z) -- node[below] x (Y);
      endscope
      endtikzpicture
      endcenter
      enddocument


      enter image description here



      If you have the same thing and want to place it all over, use pics, but since these are only two triangles here with different labels, it is perhaps easier to use scopes. However, as you asked in the comments, here is the pics variant.



      documentclassarticle
      usepackagetikz
      tikzsetpics/.cd,
      3angle/.style n args=6code=coordinate [label=left:$#2$] (B) at (0:0cm);
      coordinate [label=above:$#1$] (A) at (60:1.5cm);
      coordinate [label=right:$#3$] (C) at (20:1.8cm);
      filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #6 (A) --
      node[midway,above right] #5 (C) -- node[midway,below] #4 (B);
      begindocument
      begincenter
      begintikzpicture
      pic[scale=2] at (-3,0) 3angle=ABCabc;
      pic[scale=0.75] at (3,0) 3angle=XYZxyz;
      endtikzpicture
      endcenter
      enddocument


      enter image description here



      Notice that one might be able to cook down the number of parameters to 3 if you always label the edge opposite a given corner by the lowercase letter.



      documentclassarticle
      usepackagetikz
      tikzsetpics/.cd,
      3angle/.style n args=3code=coordinate [label=left:$MakeUppercase#2$] (B) at (0:0cm);
      coordinate [label=above:$MakeUppercase#1$] (A) at (60:1.5cm);
      coordinate [label=right:$MakeUppercase#3$] (C) at (20:1.8cm);
      filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #3 (A) --
      node[midway,above right] #2 (C) -- node[midway,below] #1 (B);
      begindocument
      begincenter
      begintikzpicture
      pic[scale=2] at (-3,0) 3angle=abc;
      pic[scale=0.75] at (3,0) 3angle=xyz;
      endtikzpicture
      endcenter
      enddocument





      share|improve this answer
























        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        In this case, the simplest way is to replace the inner tikzpictures by scopes and implement the position by simple shifts.



        documentclassarticle
        usepackagetikz

        begindocument
        begincenter
        begintikzpicture
        beginscope[xshift=-3cm,scale=2]%,cap=round,>=latex]
        coordinate [label=left:$B$] (B) at (0:0cm);
        coordinate [label=above:$A$] (A) at (60:1.5cm);
        coordinate [label=right:$C$] (C) at (20:1.8cm);
        filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
        node[above right] b (C) -- node[below] a (B);
        endscope
        beginscope[xshift=3cm,scale=2]%,cap=round,>=latex]
        coordinate [label=left:$Y$] (Y) at (0:0cm);
        coordinate [label=above:$X$] (X) at (60:.5cm);
        coordinate [label=right:$Z$] (Z) at (20:.6cm);
        filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
        node[above right] y (Z) -- node[below] x (Y);
        endscope
        endtikzpicture
        endcenter
        enddocument


        enter image description here



        If you have the same thing and want to place it all over, use pics, but since these are only two triangles here with different labels, it is perhaps easier to use scopes. However, as you asked in the comments, here is the pics variant.



        documentclassarticle
        usepackagetikz
        tikzsetpics/.cd,
        3angle/.style n args=6code=coordinate [label=left:$#2$] (B) at (0:0cm);
        coordinate [label=above:$#1$] (A) at (60:1.5cm);
        coordinate [label=right:$#3$] (C) at (20:1.8cm);
        filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #6 (A) --
        node[midway,above right] #5 (C) -- node[midway,below] #4 (B);
        begindocument
        begincenter
        begintikzpicture
        pic[scale=2] at (-3,0) 3angle=ABCabc;
        pic[scale=0.75] at (3,0) 3angle=XYZxyz;
        endtikzpicture
        endcenter
        enddocument


        enter image description here



        Notice that one might be able to cook down the number of parameters to 3 if you always label the edge opposite a given corner by the lowercase letter.



        documentclassarticle
        usepackagetikz
        tikzsetpics/.cd,
        3angle/.style n args=3code=coordinate [label=left:$MakeUppercase#2$] (B) at (0:0cm);
        coordinate [label=above:$MakeUppercase#1$] (A) at (60:1.5cm);
        coordinate [label=right:$MakeUppercase#3$] (C) at (20:1.8cm);
        filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #3 (A) --
        node[midway,above right] #2 (C) -- node[midway,below] #1 (B);
        begindocument
        begincenter
        begintikzpicture
        pic[scale=2] at (-3,0) 3angle=abc;
        pic[scale=0.75] at (3,0) 3angle=xyz;
        endtikzpicture
        endcenter
        enddocument





        share|improve this answer














        In this case, the simplest way is to replace the inner tikzpictures by scopes and implement the position by simple shifts.



        documentclassarticle
        usepackagetikz

        begindocument
        begincenter
        begintikzpicture
        beginscope[xshift=-3cm,scale=2]%,cap=round,>=latex]
        coordinate [label=left:$B$] (B) at (0:0cm);
        coordinate [label=above:$A$] (A) at (60:1.5cm);
        coordinate [label=right:$C$] (C) at (20:1.8cm);
        filldraw[fill=orange!50!white, draw=black] (B) -- node[above left] c (A) --
        node[above right] b (C) -- node[below] a (B);
        endscope
        beginscope[xshift=3cm,scale=2]%,cap=round,>=latex]
        coordinate [label=left:$Y$] (Y) at (0:0cm);
        coordinate [label=above:$X$] (X) at (60:.5cm);
        coordinate [label=right:$Z$] (Z) at (20:.6cm);
        filldraw[fill=orange!50!white, draw=black] (Y) -- node[above left] z (X) --
        node[above right] y (Z) -- node[below] x (Y);
        endscope
        endtikzpicture
        endcenter
        enddocument


        enter image description here



        If you have the same thing and want to place it all over, use pics, but since these are only two triangles here with different labels, it is perhaps easier to use scopes. However, as you asked in the comments, here is the pics variant.



        documentclassarticle
        usepackagetikz
        tikzsetpics/.cd,
        3angle/.style n args=6code=coordinate [label=left:$#2$] (B) at (0:0cm);
        coordinate [label=above:$#1$] (A) at (60:1.5cm);
        coordinate [label=right:$#3$] (C) at (20:1.8cm);
        filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #6 (A) --
        node[midway,above right] #5 (C) -- node[midway,below] #4 (B);
        begindocument
        begincenter
        begintikzpicture
        pic[scale=2] at (-3,0) 3angle=ABCabc;
        pic[scale=0.75] at (3,0) 3angle=XYZxyz;
        endtikzpicture
        endcenter
        enddocument


        enter image description here



        Notice that one might be able to cook down the number of parameters to 3 if you always label the edge opposite a given corner by the lowercase letter.



        documentclassarticle
        usepackagetikz
        tikzsetpics/.cd,
        3angle/.style n args=3code=coordinate [label=left:$MakeUppercase#2$] (B) at (0:0cm);
        coordinate [label=above:$MakeUppercase#1$] (A) at (60:1.5cm);
        coordinate [label=right:$MakeUppercase#3$] (C) at (20:1.8cm);
        filldraw[fill=orange!50!white, draw=black] (B) -- node[midway,above left] #3 (A) --
        node[midway,above right] #2 (C) -- node[midway,below] #1 (B);
        begindocument
        begincenter
        begintikzpicture
        pic[scale=2] at (-3,0) 3angle=abc;
        pic[scale=0.75] at (3,0) 3angle=xyz;
        endtikzpicture
        endcenter
        enddocument






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 4 hours ago

























        answered 4 hours ago









        marmot

        66.9k472143




        66.9k472143



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f455999%2fsimilar-triangles%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery