How to make labels automatically scale in size to fit between 2 coordinates in tikz?How to make (1,1) mean (1cm,1cm) in TikZ? (Setting the units of coordinates)How do I achieve consistent font sizing in a tikz circuit?how to set the canvas and font size in TikZ?Scaling TikZ figures for posterScale TikZ nodes and shapes for a given canvas sizePreserve node and font size when scalingTikZ scaling graphic and adjust node position and keep font sizeTikZ “scale” key not behaving at all in the expected way when scaling tikzpictureLine up nested tikz enviroments or how to get rid of themHow do I change the size of a state in a FSA in tikz?

Why could the Lunar Ascent Engine be used only once?

Does the Aboleth have expertise in history and perception?

Why does the U.S military use mercenaries?

What were the "pills" that were added to solid waste in Apollo 7?

Better than Rembrandt

Are there any crystals that are theoretically possible, but haven't yet been made?

Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?

Bash Array of Word-Splitting Headaches

How to safely discharge oneself

Richard's Favourite TV Programme

Reference for electronegativities of different metal oxidation states

Very serious stuff - Salesforce bug enabled "Modify All"

Why favour the standard WP loop over iterating over (new WP_Query())->get_posts()?

Does science define life as "beginning at conception"?

On a piano, are the effects of holding notes and the sustain pedal the same for a single chord?

Is it possible to view all the attribute data in QGIS

How can I prevent Bash expansion from passing files starting with "-" as argument?

Was Tyrion always a poor strategist?

In How Many Ways Can We Partition a Set Into Smaller Subsets So The Sum of the Numbers In Each Subset Is Equal?

Why are Marine Le Pen's possible connections with Steve Bannon something worth investigating?

Why does snapping your fingers activate the Infinity Gauntlet?

Should I twist DC power and ground wires from a power supply?

Working hours and productivity expectations for game artists and programmers

Can I have a delimited macro with a literal # in the parameter text?



How to make labels automatically scale in size to fit between 2 coordinates in tikz?


How to make (1,1) mean (1cm,1cm) in TikZ? (Setting the units of coordinates)How do I achieve consistent font sizing in a tikz circuit?how to set the canvas and font size in TikZ?Scaling TikZ figures for posterScale TikZ nodes and shapes for a given canvas sizePreserve node and font size when scalingTikZ scaling graphic and adjust node position and keep font sizeTikZ “scale” key not behaving at all in the expected way when scaling tikzpictureLine up nested tikz enviroments or how to get rid of themHow do I change the size of a state in a FSA in tikz?













3















tikz newbie here.



I want to make "template" drawing, which has part of it a line and then put different size labels on top of the line.



The label is some latex code (equation).



One of the problems is that, since I am using fixed coordinates each time, but the equation itself can be long or short, I need a way to make the latex font size automatically scale to fit the space.



Otherwise, each time I make new drawing, I have to do trial and error to change either the coordinates or manually change the font size. Here is MWE to better explain what I mean



documentclass[11pt]standalone
usepackagetikz

begindocument
begintikzpicture


coordinate[label=left:A] (A) at (0,0);
coordinate[label=right:B] (B) at (3,0);

newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$

draw (A) -- node[above] myLabel ++(B);

endtikzpicture
enddocument


Mathematica graphics



Now, I can either try again with smaller font or change the coordinates to make the space larger so the new label fit.



I do not want to change the coordinates, since if these are part of larger diagram, it means I have to also change other coordinates as well and things will start to fall apart, because once I change one coordinate, I have to go update all the other coordinates to keep the shape the same.



So I try again with smaller font, like this



newcommandmyLabelfootnotesize$sin(x)+cos(y)=int_0^infty e^x y, dx$;


Ok, a little better



Mathematica graphics



but still does not fit right. So I try now with



 newcommandmyLabeltiny$sin(x)+cos(y)=int_0^infty e^x y, dx$;


Mathematica graphics



Ok a little better.



But this is all trial and error. I want a way to automate this by telling tikz to scale the text between 2 coordinates on a line to "fit".



What would be a good way to do this sort of thing? i.e I want labels to automatically "fit" in the space they are in without having to edit coordinates each time I change the label.










