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 does string strummed with finger sound different from the one strummed with pick?
What should I wear to go and sign an employment contract?
Why can I not put the limit inside the limit definition of e?
Can a problematic AL DM/organizer prevent me from running a separate AL-legal game at the same store?
How could the B-29 bomber back up under its own power?
Is a reptile with diamond scales possible?
How to make labels automatically scale in size to fit between 2 coordinates in tikz?
pwaS eht tirsf dna tasl setterl fo hace dorw
Cycling to work - 30 mile return
Have the writers and actors of Game Of Thrones responded to its poor reception?
Have I found a major security issue with login
How does the "reverse syntax" in Middle English work?
Bash Array of Word-Splitting Headaches
Who is frowning in the sentence "Daisy looked at Tom frowning"?
Is it possible to view all the attribute data in QGIS
How can I prevent Bash expansion from passing files starting with "-" as argument?
Why does Taylor’s series “work”?
Better than Rembrandt
In Dutch history two people are referred to as "William III"; are there any more cases where this happens?
Can I have a delimited macro with a literal # in the parameter text?
What's is the easiest way to purchase a stock and hold it
Head-internal relative clauses
Warped chessboard
How could Dwarves prevent sand from filling up their settlements
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?
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
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
but still does not fit right. So I try now with
newcommandmyLabeltiny$sin(x)+cos(y)=int_0^infty e^x y, dx$;
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
add a comment |
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
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
but still does not fit right. So I try now with
newcommandmyLabeltiny$sin(x)+cos(y)=int_0^infty e^x y, dx$;
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
add a comment |
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
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
but still does not fit right. So I try now with
newcommandmyLabeltiny$sin(x)+cos(y)=int_0^infty e^x y, dx$;
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
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
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
but still does not fit right. So I try now with
newcommandmyLabeltiny$sin(x)+cos(y)=int_0^infty e^x y, dx$;
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
tikz-pgf
asked 6 hours ago
NasserNasser
8,48083490
8,48083490
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
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
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%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
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
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
add a comment |
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
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
add a comment |
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
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
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
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
edited 4 hours ago
answered 6 hours ago
marmotmarmot
128k6162308
128k6162308
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown