How to “add” units to results of pgfmathsetmacro?How can I produce a 'ring (or wheel) chart' like that on page 88 of the PGF manual?How to draw arcs linking two points in TikZ?Numerical conditional within tikz keys?circle vs arch with shorten — normal or bug?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingNode anchor centre of lineTikZ: create break in arc behind diameter?Drawing an arc between 2 nodes with a specific radiusHow to incorporate pgf macro into tikz path commandDrawing a curve (not necessarily an arc) in tikz-3dplot
How much can I judge a company based on a phone screening?
In which case does the Security misconfiguration vulnerability apply to?
How is являться different from есть and быть
How would you translate this? バタコチーズライス
Do Reform Jews believe in a theistic God?
Is this n-speak?
How do some PhD students get 10+ papers? Is that what I need for landing good faculty position?
Case Condition for two lines
Why is the Lucas test not recommended to differentiate higher alcohols?
How far did Gandalf and the Balrog drop from the bridge in Moria?
What is a "soap"?
Does fossil fuels use since 1990 account for half of all the fossil fuels used in history?
Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?
My cat is a houdini
Clarification on Integrability
What can Amex do if I cancel their card after using the sign up bonus miles?
How would timezones work on a planet 100 times the size of our Earth
Is it okay for a ticket seller to grab a tip in the USA?
(A room / an office) where an artist works
Are there really no countries that protect Freedom of Speech as the United States does?
Should I email my professor about a recommendation letter if he has offered me a job?
Are there any other rule mechanics that could grant Thieves' Cant?
How should I write this passage to make it the most readable?
How big are the Choedan Kal?
How to “add” units to results of pgfmathsetmacro?
How can I produce a 'ring (or wheel) chart' like that on page 88 of the PGF manual?How to draw arcs linking two points in TikZ?Numerical conditional within tikz keys?circle vs arch with shorten — normal or bug?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingNode anchor centre of lineTikZ: create break in arc behind diameter?Drawing an arc between 2 nodes with a specific radiusHow to incorporate pgf macro into tikz path commandDrawing a curve (not necessarily an arc) in tikz-3dplot
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
This question is inspired by Jake's answer to this question. The problem is illustrated by this MWE:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
draw[red,line width=dr] (0:ro) arc (0:360:ro);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
This produces the following output:
But this is not what I want, which is that the red strip should be between the two black circles. I expected that I could achieve this by replacing the first draw
command by
draw[red,line width=dr] (0:rm) arc (0:360:rm);
but then I get a non-sensical result in which the red strip is far too large:
This is not surprising given the remarks in Section 94.1.2 "Considerations concerning units" in the pgf manual (v3.1.2). What does surprise me is that simply adding cm
like this
draw[red,line width=dr] (0:rm cm) arc (0:360:rm cm);
does not work - in the sense that there is no change in the output. However, in Jake's answer, he adds pt
which seems to work (as witnessed by his comment Somehow, the [...] units got lost, so we add 'pt' at the end. Not nice...
).
So my questions are:
- Why does adding
pt
work in Jake's answer but not when I addcm
? - I cannot make sense of Section 94.1.2. There seem to be commands for checking whether units are "declared" but there do not seem to be any commands for "adding them back" to a result. What good is it to be able to check for units but not "adding them back"?
tikz-pgf pgfmath
add a comment |
This question is inspired by Jake's answer to this question. The problem is illustrated by this MWE:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
draw[red,line width=dr] (0:ro) arc (0:360:ro);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
This produces the following output:
But this is not what I want, which is that the red strip should be between the two black circles. I expected that I could achieve this by replacing the first draw
command by
draw[red,line width=dr] (0:rm) arc (0:360:rm);
but then I get a non-sensical result in which the red strip is far too large:
This is not surprising given the remarks in Section 94.1.2 "Considerations concerning units" in the pgf manual (v3.1.2). What does surprise me is that simply adding cm
like this
draw[red,line width=dr] (0:rm cm) arc (0:360:rm cm);
does not work - in the sense that there is no change in the output. However, in Jake's answer, he adds pt
which seems to work (as witnessed by his comment Somehow, the [...] units got lost, so we add 'pt' at the end. Not nice...
).
So my questions are:
- Why does adding
pt
work in Jake's answer but not when I addcm
? - I cannot make sense of Section 94.1.2. There seem to be commands for checking whether units are "declared" but there do not seem to be any commands for "adding them back" to a result. What good is it to be able to check for units but not "adding them back"?
tikz-pgf pgfmath
Also check out pgfmathsetlength and pgfmathsetlengthmacro.
– John Kormylo
41 mins ago
add a comment |
This question is inspired by Jake's answer to this question. The problem is illustrated by this MWE:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
draw[red,line width=dr] (0:ro) arc (0:360:ro);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
This produces the following output:
But this is not what I want, which is that the red strip should be between the two black circles. I expected that I could achieve this by replacing the first draw
command by
draw[red,line width=dr] (0:rm) arc (0:360:rm);
but then I get a non-sensical result in which the red strip is far too large:
This is not surprising given the remarks in Section 94.1.2 "Considerations concerning units" in the pgf manual (v3.1.2). What does surprise me is that simply adding cm
like this
draw[red,line width=dr] (0:rm cm) arc (0:360:rm cm);
does not work - in the sense that there is no change in the output. However, in Jake's answer, he adds pt
which seems to work (as witnessed by his comment Somehow, the [...] units got lost, so we add 'pt' at the end. Not nice...
).
So my questions are:
- Why does adding
pt
work in Jake's answer but not when I addcm
? - I cannot make sense of Section 94.1.2. There seem to be commands for checking whether units are "declared" but there do not seem to be any commands for "adding them back" to a result. What good is it to be able to check for units but not "adding them back"?
tikz-pgf pgfmath
This question is inspired by Jake's answer to this question. The problem is illustrated by this MWE:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
draw[red,line width=dr] (0:ro) arc (0:360:ro);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
This produces the following output:
But this is not what I want, which is that the red strip should be between the two black circles. I expected that I could achieve this by replacing the first draw
command by
draw[red,line width=dr] (0:rm) arc (0:360:rm);
but then I get a non-sensical result in which the red strip is far too large:
This is not surprising given the remarks in Section 94.1.2 "Considerations concerning units" in the pgf manual (v3.1.2). What does surprise me is that simply adding cm
like this
draw[red,line width=dr] (0:rm cm) arc (0:360:rm cm);
does not work - in the sense that there is no change in the output. However, in Jake's answer, he adds pt
which seems to work (as witnessed by his comment Somehow, the [...] units got lost, so we add 'pt' at the end. Not nice...
).
So my questions are:
- Why does adding
pt
work in Jake's answer but not when I addcm
? - I cannot make sense of Section 94.1.2. There seem to be commands for checking whether units are "declared" but there do not seem to be any commands for "adding them back" to a result. What good is it to be able to check for units but not "adding them back"?
tikz-pgf pgfmath
tikz-pgf pgfmath
edited 9 hours ago
user1362373
asked 10 hours ago
user1362373user1362373
1,0951 gold badge11 silver badges28 bronze badges
1,0951 gold badge11 silver badges28 bronze badges
Also check out pgfmathsetlength and pgfmathsetlengthmacro.
– John Kormylo
41 mins ago
add a comment |
Also check out pgfmathsetlength and pgfmathsetlengthmacro.
– John Kormylo
41 mins ago
Also check out pgfmathsetlength and pgfmathsetlengthmacro.
– John Kormylo
41 mins ago
Also check out pgfmathsetlength and pgfmathsetlengthmacro.
– John Kormylo
41 mins ago
add a comment |
2 Answers
2
active
oldest
votes
pgfmathsetmacro
calculates a length and gives back the result in pt but without the unit pt attached - the macro contains simply a number. So if you want to use this number in a sensible way you should reattach the pt:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
showrm %<--- shows > rm=macro: ->42.67912.
draw[red,line width=dr] (0:rm pt) arc (0:360:rm pt);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
Instead of pdfmathsetmacro
you can use pgfmathsetlengthmacro
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetlengthmacrodrro-ri % compute width
pgfmathsetlengthmacrorm(ri+ro)/2 % compute mean diameter
showrm % > rm=macro: ->42.67912pt.
draw[red,line width=dr] (0:rm) arc (0:360:rm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
add a comment |
Very simple: divide or multiply by 1cm
. That way you can work in any units you like, such as cm. (I do not recommend using rm
for a macro name, though.)
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2cm % compute mean diameter
typeoutrm
draw[red,line width=dr] (0:rm*1cm) arc (0:360:rm*1cm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
New contributor
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%2f504097%2fhow-to-add-units-to-results-of-pgfmathsetmacro%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
pgfmathsetmacro
calculates a length and gives back the result in pt but without the unit pt attached - the macro contains simply a number. So if you want to use this number in a sensible way you should reattach the pt:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
showrm %<--- shows > rm=macro: ->42.67912.
draw[red,line width=dr] (0:rm pt) arc (0:360:rm pt);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
Instead of pdfmathsetmacro
you can use pgfmathsetlengthmacro
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetlengthmacrodrro-ri % compute width
pgfmathsetlengthmacrorm(ri+ro)/2 % compute mean diameter
showrm % > rm=macro: ->42.67912pt.
draw[red,line width=dr] (0:rm) arc (0:360:rm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
add a comment |
pgfmathsetmacro
calculates a length and gives back the result in pt but without the unit pt attached - the macro contains simply a number. So if you want to use this number in a sensible way you should reattach the pt:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
showrm %<--- shows > rm=macro: ->42.67912.
draw[red,line width=dr] (0:rm pt) arc (0:360:rm pt);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
Instead of pdfmathsetmacro
you can use pgfmathsetlengthmacro
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetlengthmacrodrro-ri % compute width
pgfmathsetlengthmacrorm(ri+ro)/2 % compute mean diameter
showrm % > rm=macro: ->42.67912pt.
draw[red,line width=dr] (0:rm) arc (0:360:rm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
add a comment |
pgfmathsetmacro
calculates a length and gives back the result in pt but without the unit pt attached - the macro contains simply a number. So if you want to use this number in a sensible way you should reattach the pt:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
showrm %<--- shows > rm=macro: ->42.67912.
draw[red,line width=dr] (0:rm pt) arc (0:360:rm pt);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
Instead of pdfmathsetmacro
you can use pgfmathsetlengthmacro
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetlengthmacrodrro-ri % compute width
pgfmathsetlengthmacrorm(ri+ro)/2 % compute mean diameter
showrm % > rm=macro: ->42.67912pt.
draw[red,line width=dr] (0:rm) arc (0:360:rm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
pgfmathsetmacro
calculates a length and gives back the result in pt but without the unit pt attached - the macro contains simply a number. So if you want to use this number in a sensible way you should reattach the pt:
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2 % compute mean diameter
showrm %<--- shows > rm=macro: ->42.67912.
draw[red,line width=dr] (0:rm pt) arc (0:360:rm pt);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
Instead of pdfmathsetmacro
you can use pgfmathsetlengthmacro
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetlengthmacrodrro-ri % compute width
pgfmathsetlengthmacrorm(ri+ro)/2 % compute mean diameter
showrm % > rm=macro: ->42.67912pt.
draw[red,line width=dr] (0:rm) arc (0:360:rm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
answered 9 hours ago
Ulrike FischerUlrike Fischer
212k9 gold badges320 silver badges719 bronze badges
212k9 gold badges320 silver badges719 bronze badges
add a comment |
add a comment |
Very simple: divide or multiply by 1cm
. That way you can work in any units you like, such as cm. (I do not recommend using rm
for a macro name, though.)
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2cm % compute mean diameter
typeoutrm
draw[red,line width=dr] (0:rm*1cm) arc (0:360:rm*1cm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
New contributor
add a comment |
Very simple: divide or multiply by 1cm
. That way you can work in any units you like, such as cm. (I do not recommend using rm
for a macro name, though.)
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2cm % compute mean diameter
typeoutrm
draw[red,line width=dr] (0:rm*1cm) arc (0:360:rm*1cm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
New contributor
add a comment |
Very simple: divide or multiply by 1cm
. That way you can work in any units you like, such as cm. (I do not recommend using rm
for a macro name, though.)
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2cm % compute mean diameter
typeoutrm
draw[red,line width=dr] (0:rm*1cm) arc (0:360:rm*1cm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
New contributor
Very simple: divide or multiply by 1cm
. That way you can work in any units you like, such as cm. (I do not recommend using rm
for a macro name, though.)
documentclassstandalone
usepackagetikz
begindocument
defri1.0cm % define inner diameter
defro2.0cm % define outer diameter
begintikzpicture
pgfmathsetmacrodrro-ri % compute width
pgfmathsetmacrorm(ri+ro)/2cm % compute mean diameter
typeoutrm
draw[red,line width=dr] (0:rm*1cm) arc (0:360:rm*1cm);
draw[black] (0,0) circle (ro) circle (ri);
endtikzpicture
enddocument
New contributor
New contributor
answered 51 mins ago
HamanostorosHamanostoros
411 bronze badge
411 bronze badge
New contributor
New contributor
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%2f504097%2fhow-to-add-units-to-results-of-pgfmathsetmacro%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
Also check out pgfmathsetlength and pgfmathsetlengthmacro.
– John Kormylo
41 mins ago