How to remove unit from variable?












2















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?
enter image description here










share|improve this question























  • 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


















2















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?
enter image description here










share|improve this question























  • 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
















2












2








2








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?
enter image description here










share|improve this question














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?
enter image description here







tikz-pgf tikz-calc






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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) 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



















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












1 Answer
1






active

oldest

votes


















2














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}


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%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









    2














    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}


    enter image description here






    share|improve this answer




























      2














      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}


      enter image description here






      share|improve this answer


























        2












        2








        2







        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}


        enter image description here






        share|improve this answer













        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}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 22 at 15:15









        marmotmarmot

        105k4124236




        105k4124236






























            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%2f476153%2fhow-to-remove-unit-from-variable%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

            mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?