Omit the same coordinate parameters in drawing line in tikz The 2019 Stack Overflow Developer Survey Results Are InDifference between -| and |- in TikZTiKz dash dash plus plusCompute asin from y-value of a coordinate or: Angle between two lines in tikz3d-plane and rotating coordinate system in TiKZHow not to draw the first/last markerAnnotate grouped bar plotTikz and Beamer: How to fix coordinate system to be the same on each slide?Help understanding the coordinate system used in tikzDrawing an array of nodes using the foreach-constructPosition a tikz-draw that uses scope inside an axis environment using the coordinate system axis cstikz two magnets and magnetic fieldSpecifying line length in TikZ

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

Keeping a retro style to sci-fi spaceships?

Output the Arecibo Message

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

What is the meaning of Triage in Cybersec world?

If I can cast sorceries at instant speed, can I use sorcery-speed activated abilities at instant speed?

Cooking pasta in a water boiler

Can there be female White Walkers?

How come people say “Would of”?

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Dropping list elements from nested list after evaluation

What is the grammatical structure of "Il est de formation classique"?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Compute the product of 3 dictionaries and concatenate keys and values

Balance problems for leveling up mid-fight?

Why is ParallelDo slower than Do?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

How to type a long/em dash `—`

Can withdrawing asylum be illegal?

writing variables above the numbers in tikz picture

GUI Number Generator in QT C++

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Can we generate random numbers using irrational numbers like π and e?

Pokemon Turn Based battle (Python)



Omit the same coordinate parameters in drawing line in tikz



The 2019 Stack Overflow Developer Survey Results Are InDifference between -| and |- in TikZTiKz dash dash plus plusCompute asin from y-value of a coordinate or: Angle between two lines in tikz3d-plane and rotating coordinate system in TiKZHow not to draw the first/last markerAnnotate grouped bar plotTikz and Beamer: How to fix coordinate system to be the same on each slide?Help understanding the coordinate system used in tikzDrawing an array of nodes using the foreach-constructPosition a tikz-draw that uses scope inside an axis environment using the coordinate system axis cstikz two magnets and magnetic fieldSpecifying line length in TikZ










4















When I draw lines using TikZ, I always need to specify coordinates. For example



draw (1,0) -- (0,0) -- (0,1);


It is getting tedious when you have a lots of draws.



My question: "Is there a way to simplify the coordinate parameters?"



For example, if the coordinate parameter (on x or y axis) are the same, we can just omit it. More specifically,



draw (1,0) -- (0,0) -- (0,1);


can be written as



draw (1,0) -- (0,-) -- (-,1);


(I use - to show the parameter in this position is the same as the one before)










share|improve this question



















  • 2





    I would use -| and |- for that purpose, instead of --. For example, in this case, I would use draw (1,0) -| (0,1);.

    – JouleV
    11 hours ago












  • What about more than 3 coordinates

    – wayne
    11 hours ago






  • 1





    Give me an example, and I will do it for you. A combination of --, -|, and |- will solve it all.

    – JouleV
    11 hours ago











  • Yes, it is true you can use combinations of these to draw almost any line. In this case, my question seems trivial.

    – wayne
    10 hours ago















4















When I draw lines using TikZ, I always need to specify coordinates. For example



draw (1,0) -- (0,0) -- (0,1);


It is getting tedious when you have a lots of draws.



My question: "Is there a way to simplify the coordinate parameters?"



For example, if the coordinate parameter (on x or y axis) are the same, we can just omit it. More specifically,



draw (1,0) -- (0,0) -- (0,1);


can be written as



draw (1,0) -- (0,-) -- (-,1);


(I use - to show the parameter in this position is the same as the one before)










share|improve this question



















  • 2





    I would use -| and |- for that purpose, instead of --. For example, in this case, I would use draw (1,0) -| (0,1);.

    – JouleV
    11 hours ago












  • What about more than 3 coordinates

    – wayne
    11 hours ago






  • 1





    Give me an example, and I will do it for you. A combination of --, -|, and |- will solve it all.

    – JouleV
    11 hours ago











  • Yes, it is true you can use combinations of these to draw almost any line. In this case, my question seems trivial.

    – wayne
    10 hours ago













4












4








4








When I draw lines using TikZ, I always need to specify coordinates. For example



draw (1,0) -- (0,0) -- (0,1);


It is getting tedious when you have a lots of draws.



My question: "Is there a way to simplify the coordinate parameters?"



For example, if the coordinate parameter (on x or y axis) are the same, we can just omit it. More specifically,



draw (1,0) -- (0,0) -- (0,1);


can be written as



draw (1,0) -- (0,-) -- (-,1);


(I use - to show the parameter in this position is the same as the one before)










share|improve this question
















When I draw lines using TikZ, I always need to specify coordinates. For example



draw (1,0) -- (0,0) -- (0,1);


It is getting tedious when you have a lots of draws.



My question: "Is there a way to simplify the coordinate parameters?"



For example, if the coordinate parameter (on x or y axis) are the same, we can just omit it. More specifically,



draw (1,0) -- (0,0) -- (0,1);


can be written as



draw (1,0) -- (0,-) -- (-,1);


(I use - to show the parameter in this position is the same as the one before)







tikz-pgf draw






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 11 hours ago









JouleV

12.5k22663




12.5k22663










asked 11 hours ago









waynewayne

710922




710922







  • 2





    I would use -| and |- for that purpose, instead of --. For example, in this case, I would use draw (1,0) -| (0,1);.

    – JouleV
    11 hours ago












  • What about more than 3 coordinates

    – wayne
    11 hours ago






  • 1





    Give me an example, and I will do it for you. A combination of --, -|, and |- will solve it all.

    – JouleV
    11 hours ago











  • Yes, it is true you can use combinations of these to draw almost any line. In this case, my question seems trivial.

    – wayne
    10 hours ago












  • 2





    I would use -| and |- for that purpose, instead of --. For example, in this case, I would use draw (1,0) -| (0,1);.

    – JouleV
    11 hours ago












  • What about more than 3 coordinates

    – wayne
    11 hours ago






  • 1





    Give me an example, and I will do it for you. A combination of --, -|, and |- will solve it all.

    – JouleV
    11 hours ago











  • Yes, it is true you can use combinations of these to draw almost any line. In this case, my question seems trivial.

    – wayne
    10 hours ago







2




2





I would use -| and |- for that purpose, instead of --. For example, in this case, I would use draw (1,0) -| (0,1);.

– JouleV
11 hours ago






I would use -| and |- for that purpose, instead of --. For example, in this case, I would use draw (1,0) -| (0,1);.

– JouleV
11 hours ago














What about more than 3 coordinates

– wayne
11 hours ago





What about more than 3 coordinates

– wayne
11 hours ago




1




1





Give me an example, and I will do it for you. A combination of --, -|, and |- will solve it all.

– JouleV
11 hours ago





Give me an example, and I will do it for you. A combination of --, -|, and |- will solve it all.

– JouleV
11 hours ago













Yes, it is true you can use combinations of these to draw almost any line. In this case, my question seems trivial.

– wayne
10 hours ago





Yes, it is true you can use combinations of these to draw almost any line. In this case, my question seems trivial.

– wayne
10 hours ago










1 Answer
1






active

oldest

votes


















7














I agree with you that you should not have a command in which the x coordinate (or y coordinate) is useless in the relative positioning of the points.



However, it is not that easy to have such a command you requested. Nevertheless, TikZ already gives you a more brillant solution: -| and |-, which can handle named coordinates like (a), (b), etc. (and you will know that named coordinates are much prefered when drawing figures).



Some example:



draw (x1,y1) -- (x1,y2) -- (x2,y2);


can be changed to



draw (x1,y1) -| (x2,y2);


Or with five coordinates:



draw (x1,y1) -- (x1,y2) -- (x2,y2) -- (x2,y3) -- (x3,y3) -- (x3,y4);


can be changed to



draw (x1,y1) |- (x2,y2) -| (x3,y3) -- (x3,y4);


As I said, a combination of --, -| and |- can do anything related to this. At worst there can be a couple of replicated x (or y) coordinates, but that is not a great deal, especially when you mostly have to deal with named coordinates in the future.



Furthermore, you can specify relative coordinates by prepending + or ++ to the coordinates. Your example would be translated to



draw (x1,y1) -- ++(0, dy1) -- ++(dx1, 0);