share|improve this question


























    3















    tikz newbie here.



    I want to make "template" drawing, which has part of it a line and then put different size labels on top of the line.



    The label is some latex code (equation).



    One of the problems is that, since I am using fixed coordinates each time, but the equation itself can be long or short, I need a way to make the latex font size automatically scale to fit the space.



    Otherwise, each time I make new drawing, I have to do trial and error to change either the coordinates or manually change the font size. Here is MWE to better explain what I mean



    documentclass[11pt]standalone
    usepackagetikz

    begindocument
    begintikzpicture


    coordinate[label=left:A] (A) at (0,0);
    coordinate[label=right:B] (B) at (3,0);

    newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$

    draw (A) -- node[above] myLabel ++(B);

    endtikzpicture
    enddocument


    Mathematica graphics



    Now, I can either try again with smaller font or change the coordinates to make the space larger so the new label fit.



    I do not want to change the coordinates, since if these are part of larger diagram, it means I have to also change other coordinates as well and things will start to fall apart, because once I change one coordinate, I have to go update all the other coordinates to keep the shape the same.



    So I try again with smaller font, like this



    newcommandmyLabelfootnotesize$sin(x)+cos(y)=int_0^infty e^x y, dx$;


    Ok, a little better



    Mathematica graphics



    but still does not fit right. So I try now with



     newcommandmyLabeltiny$sin(x)+cos(y)=int_0^infty e^x y, dx$;


    Mathematica graphics



    Ok a little better.



    But this is all trial and error. I want a way to automate this by telling tikz to scale the text between 2 coordinates on a line to "fit".



    What would be a good way to do this sort of thing? i.e I want labels to automatically "fit" in the space they are in without having to edit coordinates each time I change the label.










    share|improve this question
























      3












      3








      3


      1






      tikz newbie here.



      I want to make "template" drawing, which has part of it a line and then put different size labels on top of the line.



      The label is some latex code (equation).



      One of the problems is that, since I am using fixed coordinates each time, but the equation itself can be long or short, I need a way to make the latex font size automatically scale to fit the space.



      Otherwise, each time I make new drawing, I have to do trial and error to change either the coordinates or manually change the font size. Here is MWE to better explain what I mean



      documentclass[11pt]standalone
      usepackagetikz

      begindocument
      begintikzpicture


      coordinate[label=left:A] (A) at (0,0);
      coordinate[label=right:B] (B) at (3,0);

      newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$

      draw (A) -- node[above] myLabel ++(B);

      endtikzpicture
      enddocument


      Mathematica graphics



      Now, I can either try again with smaller font or change the coordinates to make the space larger so the new label fit.



      I do not want to change the coordinates, since if these are part of larger diagram, it means I have to also change other coordinates as well and things will start to fall apart, because once I change one coordinate, I have to go update all the other coordinates to keep the shape the same.



      So I try again with smaller font, like this



      newcommandmyLabelfootnotesize$sin(x)+cos(y)=int_0^infty e^x y, dx$;


      Ok, a little better



      Mathematica graphics



      but still does not fit right. So I try now with



       newcommandmyLabeltiny$sin(x)+cos(y)=int_0^infty e^x y, dx$;


      Mathematica graphics



      Ok a little better.



      But this is all trial and error. I want a way to automate this by telling tikz to scale the text between 2 coordinates on a line to "fit".



      What would be a good way to do this sort of thing? i.e I want labels to automatically "fit" in the space they are in without having to edit coordinates each time I change the label.










      share|improve this question














      tikz newbie here.



      I want to make "template" drawing, which has part of it a line and then put different size labels on top of the line.



      The label is some latex code (equation).



      One of the problems is that, since I am using fixed coordinates each time, but the equation itself can be long or short, I need a way to make the latex font size automatically scale to fit the space.



      Otherwise, each time I make new drawing, I have to do trial and error to change either the coordinates or manually change the font size. Here is MWE to better explain what I mean



      documentclass[11pt]standalone
      usepackagetikz

      begindocument
      begintikzpicture


      coordinate[label=left:A] (A) at (0,0);
      coordinate[label=right:B] (B) at (3,0);

      newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$

      draw (A) -- node[above] myLabel ++(B);

      endtikzpicture
      enddocument


      Mathematica graphics



      Now, I can either try again with smaller font or change the coordinates to make the space larger so the new label fit.



      I do not want to change the coordinates, since if these are part of larger diagram, it means I have to also change other coordinates as well and things will start to fall apart, because once I change one coordinate, I have to go update all the other coordinates to keep the shape the same.



      So I try again with smaller font, like this



      newcommandmyLabelfootnotesize$sin(x)+cos(y)=int_0^infty e^x y, dx$;


      Ok, a little better



      Mathematica graphics



      but still does not fit right. So I try now with



       newcommandmyLabeltiny$sin(x)+cos(y)=int_0^infty e^x y, dx$;


      Mathematica graphics



      Ok a little better.



      But this is all trial and error. I want a way to automate this by telling tikz to scale the text between 2 coordinates on a line to "fit".



      What would be a good way to do this sort of thing? i.e I want labels to automatically "fit" in the space they are in without having to edit coordinates each time I change the label.







      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 5 hours ago









      NasserNasser

      8,47883490




      8,47883490




















          1 Answer
          1






          active

          oldest

          votes


















          4














          The general strategy is to measure the length of the path and then either measure the width of the node contents (first example) to compute the relevant scale factor, or to use adjustbox to scale the node to the length of the path (second example).



          documentclass[11pt]standalone
          usepackagetikz
          usetikzlibrarycalc
          begindocument
          begintikzpicture


          coordinate[label=left:A] (A) at (0,0);
          coordinate[label=right:B] (B) at (3,0);

          newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$
          pgfmathsetmacromywidthwidth("myLabel")
          draw let p1=($(B)-(A)$),n1=veclen(x1,y1) in (A) --
          node[above,scale=n1/mywidth] myLabel ++(B);

          endtikzpicture
          enddocument


          enter image description here



          You can turn this into a style. This case can be adjusted to the actual use cases, which I do not know.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarycalc
          usepackageadjustbox
          begindocument
          begintikzpicture[fitting label/.style args=between #1 and #2 with #3%
          insert path=let p1=($(#2)-(#1)$),n1=veclen(x1,y1)
          in (#1) -- (#2) node[midway]adjustboxwidth=n1#3
          ]


          coordinate[label=left:A] (A) at (0,0);
          coordinate[label=right:B] (B) at (3,0);

          newcommandmyLabel$displaystylesin(x)+cos(y)=intlimits_0^infty mathrme^x y,
          mathrmdx$
          draw[above,fitting label=between A and B with myLabel];
          endtikzpicture
          enddocument


          enter image description here






          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%2f491382%2fhow-to-make-labels-automatically-scale-in-size-to-fit-between-2-coordinates-in-t%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









            4














            The general strategy is to measure the length of the path and then either measure the width of the node contents (first example) to compute the relevant scale factor, or to use adjustbox to scale the node to the length of the path (second example).



            documentclass[11pt]standalone
            usepackagetikz
            usetikzlibrarycalc
            begindocument
            begintikzpicture


            coordinate[label=left:A] (A) at (0,0);
            coordinate[label=right:B] (B) at (3,0);

            newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$
            pgfmathsetmacromywidthwidth("myLabel")
            draw let p1=($(B)-(A)$),n1=veclen(x1,y1) in (A) --
            node[above,scale=n1/mywidth] myLabel ++(B);

            endtikzpicture
            enddocument


            enter image description here



            You can turn this into a style. This case can be adjusted to the actual use cases, which I do not know.



            documentclass[tikz,border=3.14mm]standalone
            usetikzlibrarycalc
            usepackageadjustbox
            begindocument
            begintikzpicture[fitting label/.style args=between #1 and #2 with #3%
            insert path=let p1=($(#2)-(#1)$),n1=veclen(x1,y1)
            in (#1) -- (#2) node[midway]adjustboxwidth=n1#3
            ]


            coordinate[label=left:A] (A) at (0,0);
            coordinate[label=right:B] (B) at (3,0);

            newcommandmyLabel$displaystylesin(x)+cos(y)=intlimits_0^infty mathrme^x y,
            mathrmdx$
            draw[above,fitting label=between A and B with myLabel];
            endtikzpicture
            enddocument


            enter image description here






            share|improve this answer





























              4














              The general strategy is to measure the length of the path and then either measure the width of the node contents (first example) to compute the relevant scale factor, or to use adjustbox to scale the node to the length of the path (second example).



              documentclass[11pt]standalone
              usepackagetikz
              usetikzlibrarycalc
              begindocument
              begintikzpicture


              coordinate[label=left:A] (A) at (0,0);
              coordinate[label=right:B] (B) at (3,0);

              newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$
              pgfmathsetmacromywidthwidth("myLabel")
              draw let p1=($(B)-(A)$),n1=veclen(x1,y1) in (A) --
              node[above,scale=n1/mywidth] myLabel ++(B);

              endtikzpicture
              enddocument


              enter image description here



              You can turn this into a style. This case can be adjusted to the actual use cases, which I do not know.



              documentclass[tikz,border=3.14mm]standalone
              usetikzlibrarycalc
              usepackageadjustbox
              begindocument
              begintikzpicture[fitting label/.style args=between #1 and #2 with #3%
              insert path=let p1=($(#2)-(#1)$),n1=veclen(x1,y1)
              in (#1) -- (#2) node[midway]adjustboxwidth=n1#3
              ]


              coordinate[label=left:A] (A) at (0,0);
              coordinate[label=right:B] (B) at (3,0);

              newcommandmyLabel$displaystylesin(x)+cos(y)=intlimits_0^infty mathrme^x y,
              mathrmdx$
              draw[above,fitting label=between A and B with myLabel];
              endtikzpicture
              enddocument


              enter image description here






              share|improve this answer



























                4












                4








                4







                The general strategy is to measure the length of the path and then either measure the width of the node contents (first example) to compute the relevant scale factor, or to use adjustbox to scale the node to the length of the path (second example).



                documentclass[11pt]standalone
                usepackagetikz
                usetikzlibrarycalc
                begindocument
                begintikzpicture


                coordinate[label=left:A] (A) at (0,0);
                coordinate[label=right:B] (B) at (3,0);

                newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$
                pgfmathsetmacromywidthwidth("myLabel")
                draw let p1=($(B)-(A)$),n1=veclen(x1,y1) in (A) --
                node[above,scale=n1/mywidth] myLabel ++(B);

                endtikzpicture
                enddocument


                enter image description here



                You can turn this into a style. This case can be adjusted to the actual use cases, which I do not know.



                documentclass[tikz,border=3.14mm]standalone
                usetikzlibrarycalc
                usepackageadjustbox
                begindocument
                begintikzpicture[fitting label/.style args=between #1 and #2 with #3%
                insert path=let p1=($(#2)-(#1)$),n1=veclen(x1,y1)
                in (#1) -- (#2) node[midway]adjustboxwidth=n1#3
                ]


                coordinate[label=left:A] (A) at (0,0);
                coordinate[label=right:B] (B) at (3,0);

                newcommandmyLabel$displaystylesin(x)+cos(y)=intlimits_0^infty mathrme^x y,
                mathrmdx$
                draw[above,fitting label=between A and B with myLabel];
                endtikzpicture
                enddocument


                enter image description here






                share|improve this answer















                The general strategy is to measure the length of the path and then either measure the width of the node contents (first example) to compute the relevant scale factor, or to use adjustbox to scale the node to the length of the path (second example).



                documentclass[11pt]standalone
                usepackagetikz
                usetikzlibrarycalc
                begindocument
                begintikzpicture


                coordinate[label=left:A] (A) at (0,0);
                coordinate[label=right:B] (B) at (3,0);

                newcommandmyLabel$sin(x)+cos(y)=int_0^infty e^x y, dx$
                pgfmathsetmacromywidthwidth("myLabel")
                draw let p1=($(B)-(A)$),n1=veclen(x1,y1) in (A) --
                node[above,scale=n1/mywidth] myLabel ++(B);

                endtikzpicture
                enddocument


                enter image description here



                You can turn this into a style. This case can be adjusted to the actual use cases, which I do not know.



                documentclass[tikz,border=3.14mm]standalone
                usetikzlibrarycalc
                usepackageadjustbox
                begindocument
                begintikzpicture[fitting label/.style args=between #1 and #2 with #3%
                insert path=let p1=($(#2)-(#1)$),n1=veclen(x1,y1)
                in (#1) -- (#2) node[midway]adjustboxwidth=n1#3
                ]


                coordinate[label=left:A] (A) at (0,0);
                coordinate[label=right:B] (B) at (3,0);

                newcommandmyLabel$displaystylesin(x)+cos(y)=intlimits_0^infty mathrme^x y,
                mathrmdx$
                draw[above,fitting label=between A and B with myLabel];
                endtikzpicture
                enddocument


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 3 hours ago

























                answered 4 hours ago









                marmotmarmot

                128k6162308




                128k6162308



























                    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%2f491382%2fhow-to-make-labels-automatically-scale-in-size-to-fit-between-2-coordinates-in-t%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

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單