How to remove unit from variable?
I want to draw an arc of a certain length in cm, so I divide by the circumference in cm and multiply 360 to get the segment in degrees. (Is there a shortcut?)
In my MWE b
is the unitless number I want to get from a
.
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
defb{{a / (1cm*pi) *20}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
%draw[very thin] (0,0.1) -- ({b+0.1},0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
%draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
As can be seen from the node text and the commented lines b
does not behave like a unitless scalar. Removing either comment yields ERROR: Missing number, treated as zero.
How can I make b
unitless?
tikz-pgf tikz-calc
add a comment |
I want to draw an arc of a certain length in cm, so I divide by the circumference in cm and multiply 360 to get the segment in degrees. (Is there a shortcut?)
In my MWE b
is the unitless number I want to get from a
.
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
defb{{a / (1cm*pi) *20}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
%draw[very thin] (0,0.1) -- ({b+0.1},0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
%draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
As can be seen from the node text and the commented lines b
does not behave like a unitless scalar. Removing either comment yields ERROR: Missing number, treated as zero.
How can I make b
unitless?
tikz-pgf tikz-calc
Do you also want to draw the radius with the circumference? Why don't you use sin(x) and cos(x) asdraw [red,thick,domain=0:90] plot ({cos(x)}, {sin(x)});
?
– Sina Ahmadi
Feb 22 at 12:41
add a comment |
I want to draw an arc of a certain length in cm, so I divide by the circumference in cm and multiply 360 to get the segment in degrees. (Is there a shortcut?)
In my MWE b
is the unitless number I want to get from a
.
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
defb{{a / (1cm*pi) *20}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
%draw[very thin] (0,0.1) -- ({b+0.1},0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
%draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
As can be seen from the node text and the commented lines b
does not behave like a unitless scalar. Removing either comment yields ERROR: Missing number, treated as zero.
How can I make b
unitless?
tikz-pgf tikz-calc
I want to draw an arc of a certain length in cm, so I divide by the circumference in cm and multiply 360 to get the segment in degrees. (Is there a shortcut?)
In my MWE b
is the unitless number I want to get from a
.
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
defb{{a / (1cm*pi) *20}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
%draw[very thin] (0,0.1) -- ({b+0.1},0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
%draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
As can be seen from the node text and the commented lines b
does not behave like a unitless scalar. Removing either comment yields ERROR: Missing number, treated as zero.
How can I make b
unitless?
tikz-pgf tikz-calc
tikz-pgf tikz-calc
asked Feb 22 at 12:29
user2740user2740
31419
31419
Do you also want to draw the radius with the circumference? Why don't you use sin(x) and cos(x) asdraw [red,thick,domain=0:90] plot ({cos(x)}, {sin(x)});
?
– Sina Ahmadi
Feb 22 at 12:41
add a comment |
Do you also want to draw the radius with the circumference? Why don't you use sin(x) and cos(x) asdraw [red,thick,domain=0:90] plot ({cos(x)}, {sin(x)});
?
– Sina Ahmadi
Feb 22 at 12:41
Do you also want to draw the radius with the circumference? Why don't you use sin(x) and cos(x) as
draw [red,thick,domain=0:90] plot ({cos(x)}, {sin(x)});
?– Sina Ahmadi
Feb 22 at 12:41
Do you also want to draw the radius with the circumference? Why don't you use sin(x) and cos(x) as
draw [red,thick,domain=0:90] plot ({cos(x)}, {sin(x)});
?– Sina Ahmadi
Feb 22 at 12:41
add a comment |
1 Answer
1
active
oldest
votes
pgfmathsetmacro
removes units. (I replaced 20 by 2 because the plot was huge when using 20.)
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
pgfmathsetmacrob{{a / (1cm*pi) *2}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
draw[very thin] (0,0.1) -- (b+0.1,0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
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%2f476153%2fhow-to-remove-unit-from-variable%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
pgfmathsetmacro
removes units. (I replaced 20 by 2 because the plot was huge when using 20.)
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
pgfmathsetmacrob{{a / (1cm*pi) *2}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
draw[very thin] (0,0.1) -- (b+0.1,0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
add a comment |
pgfmathsetmacro
removes units. (I replaced 20 by 2 because the plot was huge when using 20.)
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
pgfmathsetmacrob{{a / (1cm*pi) *2}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
draw[very thin] (0,0.1) -- (b+0.1,0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
add a comment |
pgfmathsetmacro
removes units. (I replaced 20 by 2 because the plot was huge when using 20.)
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
pgfmathsetmacrob{{a / (1cm*pi) *2}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
draw[very thin] (0,0.1) -- (b+0.1,0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
pgfmathsetmacro
removes units. (I replaced 20 by 2 because the plot was huge when using 20.)
documentclass[tikz]{standalone}
usepackage{tikz}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
defa{3.14cm}
node[scale=0.5] at (-1,0) {a};
pgfmathsetmacrob{{a / (1cm*pi) *2}}
defc{20}
node[scale=0.5] at (-1,1) {b};
draw[very thin] (0,0) -- (a/3,0);
draw[very thin] (0,0.1) -- (b,0.1);
draw[very thin] (0,0.1) -- (b+0.1,0.1);
draw[red] (1:1) arc (1:1+20:1);
draw[blue] (30:1) arc (30:{(30+c)}:1);
draw[green] (60:1) arc (60:{(60+b)}:1);
end{tikzpicture}
end{document}
answered Feb 22 at 15:15
marmotmarmot
105k4124236
105k4124236
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%2f476153%2fhow-to-remove-unit-from-variable%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
Do you also want to draw the radius with the circumference? Why don't you use sin(x) and cos(x) as
draw [red,thick,domain=0:90] plot ({cos(x)}, {sin(x)});
?– Sina Ahmadi
Feb 22 at 12:41