A single + leaves the reference point in place, while a ++ moves the reference point to the current location. This makes it very easy to move parts of a sketch around. You only have to edit the first coordinate.






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',
    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f484260%2fomit-the-same-coordinate-parameters-in-drawing-line-in-tikz%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    I agree with you that you should not have a command in which the x coordinate (or y coordinate) is useless in the relative positioning of the points.



    However, it is not that easy to have such a command you requested. Nevertheless, TikZ already gives you a more brillant solution: -| and |-, which can handle named coordinates like (a), (b), etc. (and you will know that named coordinates are much prefered when drawing figures).



    Some example:



    draw (x1,y1) -- (x1,y2) -- (x2,y2);


    can be changed to



    draw (x1,y1) -| (x2,y2);


    Or with five coordinates:



    draw (x1,y1) -- (x1,y2) -- (x2,y2) -- (x2,y3) -- (x3,y3) -- (x3,y4);


    can be changed to



    draw (x1,y1) |- (x2,y2) -| (x3,y3) -- (x3,y4);


    As I said, a combination of --, -| and |- can do anything related to this. At worst there can be a couple of replicated x (or y) coordinates, but that is not a great deal, especially when you mostly have to deal with named coordinates in the future.



    Furthermore, you can specify relative coordinates by prepending + or ++ to the coordinates. Your example would be translated to



    draw (x1,y1) -- ++(0, dy1) -- ++(dx1, 0);


    A single + leaves the reference point in place, while a ++ moves the reference point to the current location. This makes it very easy to move parts of a sketch around. You only have to edit the first coordinate.






    share|improve this answer





























      7














      I agree with you that you should not have a command in which the x coordinate (or y coordinate) is useless in the relative positioning of the points.



      However, it is not that easy to have such a command you requested. Nevertheless, TikZ already gives you a more brillant solution: -| and |-, which can handle named coordinates like (a), (b), etc. (and you will know that named coordinates are much prefered when drawing figures).



      Some example:



      draw (x1,y1) -- (x1,y2) -- (x2,y2);


      can be changed to



      draw (x1,y1) -| (x2,y2);


      Or with five coordinates:



      draw (x1,y1) -- (x1,y2) -- (x2,y2) -- (x2,y3) -- (x3,y3) -- (x3,y4);


      can be changed to



      draw (x1,y1) |- (x2,y2) -| (x3,y3) -- (x3,y4);


      As I said, a combination of --, -| and |- can do anything related to this. At worst there can be a couple of replicated x (or y) coordinates, but that is not a great deal, especially when you mostly have to deal with named coordinates in the future.



      Furthermore, you can specify relative coordinates by prepending + or ++ to the coordinates. Your example would be translated to



      draw (x1,y1) -- ++(0, dy1) -- ++(dx1, 0);


      A single + leaves the reference point in place, while a ++ moves the reference point to the current location. This makes it very easy to move parts of a sketch around. You only have to edit the first coordinate.






      share|improve this answer



























        7












        7








        7







        I agree with you that you should not have a command in which the x coordinate (or y coordinate) is useless in the relative positioning of the points.



        However, it is not that easy to have such a command you requested. Nevertheless, TikZ already gives you a more brillant solution: -| and |-, which can handle named coordinates like (a), (b), etc. (and you will know that named coordinates are much prefered when drawing figures).



        Some example:



        draw (x1,y1) -- (x1,y2) -- (x2,y2);


        can be changed to



        draw (x1,y1) -| (x2,y2);


        Or with five coordinates:



        draw (x1,y1) -- (x1,y2) -- (x2,y2) -- (x2,y3) -- (x3,y3) -- (x3,y4);


        can be changed to



        draw (x1,y1) |- (x2,y2) -| (x3,y3) -- (x3,y4);


        As I said, a combination of --, -| and |- can do anything related to this. At worst there can be a couple of replicated x (or y) coordinates, but that is not a great deal, especially when you mostly have to deal with named coordinates in the future.



        Furthermore, you can specify relative coordinates by prepending + or ++ to the coordinates. Your example would be translated to



        draw (x1,y1) -- ++(0, dy1) -- ++(dx1, 0);


        A single + leaves the reference point in place, while a ++ moves the reference point to the current location. This makes it very easy to move parts of a sketch around. You only have to edit the first coordinate.






        share|improve this answer















        I agree with you that you should not have a command in which the x coordinate (or y coordinate) is useless in the relative positioning of the points.



        However, it is not that easy to have such a command you requested. Nevertheless, TikZ already gives you a more brillant solution: -| and |-, which can handle named coordinates like (a), (b), etc. (and you will know that named coordinates are much prefered when drawing figures).



        Some example:



        draw (x1,y1) -- (x1,y2) -- (x2,y2);


        can be changed to



        draw (x1,y1) -| (x2,y2);


        Or with five coordinates:



        draw (x1,y1) -- (x1,y2) -- (x2,y2) -- (x2,y3) -- (x3,y3) -- (x3,y4);


        can be changed to



        draw (x1,y1) |- (x2,y2) -| (x3,y3) -- (x3,y4);


        As I said, a combination of --, -| and |- can do anything related to this. At worst there can be a couple of replicated x (or y) coordinates, but that is not a great deal, especially when you mostly have to deal with named coordinates in the future.



        Furthermore, you can specify relative coordinates by prepending + or ++ to the coordinates. Your example would be translated to



        draw (x1,y1) -- ++(0, dy1) -- ++(dx1, 0);


        A single + leaves the reference point in place, while a ++ moves the reference point to the current location. This makes it very easy to move parts of a sketch around. You only have to edit the first coordinate.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 4 hours ago

























        answered 10 hours ago









        JouleVJouleV

        12.5k22663




        12.5k22663



























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f484260%2fomit-the-same-coordinate-parameters-in-drawing-line-in-tikz%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

            名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

            格濟夫卡 參考資料 导航菜单51°3′40″N 34°2′21″E / 51.06111°N 34.03917°E / 51.06111; 34.03917ГезівкаПогода в селі 编辑或修订

            聖斯德望教堂 (塞克什白堡) 參考資料 导航菜单