numexpr behavior in math mode and/or TikZ Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)nullfont in mathmodeTable of 2x2 tikzpicturesDefine tikz node based on pagenodesBehavior of , in both text and math modeWeird Behavior of Math mode in beamerDefault spaces between letters in math-modeLegends in Externalized Graphics with TikZnarrow mode math environment in tikz nodesMath mode and beamermacros and math mode

Why not send Voyager 3 and 4 following up the paths taken by Voyager 1 and 2 to re-transmit signals of later as they fly away from Earth?

Trying to understand entropy as a novice in thermodynamics

How does the math work when buying airline miles?

NERDTreeMenu Remapping

"klopfte jemand" or "jemand klopfte"?

Google .dev domain strangely redirects to https

What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?

GDP with Intermediate Production

How does light 'choose' between wave and particle behaviour?

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

Universal covering space of the real projective line?

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

I can't produce songs

Show current row "win streak"

A proverb that is used to imply that you have unexpectedly faced a big problem

Putting class ranking in CV, but against dept guidelines

What adaptations would allow standard fantasy dwarves to survive in the desert?

How do living politicians protect their readily obtainable signatures from misuse?

Was Kant an Intuitionist about mathematical objects?

One-one communication

License to disallow distribution in closed source software, but allow exceptions made by owner?

Why are vacuum tubes still used in amateur radios?

Understanding p-Values using an example

What is the "studentd" process?



numexpr behavior in math mode and/or TikZ



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)nullfont in mathmodeTable of 2x2 tikzpicturesDefine tikz node based on pagenodesBehavior of , in both text and math modeWeird Behavior of Math mode in beamerDefault spaces between letters in math-modeLegends in Externalized Graphics with TikZnarrow mode math environment in tikz nodesMath mode and beamermacros and math mode










5















I am attempting to create a triangular grid of numbers like shown below:



enter image description here



This was created in TikZ by hard-coding each point, but I would like to generate the grid procedurally so I can make adjustments easily with a large number of points. The following code is how I have approached the problem:



documentclassarticle
usepackagetikz

begintikzpicture[scale=1.5]
foreach s in 2,...,4
foreach m in 1,...,numexprs-1
defns-m
draw (n,-m) node $a_mn$;


endtikzpicture


However this produces the following undesired result:



enter image description here



My thought to resolve this issue was to add numexpr in the n definition or prior to n in the nodes. However this produces the error you can't use 'numexpr' in math mode.



I'm at a loss as to what to do next. How can I evaluate variables like this in math mode in a TikZ picture?



As a further note, if I for testing purposes ignore my need for math mode and simply put numexprn in the node text I instead receive the similar error message you can't use 'numexpr' in restricted horizontal mode.



Also, if possible I would like to preserve this foreach iteration structure as it is ideal for other annotations I am using in my full application.










share|improve this question
























  • Probably thenumexprs-1relax

    – Henri Menke
    Apr 4 at 8:38















5















I am attempting to create a triangular grid of numbers like shown below:



enter image description here



This was created in TikZ by hard-coding each point, but I would like to generate the grid procedurally so I can make adjustments easily with a large number of points. The following code is how I have approached the problem:



documentclassarticle
usepackagetikz

begintikzpicture[scale=1.5]
foreach s in 2,...,4
foreach m in 1,...,numexprs-1
defns-m
draw (n,-m) node $a_mn$;


endtikzpicture


However this produces the following undesired result:



enter image description here



My thought to resolve this issue was to add numexpr in the n definition or prior to n in the nodes. However this produces the error you can't use 'numexpr' in math mode.



I'm at a loss as to what to do next. How can I evaluate variables like this in math mode in a TikZ picture?



As a further note, if I for testing purposes ignore my need for math mode and simply put numexprn in the node text I instead receive the similar error message you can't use 'numexpr' in restricted horizontal mode.



Also, if possible I would like to preserve this foreach iteration structure as it is ideal for other annotations I am using in my full application.










share|improve this question
























  • Probably thenumexprs-1relax

    – Henri Menke
    Apr 4 at 8:38













5












5








5








I am attempting to create a triangular grid of numbers like shown below:



enter image description here



This was created in TikZ by hard-coding each point, but I would like to generate the grid procedurally so I can make adjustments easily with a large number of points. The following code is how I have approached the problem:



documentclassarticle
usepackagetikz

begintikzpicture[scale=1.5]
foreach s in 2,...,4
foreach m in 1,...,numexprs-1
defns-m
draw (n,-m) node $a_mn$;


endtikzpicture


However this produces the following undesired result:



enter image description here



My thought to resolve this issue was to add numexpr in the n definition or prior to n in the nodes. However this produces the error you can't use 'numexpr' in math mode.



I'm at a loss as to what to do next. How can I evaluate variables like this in math mode in a TikZ picture?



As a further note, if I for testing purposes ignore my need for math mode and simply put numexprn in the node text I instead receive the similar error message you can't use 'numexpr' in restricted horizontal mode.



Also, if possible I would like to preserve this foreach iteration structure as it is ideal for other annotations I am using in my full application.










share|improve this question
















I am attempting to create a triangular grid of numbers like shown below:



enter image description here



This was created in TikZ by hard-coding each point, but I would like to generate the grid procedurally so I can make adjustments easily with a large number of points. The following code is how I have approached the problem:



documentclassarticle
usepackagetikz

begintikzpicture[scale=1.5]
foreach s in 2,...,4
foreach m in 1,...,numexprs-1
defns-m
draw (n,-m) node $a_mn$;


endtikzpicture


However this produces the following undesired result:



enter image description here



My thought to resolve this issue was to add numexpr in the n definition or prior to n in the nodes. However this produces the error you can't use 'numexpr' in math mode.



I'm at a loss as to what to do next. How can I evaluate variables like this in math mode in a TikZ picture?



As a further note, if I for testing purposes ignore my need for math mode and simply put numexprn in the node text I instead receive the similar error message you can't use 'numexpr' in restricted horizontal mode.



Also, if possible I would like to preserve this foreach iteration structure as it is ideal for other annotations I am using in my full application.







tikz-pgf math-mode programming






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 10 at 4:51









JouleV

14.6k22665




14.6k22665










asked Apr 4 at 7:58









PGmathPGmath

20315




20315












  • Probably thenumexprs-1relax

    – Henri Menke
    Apr 4 at 8:38

















  • Probably thenumexprs-1relax

    – Henri Menke
    Apr 4 at 8:38
















Probably thenumexprs-1relax

– Henri Menke
Apr 4 at 8:38





Probably thenumexprs-1relax

– Henri Menke
Apr 4 at 8:38










3 Answers
3






active

oldest

votes


















8














You could use edefnthenumexprs-m, or just use it in the subscript:



documentclassarticle
usepackagetikz

begindocument

begintikzpicture[scale=1.5]
foreach s in 2,...,4
foreach m in 1,...,numexprs-1
draw (s-m,-m) node $a_mthenumexprs-m$;


endtikzpicture

enddocument


enter image description here






share|improve this answer






























    4














    There is already one answer how to use numexpr, one how to rewrite your loop to avoid it, and here is another possibility : you can use the tools provided by foreach to make calculations. You can use count and evaluate:



    documentclass[tikz,border=7pt]standalone
    begindocument
    begintikzpicture[scale=1.5]
    foreach[count=t from 1] s in 2,...,4
    foreach[evaluate=n=int(s-m)] m in 1,...,t
    draw (n,-m) node $a_mn$;


    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer






























      3














      Avoid additional calculations. Try to think of another way of using nested foreachs.



      documentclass[tikz]standalone
      begindocument
      begintikzpicture[scale=1.5]
      foreach y in 1,...,3
      foreach x in 1,...,numexpr4-y
      draw (x,-y) node $a_yx$;


      endtikzpicture
      enddocument


      enter image description here






      share|improve this answer























      • Like I said in the post, due to the way I other annotations are drawn I would like to keep the same loop structure I used.

        – PGmath
        Apr 4 at 19:51











      • @PGmath Of course you can always keep the loop structure. However, that means you are making your problem unnecessarily complicated.

        – JouleV
        Apr 5 at 5:35











      • It's not unnecessarily complicated if I necessarily need that structure though.

        – PGmath
        Apr 5 at 5:36











      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%2f483102%2fnumexpr-behavior-in-math-mode-and-or-tikz%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      8














      You could use edefnthenumexprs-m, or just use it in the subscript:



      documentclassarticle
      usepackagetikz

      begindocument

      begintikzpicture[scale=1.5]
      foreach s in 2,...,4
      foreach m in 1,...,numexprs-1
      draw (s-m,-m) node $a_mthenumexprs-m$;


      endtikzpicture

      enddocument


      enter image description here






      share|improve this answer



























        8














        You could use edefnthenumexprs-m, or just use it in the subscript:



        documentclassarticle
        usepackagetikz

        begindocument

        begintikzpicture[scale=1.5]
        foreach s in 2,...,4
        foreach m in 1,...,numexprs-1
        draw (s-m,-m) node $a_mthenumexprs-m$;


        endtikzpicture

        enddocument


        enter image description here






        share|improve this answer

























          8












          8








          8







          You could use edefnthenumexprs-m, or just use it in the subscript:



          documentclassarticle
          usepackagetikz

          begindocument

          begintikzpicture[scale=1.5]
          foreach s in 2,...,4
          foreach m in 1,...,numexprs-1
          draw (s-m,-m) node $a_mthenumexprs-m$;


          endtikzpicture

          enddocument


          enter image description here






          share|improve this answer













          You could use edefnthenumexprs-m, or just use it in the subscript:



          documentclassarticle
          usepackagetikz

          begindocument

          begintikzpicture[scale=1.5]
          foreach s in 2,...,4
          foreach m in 1,...,numexprs-1
          draw (s-m,-m) node $a_mthenumexprs-m$;


          endtikzpicture

          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 4 at 9:08









          egregegreg

          735k8919343260




          735k8919343260





















              4














              There is already one answer how to use numexpr, one how to rewrite your loop to avoid it, and here is another possibility : you can use the tools provided by foreach to make calculations. You can use count and evaluate:



              documentclass[tikz,border=7pt]standalone
              begindocument
              begintikzpicture[scale=1.5]
              foreach[count=t from 1] s in 2,...,4
              foreach[evaluate=n=int(s-m)] m in 1,...,t
              draw (n,-m) node $a_mn$;


              endtikzpicture
              enddocument


              enter image description here






              share|improve this answer



























                4














                There is already one answer how to use numexpr, one how to rewrite your loop to avoid it, and here is another possibility : you can use the tools provided by foreach to make calculations. You can use count and evaluate:



                documentclass[tikz,border=7pt]standalone
                begindocument
                begintikzpicture[scale=1.5]
                foreach[count=t from 1] s in 2,...,4
                foreach[evaluate=n=int(s-m)] m in 1,...,t
                draw (n,-m) node $a_mn$;


                endtikzpicture
                enddocument


                enter image description here






                share|improve this answer

























                  4












                  4








                  4







                  There is already one answer how to use numexpr, one how to rewrite your loop to avoid it, and here is another possibility : you can use the tools provided by foreach to make calculations. You can use count and evaluate:



                  documentclass[tikz,border=7pt]standalone
                  begindocument
                  begintikzpicture[scale=1.5]
                  foreach[count=t from 1] s in 2,...,4
                  foreach[evaluate=n=int(s-m)] m in 1,...,t
                  draw (n,-m) node $a_mn$;


                  endtikzpicture
                  enddocument


                  enter image description here






                  share|improve this answer













                  There is already one answer how to use numexpr, one how to rewrite your loop to avoid it, and here is another possibility : you can use the tools provided by foreach to make calculations. You can use count and evaluate:



                  documentclass[tikz,border=7pt]standalone
                  begindocument
                  begintikzpicture[scale=1.5]
                  foreach[count=t from 1] s in 2,...,4
                  foreach[evaluate=n=int(s-m)] m in 1,...,t
                  draw (n,-m) node $a_mn$;


                  endtikzpicture
                  enddocument


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 4 at 9:39









                  KpymKpym

                  17.9k24192




                  17.9k24192





















                      3














                      Avoid additional calculations. Try to think of another way of using nested foreachs.



                      documentclass[tikz]standalone
                      begindocument
                      begintikzpicture[scale=1.5]
                      foreach y in 1,...,3
                      foreach x in 1,...,numexpr4-y
                      draw (x,-y) node $a_yx$;


                      endtikzpicture
                      enddocument


                      enter image description here






                      share|improve this answer























                      • Like I said in the post, due to the way I other annotations are drawn I would like to keep the same loop structure I used.

                        – PGmath
                        Apr 4 at 19:51











                      • @PGmath Of course you can always keep the loop structure. However, that means you are making your problem unnecessarily complicated.

                        – JouleV
                        Apr 5 at 5:35











                      • It's not unnecessarily complicated if I necessarily need that structure though.

                        – PGmath
                        Apr 5 at 5:36















                      3














                      Avoid additional calculations. Try to think of another way of using nested foreachs.



                      documentclass[tikz]standalone
                      begindocument
                      begintikzpicture[scale=1.5]
                      foreach y in 1,...,3
                      foreach x in 1,...,numexpr4-y
                      draw (x,-y) node $a_yx$;


                      endtikzpicture
                      enddocument


                      enter image description here






                      share|improve this answer























                      • Like I said in the post, due to the way I other annotations are drawn I would like to keep the same loop structure I used.

                        – PGmath
                        Apr 4 at 19:51











                      • @PGmath Of course you can always keep the loop structure. However, that means you are making your problem unnecessarily complicated.

                        – JouleV
                        Apr 5 at 5:35











                      • It's not unnecessarily complicated if I necessarily need that structure though.

                        – PGmath
                        Apr 5 at 5:36













                      3












                      3








                      3







                      Avoid additional calculations. Try to think of another way of using nested foreachs.



                      documentclass[tikz]standalone
                      begindocument
                      begintikzpicture[scale=1.5]
                      foreach y in 1,...,3
                      foreach x in 1,...,numexpr4-y
                      draw (x,-y) node $a_yx$;


                      endtikzpicture
                      enddocument


                      enter image description here






                      share|improve this answer













                      Avoid additional calculations. Try to think of another way of using nested foreachs.



                      documentclass[tikz]standalone
                      begindocument
                      begintikzpicture[scale=1.5]
                      foreach y in 1,...,3
                      foreach x in 1,...,numexpr4-y
                      draw (x,-y) node $a_yx$;


                      endtikzpicture
                      enddocument


                      enter image description here







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Apr 4 at 8:17









                      JouleVJouleV

                      14.6k22665




                      14.6k22665












                      • Like I said in the post, due to the way I other annotations are drawn I would like to keep the same loop structure I used.

                        – PGmath
                        Apr 4 at 19:51











                      • @PGmath Of course you can always keep the loop structure. However, that means you are making your problem unnecessarily complicated.

                        – JouleV
                        Apr 5 at 5:35











                      • It's not unnecessarily complicated if I necessarily need that structure though.

                        – PGmath
                        Apr 5 at 5:36

















                      • Like I said in the post, due to the way I other annotations are drawn I would like to keep the same loop structure I used.

                        – PGmath
                        Apr 4 at 19:51











                      • @PGmath Of course you can always keep the loop structure. However, that means you are making your problem unnecessarily complicated.

                        – JouleV
                        Apr 5 at 5:35











                      • It's not unnecessarily complicated if I necessarily need that structure though.

                        – PGmath
                        Apr 5 at 5:36
















                      Like I said in the post, due to the way I other annotations are drawn I would like to keep the same loop structure I used.

                      – PGmath
                      Apr 4 at 19:51





                      Like I said in the post, due to the way I other annotations are drawn I would like to keep the same loop structure I used.

                      – PGmath
                      Apr 4 at 19:51













                      @PGmath Of course you can always keep the loop structure. However, that means you are making your problem unnecessarily complicated.

                      – JouleV
                      Apr 5 at 5:35





                      @PGmath Of course you can always keep the loop structure. However, that means you are making your problem unnecessarily complicated.

                      – JouleV
                      Apr 5 at 5:35













                      It's not unnecessarily complicated if I necessarily need that structure though.

                      – PGmath
                      Apr 5 at 5:36





                      It's not unnecessarily complicated if I necessarily need that structure though.

                      – PGmath
                      Apr 5 at 5:36

















                      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%2f483102%2fnumexpr-behavior-in-math-mode-and-or-tikz%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

                      Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

                      Tähtien Talli Jäsenet | Lähteet | NavigointivalikkoSuomen Hippos – Tähtien Talli

                      Do these cracks on my tires look bad? The Next CEO of Stack OverflowDry rot tire should I replace?Having to replace tiresFishtailed so easily? Bad tires? ABS?Filling the tires with something other than air, to avoid puncture hassles?Used Michelin tires safe to install?Do these tyre cracks necessitate replacement?Rumbling noise: tires or mechanicalIs it possible to fix noisy feathered tires?Are bad winter tires still better than summer tires in winter?Torque converter failure - Related to replacing only 2 tires?Why use snow tires on all 4 wheels on 2-wheel-drive cars?