How to replace space with '+' symbol in a triangular array?How to draw a circle with a triangle in TikZ?Visualize array changes with arrows(not)implies sign as edges in tikz graphHow to make the number line?drawing patterns based on prime factorizationHow can I make a diagram with lots of colored circles?Generating ukulele chord diagramscolored boxes diagram with textStandard align space with CD environment from amscd packageHow to draw a triangular prism in latex?

Promotion comes with unexpected 24/7/365 on-call

He is the first man to arrive here

Have there been any examples of re-usable rockets in the past?

What are the effects of eating many berries from the Goodberry spell per day?

I recently started my machine learning PhD and I have absolutely no idea what I'm doing

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?

How can I make dummy text (like lipsum) grey?

Solenoid fastest possible release - for how long should reversed polarity be applied?

How do Ctrl+C and Ctrl+V work?

Why is Drogon so much better in battle than Rhaegal and Viserion?

Would life always name the light from their sun "white"

Usage of the relative pronoun "dont"

Is there an academic word that means "to split hairs over"?

Why does string strummed with finger sound different from the one strummed with pick?

FIFO data structure in pure C

Why does the U.S military use mercenaries?

Why are there five extra turns in tournament Magic?

Is it standard to have the first week's pay indefinitely withheld?

What would a Dragon have to exhale to cause rain?

What technology would Dwarves need to forge titanium?

Capital gains on stocks sold to take initial investment off the table

"Counterexample" for the Inverse function theorem

How can I safely determine the output voltage and current of a transformer?

How to generate a triangular grid from a list of points



How to replace space with '+' symbol in a triangular array?


How to draw a circle with a triangle in TikZ?Visualize array changes with arrows(not)implies sign as edges in tikz graphHow to make the number line?drawing patterns based on prime factorizationHow can I make a diagram with lots of colored circles?Generating ukulele chord diagramscolored boxes diagram with textStandard align space with CD environment from amscd packageHow to draw a triangular prism in latex?













14















How can I make number pattern like this



enter image description here



But, all spaces are replaced with plus signs ?










share|improve this question



















  • 1





    Welcome to TeX.SE!

    – Kurt
    May 5 at 4:03






  • 3





    In the final row of your screenshot, should there be a space between 10 and 11?

    – Mico
    May 5 at 4:12















14















How can I make number pattern like this



enter image description here



But, all spaces are replaced with plus signs ?










share|improve this question



















  • 1





    Welcome to TeX.SE!

    – Kurt
    May 5 at 4:03






  • 3





    In the final row of your screenshot, should there be a space between 10 and 11?

    – Mico
    May 5 at 4:12













14












14








14


4






How can I make number pattern like this



enter image description here



But, all spaces are replaced with plus signs ?










share|improve this question
















How can I make number pattern like this



enter image description here



But, all spaces are replaced with plus signs ?







diagrams






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 5 at 11:39









Mico

291k32399788




291k32399788










asked May 5 at 3:14









LimoPandaLimoPanda

744




744







  • 1





    Welcome to TeX.SE!

    – Kurt
    May 5 at 4:03






  • 3





    In the final row of your screenshot, should there be a space between 10 and 11?

    – Mico
    May 5 at 4:12












  • 1





    Welcome to TeX.SE!

    – Kurt
    May 5 at 4:03






  • 3





    In the final row of your screenshot, should there be a space between 10 and 11?

    – Mico
    May 5 at 4:12







1




1





Welcome to TeX.SE!

– Kurt
May 5 at 4:03





Welcome to TeX.SE!

– Kurt
May 5 at 4:03




3




3





In the final row of your screenshot, should there be a space between 10 and 11?

– Mico
May 5 at 4:12





In the final row of your screenshot, should there be a space between 10 and 11?

– Mico
May 5 at 4:12










5 Answers
5






active

oldest

votes


















21














Just for fun: without packages.



documentclassarticle
newcounterpft
newcounterpfft
begindocument
setcounterpft0loop%
stepcounterpft%
setcounterpfft0noindent$loop%
stepcounterpfftnumbervaluepfft%
ifnumnumbervaluepfft<numbervaluepft+repeat$par%
ifnumnumbervaluepft<11repeat%
enddocument


enter image description here



Or with pgffor, which contains the foreach command that is used in JouleV's nice answer, and which is loaded by TikZ.



documentclassarticle
usepackagepgffor
begindocument
foreach X in 1,...,11%
noindent$foreach Y in 1,...,X%
ifnumY>1%
+%
fi%
Y
$par
enddocument


Since everyone has a bonus...



documentclassarticle
newcounterpft
newcounterpfft
newcountersum
begindocument
beginflushright
setcounterpft0loop%
stepcounterpft%
setcounterpfft0setcountersum0noindent$loop%
stepcounterpfftnumbervaluepfftaddtocountersumvaluepfft%
ifnumnumbervaluepfft<numbervaluepft+repeat=numbervaluesum%
ifnumvaluesum<10relaxphantom1fi$par%
ifnumnumbervaluepft<11repeat%
endflushright
enddocument


enter image description here






share|improve this answer
































    15














    Let's employ TikZ and some simple algorithms for such things.



    documentclass[tikz]standalone
    begindocument
    begintikzpicture[x=5ex,y=5ex]
    defmaxnum11 % Change the size here
    foreach i in 1,...,maxnum
    % Draw the numbers
    pgfmathsetmacroauxnummaxnum-i+1
    foreach j in 1,...,auxnum
    node (i-j) at (i,j) i;
    % Draw the plus signs
    ifnumi=maxnumrelaxelse
    pgfmathsetmacroauxnummaxnum-i
    foreach j in 1,...,auxnum
    node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
    fi

    endtikzpicture
    enddocument


    enter image description here



    A little bonus:



    documentclass[tikz]standalone
    begindocument
    begintikzpicture[x=5ex,y=5ex]
    defmaxnum11
    foreach i in 1,...,maxnum
    % Draw the numbers
    pgfmathsetmacroauxnummaxnum-i+1
    foreach j in 1,...,auxnum
    node (i-j) at (i,j) i;
    % Draw the plus signs
    ifnumi=maxnumrelaxelse
    pgfmathsetmacroauxnummaxnum-i
    foreach j in 1,...,auxnum
    node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
    fi
    % The rest :)
    pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
    node (output-i) at (maxnum+1,i) sumoutput;
    node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

    endtikzpicture
    enddocument


    enter image description here




    Not sure what do you really want to get by "to the right", but maybe this?



    documentclass[tikz]standalone
    begindocument
    begintikzpicture[x=5ex,y=5ex]
    defmaxnum11
    foreach i in 1,...,maxnum
    % numbers - simpler than the above code
    foreach j [count=k] in i,...,1
    node (i-j) at (i,j) k;
    % plus signs - a bit simpler
    ifnumi=maxnumrelaxelse
    foreach j in i,...,1
    node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
    fi
    % I keep the "bonus" part - it needs no improvements
    pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
    node (output-i) at (maxnum+1,i) sumoutput;
    node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

    endtikzpicture
    enddocument


    enter image description here




    Comparison with other answers



    Other answers are very good, but it seems that this answer is totally different from all other answers (which are somehow a little similar to each other). This is the pros and cons of this answer compared to the others. Read it to consider what to use.



    Pros



    The numbers and signs are aligned in a perfect square. So you can have something like this



    documentclass[tikz]standalone
    usetikzlibrarybackgrounds,fit,calc
    begindocument
    begintikzpicture[x=5ex,y=5ex]
    defmaxnum11 % Change the size here
    foreach i in 1,...,maxnum
    % numbers - simpler than the above code
    foreach j [count=k] in i,...,1
    node[minimum size=.55cm] (i-j) at (i,j) k;
    % plus signs - a bit simpler
    ifnumi=maxnumrelaxelse
    foreach j in i,...,1
    node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
    fi
    % I keep the "bonus" part - it needs no improvements
    pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
    node (output-i) at (maxnum+1,i) sumoutput;
    node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

    beginscope[on background layer]
    path[fill=red!10,draw=red,thick]
    ([shift=( .1,-.1)]1-1.north west) --
    ([shift=( .1,-.1)]11-11.north west)
    arc (135:-45:.55/sqrt(2)) --
    ([shift=(-.1, .1)]1-1.south east)
    arc (315:135:.55/sqrt(2)); % Well, possibly this is not the best
    % way to draw this, but this is only
    % for illustration purpose.
    draw[red,thick,<-]
    ($([shift=( .1,-.1)]1-1.north west)!.45!([shift=( .1,-.1)]11-11.north west)$)
    -- + (-2,1) node[pos=1.3] Looks! All are number 1!;
    endscope
    endtikzpicture
    enddocument


    enter image description here



    In other answers, the numbers, say 1, are not perfectly aligned if maxnum is greater than 9, so it is harder to draw such a path.



    Cons



    It is very clear: the spacing between the numbers and the plus signs are inconsistent. But when I follow this approach (insert the plus signs separately), I have to accept this kind of spacing.



    Btw, the numbers after the equal signs are not right-aligned. This is fixable, but a fix will make the code much more complicated (if I want to automatically determine the width of the node of the "sum"). I don't think this is a major problem though.






    share|improve this answer

























    • What if you want to make it align to the right ? What is this TikZ thing ? (I'm a very-beginner)

      – LimoPanda
      May 5 at 4:05







    • 2





      Hello @LimoPanda, if you want to know what TikZ is good for, please have a look at p. 18 of this manual. ;-)

      – marmot
      May 5 at 4:10











    • @LimoPanda Sorry for the late reply. What do you want to align to the right?

      – JouleV
      May 5 at 4:34






    • 1





      @marmot I thought it should be pages 18 and 11-12 of that manual

      – JouleV
      May 5 at 4:39







    • 1





      @Mico Sure. I edited my answer.

      – JouleV
      May 5 at 14:06


















    12














    Here's a LuaLaTeX-based solution. The number of rows can be set as the argument of the LaTeX macro makearray; this macro calls the Lua function make_array, which does most of the work.



    enter image description here



    To make the triangular array right-aligned instead of left-aligned, change beginarray@l@ to beginarray@r@. If you wish to have a bit more space around the + symbols, change tex.sprint ( "+" ) to tex.sprint ( "+" ).



    % !TEX TS-program = lualatex
    documentclassarticle
    usepackageluacode % for 'luacode' environment

    %% Lua-side code: Define the Lua function 'make_array'
    beginluacode


    function make_array ( n )
    for i=1,n do
    for j=1,i do
    tex.sprint ( j )
    if j<i then
    tex.sprint ( "+" )
    else
    tex.sprint ( "\\" )
    end
    end
    end
    end


    endluacode

    %% LaTeX-side code: Define the macro 'makearray'
    newcommandmakearray[1]%
    $beginarray@l@
    directluamake_array(#1)
    endarray$


    begindocument
    makearray11
    enddocument



    Addendum: Here's a solution which typesets each row's sum along the right-hand edge of the (now rectangular) array. Compared with the solution shown above, it also allows for a bit more space around the + symbols. Observe the use of toprule and bottomrule: These instruction are optional and may be left off.



    enter image description here



    % !TEX TS-program = lualatex
    documentclassarticle
    usepackageluacode % for 'luaexec' macro
    usepackagebooktabs % for 'toprule' and 'bottomrule' macros

    %% Lua-side code: Define the function 'make_array_with_rowsum'
    luaexec%


    function make_array_with_rowsum ( n )
    for i=1,n do
    for j=1,i do
    tex.sprint ( j )
    if j<i then
    tex.sprint ( "+" )
    else
    tex.sprint ( "&=&" .. i*(i+1)//2 .. "\\" )
    end
    end
    end
    end




    %% LaTeX-side code: Define the macro 'makearray'
    newcommandmakearray[1]%
    parnoindent
    begingroup
    centering
    setlengtharraycolsep0pt
    $beginarraylcr
    toprule
    luadirectmake_array_with_rowsum(#1)
    bottomrule
    endarray$par
    endgroup

    begindocument
    makearray16
    enddocument





    share|improve this answer
































      11














      documentclassarticle
      usepackagemultido
      begindocument
      noindent$1$
      multidoiA=2+110\$%
      multidoiB=1+1numexpriA-1iB+iA$

      bigskipnoindent$1=1$
      multidoiA=2+110\$xdefSum0%
      multidoiB=1+1numexpriA-1%
      iB+xdefSumthenumexprSum+iBiA=thenumexprSum+iA$

      enddocument


      enter image description here






      share|improve this answer






























        8














        The mandatory double expl3 loop:



        documentclassarticle
        usepackagexparse,array

        ExplSyntaxOn
        NewDocumentCommandtriangletabsm
        % #1 = * for totals, #2 = end point
        IfBooleanTF #1

        begintabular@ l @ c @ r @
        int_step_inline:nn #2 panda_row_total:n ##1 \
        endtabular


        begintabular@ l @
        int_step_inline:nn #2 panda_row:n ##1 \
        endtabular


        cs_new_protected:Nn panda_row:n

        $1 int_step_inline:nnn 2 #1 + ##1 $

        cs_new_protected:Nn panda_row_total:n

        panda_row:n #1 & $=$ & $int_eval:n (#1)*(#1+1)/2 $

        ExplSyntaxOff

        begindocument

        [
        triangletab1 qquad triangletab3 qquad triangletab11
        ]

        [
        triangletab*1 qquad triangletab*3 qquad triangletab*11
        ]

        enddocument


        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%2f489242%2fhow-to-replace-space-with-symbol-in-a-triangular-array%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          21














          Just for fun: without packages.



          documentclassarticle
          newcounterpft
          newcounterpfft
          begindocument
          setcounterpft0loop%
          stepcounterpft%
          setcounterpfft0noindent$loop%
          stepcounterpfftnumbervaluepfft%
          ifnumnumbervaluepfft<numbervaluepft+repeat$par%
          ifnumnumbervaluepft<11repeat%
          enddocument


          enter image description here



          Or with pgffor, which contains the foreach command that is used in JouleV's nice answer, and which is loaded by TikZ.



          documentclassarticle
          usepackagepgffor
          begindocument
          foreach X in 1,...,11%
          noindent$foreach Y in 1,...,X%
          ifnumY>1%
          +%
          fi%
          Y
          $par
          enddocument


          Since everyone has a bonus...



          documentclassarticle
          newcounterpft
          newcounterpfft
          newcountersum
          begindocument
          beginflushright
          setcounterpft0loop%
          stepcounterpft%
          setcounterpfft0setcountersum0noindent$loop%
          stepcounterpfftnumbervaluepfftaddtocountersumvaluepfft%
          ifnumnumbervaluepfft<numbervaluepft+repeat=numbervaluesum%
          ifnumvaluesum<10relaxphantom1fi$par%
          ifnumnumbervaluepft<11repeat%
          endflushright
          enddocument


          enter image description here






          share|improve this answer





























            21














            Just for fun: without packages.



            documentclassarticle
            newcounterpft
            newcounterpfft
            begindocument
            setcounterpft0loop%
            stepcounterpft%
            setcounterpfft0noindent$loop%
            stepcounterpfftnumbervaluepfft%
            ifnumnumbervaluepfft<numbervaluepft+repeat$par%
            ifnumnumbervaluepft<11repeat%
            enddocument


            enter image description here



            Or with pgffor, which contains the foreach command that is used in JouleV's nice answer, and which is loaded by TikZ.



            documentclassarticle
            usepackagepgffor
            begindocument
            foreach X in 1,...,11%
            noindent$foreach Y in 1,...,X%
            ifnumY>1%
            +%
            fi%
            Y
            $par
            enddocument


            Since everyone has a bonus...



            documentclassarticle
            newcounterpft
            newcounterpfft
            newcountersum
            begindocument
            beginflushright
            setcounterpft0loop%
            stepcounterpft%
            setcounterpfft0setcountersum0noindent$loop%
            stepcounterpfftnumbervaluepfftaddtocountersumvaluepfft%
            ifnumnumbervaluepfft<numbervaluepft+repeat=numbervaluesum%
            ifnumvaluesum<10relaxphantom1fi$par%
            ifnumnumbervaluepft<11repeat%
            endflushright
            enddocument


            enter image description here






            share|improve this answer



























              21












              21








              21







              Just for fun: without packages.



              documentclassarticle
              newcounterpft
              newcounterpfft
              begindocument
              setcounterpft0loop%
              stepcounterpft%
              setcounterpfft0noindent$loop%
              stepcounterpfftnumbervaluepfft%
              ifnumnumbervaluepfft<numbervaluepft+repeat$par%
              ifnumnumbervaluepft<11repeat%
              enddocument


              enter image description here



              Or with pgffor, which contains the foreach command that is used in JouleV's nice answer, and which is loaded by TikZ.



              documentclassarticle
              usepackagepgffor
              begindocument
              foreach X in 1,...,11%
              noindent$foreach Y in 1,...,X%
              ifnumY>1%
              +%
              fi%
              Y
              $par
              enddocument


              Since everyone has a bonus...



              documentclassarticle
              newcounterpft
              newcounterpfft
              newcountersum
              begindocument
              beginflushright
              setcounterpft0loop%
              stepcounterpft%
              setcounterpfft0setcountersum0noindent$loop%
              stepcounterpfftnumbervaluepfftaddtocountersumvaluepfft%
              ifnumnumbervaluepfft<numbervaluepft+repeat=numbervaluesum%
              ifnumvaluesum<10relaxphantom1fi$par%
              ifnumnumbervaluepft<11repeat%
              endflushright
              enddocument


              enter image description here






              share|improve this answer















              Just for fun: without packages.



              documentclassarticle
              newcounterpft
              newcounterpfft
              begindocument
              setcounterpft0loop%
              stepcounterpft%
              setcounterpfft0noindent$loop%
              stepcounterpfftnumbervaluepfft%
              ifnumnumbervaluepfft<numbervaluepft+repeat$par%
              ifnumnumbervaluepft<11repeat%
              enddocument


              enter image description here



              Or with pgffor, which contains the foreach command that is used in JouleV's nice answer, and which is loaded by TikZ.



              documentclassarticle
              usepackagepgffor
              begindocument
              foreach X in 1,...,11%
              noindent$foreach Y in 1,...,X%
              ifnumY>1%
              +%
              fi%
              Y
              $par
              enddocument


              Since everyone has a bonus...



              documentclassarticle
              newcounterpft
              newcounterpfft
              newcountersum
              begindocument
              beginflushright
              setcounterpft0loop%
              stepcounterpft%
              setcounterpfft0setcountersum0noindent$loop%
              stepcounterpfftnumbervaluepfftaddtocountersumvaluepfft%
              ifnumnumbervaluepfft<numbervaluepft+repeat=numbervaluesum%
              ifnumvaluesum<10relaxphantom1fi$par%
              ifnumnumbervaluepft<11repeat%
              endflushright
              enddocument


              enter image description here







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 8 at 21:20

























              answered May 5 at 3:58









              marmotmarmot

              127k6162308




              127k6162308





















                  15














                  Let's employ TikZ and some simple algorithms for such things.



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11 % Change the size here
                  foreach i in 1,...,maxnum
                  % Draw the numbers
                  pgfmathsetmacroauxnummaxnum-i+1
                  foreach j in 1,...,auxnum
                  node (i-j) at (i,j) i;
                  % Draw the plus signs
                  ifnumi=maxnumrelaxelse
                  pgfmathsetmacroauxnummaxnum-i
                  foreach j in 1,...,auxnum
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi

                  endtikzpicture
                  enddocument


                  enter image description here



                  A little bonus:



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11
                  foreach i in 1,...,maxnum
                  % Draw the numbers
                  pgfmathsetmacroauxnummaxnum-i+1
                  foreach j in 1,...,auxnum
                  node (i-j) at (i,j) i;
                  % Draw the plus signs
                  ifnumi=maxnumrelaxelse
                  pgfmathsetmacroauxnummaxnum-i
                  foreach j in 1,...,auxnum
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % The rest :)
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  endtikzpicture
                  enddocument


                  enter image description here




                  Not sure what do you really want to get by "to the right", but maybe this?



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11
                  foreach i in 1,...,maxnum
                  % numbers - simpler than the above code
                  foreach j [count=k] in i,...,1
                  node (i-j) at (i,j) k;
                  % plus signs - a bit simpler
                  ifnumi=maxnumrelaxelse
                  foreach j in i,...,1
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % I keep the "bonus" part - it needs no improvements
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  endtikzpicture
                  enddocument


                  enter image description here




                  Comparison with other answers



                  Other answers are very good, but it seems that this answer is totally different from all other answers (which are somehow a little similar to each other). This is the pros and cons of this answer compared to the others. Read it to consider what to use.



                  Pros



                  The numbers and signs are aligned in a perfect square. So you can have something like this



                  documentclass[tikz]standalone
                  usetikzlibrarybackgrounds,fit,calc
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11 % Change the size here
                  foreach i in 1,...,maxnum
                  % numbers - simpler than the above code
                  foreach j [count=k] in i,...,1
                  node[minimum size=.55cm] (i-j) at (i,j) k;
                  % plus signs - a bit simpler
                  ifnumi=maxnumrelaxelse
                  foreach j in i,...,1
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % I keep the "bonus" part - it needs no improvements
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  beginscope[on background layer]
                  path[fill=red!10,draw=red,thick]
                  ([shift=( .1,-.1)]1-1.north west) --
                  ([shift=( .1,-.1)]11-11.north west)
                  arc (135:-45:.55/sqrt(2)) --
                  ([shift=(-.1, .1)]1-1.south east)
                  arc (315:135:.55/sqrt(2)); % Well, possibly this is not the best
                  % way to draw this, but this is only
                  % for illustration purpose.
                  draw[red,thick,<-]
                  ($([shift=( .1,-.1)]1-1.north west)!.45!([shift=( .1,-.1)]11-11.north west)$)
                  -- + (-2,1) node[pos=1.3] Looks! All are number 1!;
                  endscope
                  endtikzpicture
                  enddocument


                  enter image description here



                  In other answers, the numbers, say 1, are not perfectly aligned if maxnum is greater than 9, so it is harder to draw such a path.



                  Cons



                  It is very clear: the spacing between the numbers and the plus signs are inconsistent. But when I follow this approach (insert the plus signs separately), I have to accept this kind of spacing.



                  Btw, the numbers after the equal signs are not right-aligned. This is fixable, but a fix will make the code much more complicated (if I want to automatically determine the width of the node of the "sum"). I don't think this is a major problem though.






                  share|improve this answer

























                  • What if you want to make it align to the right ? What is this TikZ thing ? (I'm a very-beginner)

                    – LimoPanda
                    May 5 at 4:05







                  • 2





                    Hello @LimoPanda, if you want to know what TikZ is good for, please have a look at p. 18 of this manual. ;-)

                    – marmot
                    May 5 at 4:10











                  • @LimoPanda Sorry for the late reply. What do you want to align to the right?

                    – JouleV
                    May 5 at 4:34






                  • 1





                    @marmot I thought it should be pages 18 and 11-12 of that manual

                    – JouleV
                    May 5 at 4:39







                  • 1





                    @Mico Sure. I edited my answer.

                    – JouleV
                    May 5 at 14:06















                  15














                  Let's employ TikZ and some simple algorithms for such things.



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11 % Change the size here
                  foreach i in 1,...,maxnum
                  % Draw the numbers
                  pgfmathsetmacroauxnummaxnum-i+1
                  foreach j in 1,...,auxnum
                  node (i-j) at (i,j) i;
                  % Draw the plus signs
                  ifnumi=maxnumrelaxelse
                  pgfmathsetmacroauxnummaxnum-i
                  foreach j in 1,...,auxnum
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi

                  endtikzpicture
                  enddocument


                  enter image description here



                  A little bonus:



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11
                  foreach i in 1,...,maxnum
                  % Draw the numbers
                  pgfmathsetmacroauxnummaxnum-i+1
                  foreach j in 1,...,auxnum
                  node (i-j) at (i,j) i;
                  % Draw the plus signs
                  ifnumi=maxnumrelaxelse
                  pgfmathsetmacroauxnummaxnum-i
                  foreach j in 1,...,auxnum
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % The rest :)
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  endtikzpicture
                  enddocument


                  enter image description here




                  Not sure what do you really want to get by "to the right", but maybe this?



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11
                  foreach i in 1,...,maxnum
                  % numbers - simpler than the above code
                  foreach j [count=k] in i,...,1
                  node (i-j) at (i,j) k;
                  % plus signs - a bit simpler
                  ifnumi=maxnumrelaxelse
                  foreach j in i,...,1
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % I keep the "bonus" part - it needs no improvements
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  endtikzpicture
                  enddocument


                  enter image description here




                  Comparison with other answers



                  Other answers are very good, but it seems that this answer is totally different from all other answers (which are somehow a little similar to each other). This is the pros and cons of this answer compared to the others. Read it to consider what to use.



                  Pros



                  The numbers and signs are aligned in a perfect square. So you can have something like this



                  documentclass[tikz]standalone
                  usetikzlibrarybackgrounds,fit,calc
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11 % Change the size here
                  foreach i in 1,...,maxnum
                  % numbers - simpler than the above code
                  foreach j [count=k] in i,...,1
                  node[minimum size=.55cm] (i-j) at (i,j) k;
                  % plus signs - a bit simpler
                  ifnumi=maxnumrelaxelse
                  foreach j in i,...,1
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % I keep the "bonus" part - it needs no improvements
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  beginscope[on background layer]
                  path[fill=red!10,draw=red,thick]
                  ([shift=( .1,-.1)]1-1.north west) --
                  ([shift=( .1,-.1)]11-11.north west)
                  arc (135:-45:.55/sqrt(2)) --
                  ([shift=(-.1, .1)]1-1.south east)
                  arc (315:135:.55/sqrt(2)); % Well, possibly this is not the best
                  % way to draw this, but this is only
                  % for illustration purpose.
                  draw[red,thick,<-]
                  ($([shift=( .1,-.1)]1-1.north west)!.45!([shift=( .1,-.1)]11-11.north west)$)
                  -- + (-2,1) node[pos=1.3] Looks! All are number 1!;
                  endscope
                  endtikzpicture
                  enddocument


                  enter image description here



                  In other answers, the numbers, say 1, are not perfectly aligned if maxnum is greater than 9, so it is harder to draw such a path.



                  Cons



                  It is very clear: the spacing between the numbers and the plus signs are inconsistent. But when I follow this approach (insert the plus signs separately), I have to accept this kind of spacing.



                  Btw, the numbers after the equal signs are not right-aligned. This is fixable, but a fix will make the code much more complicated (if I want to automatically determine the width of the node of the "sum"). I don't think this is a major problem though.






                  share|improve this answer

























                  • What if you want to make it align to the right ? What is this TikZ thing ? (I'm a very-beginner)

                    – LimoPanda
                    May 5 at 4:05







                  • 2





                    Hello @LimoPanda, if you want to know what TikZ is good for, please have a look at p. 18 of this manual. ;-)

                    – marmot
                    May 5 at 4:10











                  • @LimoPanda Sorry for the late reply. What do you want to align to the right?

                    – JouleV
                    May 5 at 4:34






                  • 1





                    @marmot I thought it should be pages 18 and 11-12 of that manual

                    – JouleV
                    May 5 at 4:39







                  • 1





                    @Mico Sure. I edited my answer.

                    – JouleV
                    May 5 at 14:06













                  15












                  15








                  15







                  Let's employ TikZ and some simple algorithms for such things.



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11 % Change the size here
                  foreach i in 1,...,maxnum
                  % Draw the numbers
                  pgfmathsetmacroauxnummaxnum-i+1
                  foreach j in 1,...,auxnum
                  node (i-j) at (i,j) i;
                  % Draw the plus signs
                  ifnumi=maxnumrelaxelse
                  pgfmathsetmacroauxnummaxnum-i
                  foreach j in 1,...,auxnum
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi

                  endtikzpicture
                  enddocument


                  enter image description here



                  A little bonus:



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11
                  foreach i in 1,...,maxnum
                  % Draw the numbers
                  pgfmathsetmacroauxnummaxnum-i+1
                  foreach j in 1,...,auxnum
                  node (i-j) at (i,j) i;
                  % Draw the plus signs
                  ifnumi=maxnumrelaxelse
                  pgfmathsetmacroauxnummaxnum-i
                  foreach j in 1,...,auxnum
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % The rest :)
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  endtikzpicture
                  enddocument


                  enter image description here




                  Not sure what do you really want to get by "to the right", but maybe this?



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11
                  foreach i in 1,...,maxnum
                  % numbers - simpler than the above code
                  foreach j [count=k] in i,...,1
                  node (i-j) at (i,j) k;
                  % plus signs - a bit simpler
                  ifnumi=maxnumrelaxelse
                  foreach j in i,...,1
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % I keep the "bonus" part - it needs no improvements
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  endtikzpicture
                  enddocument


                  enter image description here




                  Comparison with other answers



                  Other answers are very good, but it seems that this answer is totally different from all other answers (which are somehow a little similar to each other). This is the pros and cons of this answer compared to the others. Read it to consider what to use.



                  Pros



                  The numbers and signs are aligned in a perfect square. So you can have something like this



                  documentclass[tikz]standalone
                  usetikzlibrarybackgrounds,fit,calc
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11 % Change the size here
                  foreach i in 1,...,maxnum
                  % numbers - simpler than the above code
                  foreach j [count=k] in i,...,1
                  node[minimum size=.55cm] (i-j) at (i,j) k;
                  % plus signs - a bit simpler
                  ifnumi=maxnumrelaxelse
                  foreach j in i,...,1
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % I keep the "bonus" part - it needs no improvements
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  beginscope[on background layer]
                  path[fill=red!10,draw=red,thick]
                  ([shift=( .1,-.1)]1-1.north west) --
                  ([shift=( .1,-.1)]11-11.north west)
                  arc (135:-45:.55/sqrt(2)) --
                  ([shift=(-.1, .1)]1-1.south east)
                  arc (315:135:.55/sqrt(2)); % Well, possibly this is not the best
                  % way to draw this, but this is only
                  % for illustration purpose.
                  draw[red,thick,<-]
                  ($([shift=( .1,-.1)]1-1.north west)!.45!([shift=( .1,-.1)]11-11.north west)$)
                  -- + (-2,1) node[pos=1.3] Looks! All are number 1!;
                  endscope
                  endtikzpicture
                  enddocument


                  enter image description here



                  In other answers, the numbers, say 1, are not perfectly aligned if maxnum is greater than 9, so it is harder to draw such a path.



                  Cons



                  It is very clear: the spacing between the numbers and the plus signs are inconsistent. But when I follow this approach (insert the plus signs separately), I have to accept this kind of spacing.



                  Btw, the numbers after the equal signs are not right-aligned. This is fixable, but a fix will make the code much more complicated (if I want to automatically determine the width of the node of the "sum"). I don't think this is a major problem though.






                  share|improve this answer















                  Let's employ TikZ and some simple algorithms for such things.



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11 % Change the size here
                  foreach i in 1,...,maxnum
                  % Draw the numbers
                  pgfmathsetmacroauxnummaxnum-i+1
                  foreach j in 1,...,auxnum
                  node (i-j) at (i,j) i;
                  % Draw the plus signs
                  ifnumi=maxnumrelaxelse
                  pgfmathsetmacroauxnummaxnum-i
                  foreach j in 1,...,auxnum
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi

                  endtikzpicture
                  enddocument


                  enter image description here



                  A little bonus:



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11
                  foreach i in 1,...,maxnum
                  % Draw the numbers
                  pgfmathsetmacroauxnummaxnum-i+1
                  foreach j in 1,...,auxnum
                  node (i-j) at (i,j) i;
                  % Draw the plus signs
                  ifnumi=maxnumrelaxelse
                  pgfmathsetmacroauxnummaxnum-i
                  foreach j in 1,...,auxnum
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % The rest :)
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  endtikzpicture
                  enddocument


                  enter image description here




                  Not sure what do you really want to get by "to the right", but maybe this?



                  documentclass[tikz]standalone
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11
                  foreach i in 1,...,maxnum
                  % numbers - simpler than the above code
                  foreach j [count=k] in i,...,1
                  node (i-j) at (i,j) k;
                  % plus signs - a bit simpler
                  ifnumi=maxnumrelaxelse
                  foreach j in i,...,1
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % I keep the "bonus" part - it needs no improvements
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  endtikzpicture
                  enddocument


                  enter image description here




                  Comparison with other answers



                  Other answers are very good, but it seems that this answer is totally different from all other answers (which are somehow a little similar to each other). This is the pros and cons of this answer compared to the others. Read it to consider what to use.



                  Pros



                  The numbers and signs are aligned in a perfect square. So you can have something like this



                  documentclass[tikz]standalone
                  usetikzlibrarybackgrounds,fit,calc
                  begindocument
                  begintikzpicture[x=5ex,y=5ex]
                  defmaxnum11 % Change the size here
                  foreach i in 1,...,maxnum
                  % numbers - simpler than the above code
                  foreach j [count=k] in i,...,1
                  node[minimum size=.55cm] (i-j) at (i,j) k;
                  % plus signs - a bit simpler
                  ifnumi=maxnumrelaxelse
                  foreach j in i,...,1
                  node[anchor=base] at ([shift=(.5,0)]i-j.base) +;
                  fi
                  % I keep the "bonus" part - it needs no improvements
                  pgfmathsetmacrosumoutputint((maxnum-i+1)*(maxnum-i+2)/2)
                  node (output-i) at (maxnum+1,i) sumoutput;
                  node[anchor=base] at ([shift=(-.5,0)]output-i.base) =;

                  beginscope[on background layer]
                  path[fill=red!10,draw=red,thick]
                  ([shift=( .1,-.1)]1-1.north west) --
                  ([shift=( .1,-.1)]11-11.north west)
                  arc (135:-45:.55/sqrt(2)) --
                  ([shift=(-.1, .1)]1-1.south east)
                  arc (315:135:.55/sqrt(2)); % Well, possibly this is not the best
                  % way to draw this, but this is only
                  % for illustration purpose.
                  draw[red,thick,<-]
                  ($([shift=( .1,-.1)]1-1.north west)!.45!([shift=( .1,-.1)]11-11.north west)$)
                  -- + (-2,1) node[pos=1.3] Looks! All are number 1!;
                  endscope
                  endtikzpicture
                  enddocument


                  enter image description here



                  In other answers, the numbers, say 1, are not perfectly aligned if maxnum is greater than 9, so it is harder to draw such a path.



                  Cons



                  It is very clear: the spacing between the numbers and the plus signs are inconsistent. But when I follow this approach (insert the plus signs separately), I have to accept this kind of spacing.



                  Btw, the numbers after the equal signs are not right-aligned. This is fixable, but a fix will make the code much more complicated (if I want to automatically determine the width of the node of the "sum"). I don't think this is a major problem though.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 9 at 4:18

























                  answered May 5 at 3:29









                  JouleVJouleV

                  17.6k22971




                  17.6k22971












                  • What if you want to make it align to the right ? What is this TikZ thing ? (I'm a very-beginner)

                    – LimoPanda
                    May 5 at 4:05







                  • 2





                    Hello @LimoPanda, if you want to know what TikZ is good for, please have a look at p. 18 of this manual. ;-)

                    – marmot
                    May 5 at 4:10











                  • @LimoPanda Sorry for the late reply. What do you want to align to the right?

                    – JouleV
                    May 5 at 4:34






                  • 1





                    @marmot I thought it should be pages 18 and 11-12 of that manual

                    – JouleV
                    May 5 at 4:39







                  • 1





                    @Mico Sure. I edited my answer.

                    – JouleV
                    May 5 at 14:06

















                  • What if you want to make it align to the right ? What is this TikZ thing ? (I'm a very-beginner)

                    – LimoPanda
                    May 5 at 4:05







                  • 2





                    Hello @LimoPanda, if you want to know what TikZ is good for, please have a look at p. 18 of this manual. ;-)

                    – marmot
                    May 5 at 4:10











                  • @LimoPanda Sorry for the late reply. What do you want to align to the right?

                    – JouleV
                    May 5 at 4:34






                  • 1





                    @marmot I thought it should be pages 18 and 11-12 of that manual

                    – JouleV
                    May 5 at 4:39







                  • 1





                    @Mico Sure. I edited my answer.

                    – JouleV
                    May 5 at 14:06
















                  What if you want to make it align to the right ? What is this TikZ thing ? (I'm a very-beginner)

                  – LimoPanda
                  May 5 at 4:05






                  What if you want to make it align to the right ? What is this TikZ thing ? (I'm a very-beginner)

                  – LimoPanda
                  May 5 at 4:05





                  2




                  2





                  Hello @LimoPanda, if you want to know what TikZ is good for, please have a look at p. 18 of this manual. ;-)

                  – marmot
                  May 5 at 4:10





                  Hello @LimoPanda, if you want to know what TikZ is good for, please have a look at p. 18 of this manual. ;-)

                  – marmot
                  May 5 at 4:10













                  @LimoPanda Sorry for the late reply. What do you want to align to the right?

                  – JouleV
                  May 5 at 4:34





                  @LimoPanda Sorry for the late reply. What do you want to align to the right?

                  – JouleV
                  May 5 at 4:34




                  1




                  1





                  @marmot I thought it should be pages 18 and 11-12 of that manual

                  – JouleV
                  May 5 at 4:39






                  @marmot I thought it should be pages 18 and 11-12 of that manual

                  – JouleV
                  May 5 at 4:39





                  1




                  1





                  @Mico Sure. I edited my answer.

                  – JouleV
                  May 5 at 14:06





                  @Mico Sure. I edited my answer.

                  – JouleV
                  May 5 at 14:06











                  12














                  Here's a LuaLaTeX-based solution. The number of rows can be set as the argument of the LaTeX macro makearray; this macro calls the Lua function make_array, which does most of the work.



                  enter image description here



                  To make the triangular array right-aligned instead of left-aligned, change beginarray@l@ to beginarray@r@. If you wish to have a bit more space around the + symbols, change tex.sprint ( "+" ) to tex.sprint ( "+" ).



                  % !TEX TS-program = lualatex
                  documentclassarticle
                  usepackageluacode % for 'luacode' environment

                  %% Lua-side code: Define the Lua function 'make_array'
                  beginluacode


                  function make_array ( n )
                  for i=1,n do
                  for j=1,i do
                  tex.sprint ( j )
                  if j<i then
                  tex.sprint ( "+" )
                  else
                  tex.sprint ( "\\" )
                  end
                  end
                  end
                  end


                  endluacode

                  %% LaTeX-side code: Define the macro 'makearray'
                  newcommandmakearray[1]%
                  $beginarray@l@
                  directluamake_array(#1)
                  endarray$


                  begindocument
                  makearray11
                  enddocument



                  Addendum: Here's a solution which typesets each row's sum along the right-hand edge of the (now rectangular) array. Compared with the solution shown above, it also allows for a bit more space around the + symbols. Observe the use of toprule and bottomrule: These instruction are optional and may be left off.



                  enter image description here



                  % !TEX TS-program = lualatex
                  documentclassarticle
                  usepackageluacode % for 'luaexec' macro
                  usepackagebooktabs % for 'toprule' and 'bottomrule' macros

                  %% Lua-side code: Define the function 'make_array_with_rowsum'
                  luaexec%


                  function make_array_with_rowsum ( n )
                  for i=1,n do
                  for j=1,i do
                  tex.sprint ( j )
                  if j<i then
                  tex.sprint ( "+" )
                  else
                  tex.sprint ( "&=&" .. i*(i+1)//2 .. "\\" )
                  end
                  end
                  end
                  end




                  %% LaTeX-side code: Define the macro 'makearray'
                  newcommandmakearray[1]%
                  parnoindent
                  begingroup
                  centering
                  setlengtharraycolsep0pt
                  $beginarraylcr
                  toprule
                  luadirectmake_array_with_rowsum(#1)
                  bottomrule
                  endarray$par
                  endgroup

                  begindocument
                  makearray16
                  enddocument





                  share|improve this answer





























                    12














                    Here's a LuaLaTeX-based solution. The number of rows can be set as the argument of the LaTeX macro makearray; this macro calls the Lua function make_array, which does most of the work.



                    enter image description here



                    To make the triangular array right-aligned instead of left-aligned, change beginarray@l@ to beginarray@r@. If you wish to have a bit more space around the + symbols, change tex.sprint ( "+" ) to tex.sprint ( "+" ).



                    % !TEX TS-program = lualatex
                    documentclassarticle
                    usepackageluacode % for 'luacode' environment

                    %% Lua-side code: Define the Lua function 'make_array'
                    beginluacode


                    function make_array ( n )
                    for i=1,n do
                    for j=1,i do
                    tex.sprint ( j )
                    if j<i then
                    tex.sprint ( "+" )
                    else
                    tex.sprint ( "\\" )
                    end
                    end
                    end
                    end


                    endluacode

                    %% LaTeX-side code: Define the macro 'makearray'
                    newcommandmakearray[1]%
                    $beginarray@l@
                    directluamake_array(#1)
                    endarray$


                    begindocument
                    makearray11
                    enddocument



                    Addendum: Here's a solution which typesets each row's sum along the right-hand edge of the (now rectangular) array. Compared with the solution shown above, it also allows for a bit more space around the + symbols. Observe the use of toprule and bottomrule: These instruction are optional and may be left off.



                    enter image description here



                    % !TEX TS-program = lualatex
                    documentclassarticle
                    usepackageluacode % for 'luaexec' macro
                    usepackagebooktabs % for 'toprule' and 'bottomrule' macros

                    %% Lua-side code: Define the function 'make_array_with_rowsum'
                    luaexec%


                    function make_array_with_rowsum ( n )
                    for i=1,n do
                    for j=1,i do
                    tex.sprint ( j )
                    if j<i then
                    tex.sprint ( "+" )
                    else
                    tex.sprint ( "&=&" .. i*(i+1)//2 .. "\\" )
                    end
                    end
                    end
                    end




                    %% LaTeX-side code: Define the macro 'makearray'
                    newcommandmakearray[1]%
                    parnoindent
                    begingroup
                    centering
                    setlengtharraycolsep0pt
                    $beginarraylcr
                    toprule
                    luadirectmake_array_with_rowsum(#1)
                    bottomrule
                    endarray$par
                    endgroup

                    begindocument
                    makearray16
                    enddocument





                    share|improve this answer



























                      12












                      12








                      12







                      Here's a LuaLaTeX-based solution. The number of rows can be set as the argument of the LaTeX macro makearray; this macro calls the Lua function make_array, which does most of the work.



                      enter image description here



                      To make the triangular array right-aligned instead of left-aligned, change beginarray@l@ to beginarray@r@. If you wish to have a bit more space around the + symbols, change tex.sprint ( "+" ) to tex.sprint ( "+" ).



                      % !TEX TS-program = lualatex
                      documentclassarticle
                      usepackageluacode % for 'luacode' environment

                      %% Lua-side code: Define the Lua function 'make_array'
                      beginluacode


                      function make_array ( n )
                      for i=1,n do
                      for j=1,i do
                      tex.sprint ( j )
                      if j<i then
                      tex.sprint ( "+" )
                      else
                      tex.sprint ( "\\" )
                      end
                      end
                      end
                      end


                      endluacode

                      %% LaTeX-side code: Define the macro 'makearray'
                      newcommandmakearray[1]%
                      $beginarray@l@
                      directluamake_array(#1)
                      endarray$


                      begindocument
                      makearray11
                      enddocument



                      Addendum: Here's a solution which typesets each row's sum along the right-hand edge of the (now rectangular) array. Compared with the solution shown above, it also allows for a bit more space around the + symbols. Observe the use of toprule and bottomrule: These instruction are optional and may be left off.



                      enter image description here



                      % !TEX TS-program = lualatex
                      documentclassarticle
                      usepackageluacode % for 'luaexec' macro
                      usepackagebooktabs % for 'toprule' and 'bottomrule' macros

                      %% Lua-side code: Define the function 'make_array_with_rowsum'
                      luaexec%


                      function make_array_with_rowsum ( n )
                      for i=1,n do
                      for j=1,i do
                      tex.sprint ( j )
                      if j<i then
                      tex.sprint ( "+" )
                      else
                      tex.sprint ( "&=&" .. i*(i+1)//2 .. "\\" )
                      end
                      end
                      end
                      end




                      %% LaTeX-side code: Define the macro 'makearray'
                      newcommandmakearray[1]%
                      parnoindent
                      begingroup
                      centering
                      setlengtharraycolsep0pt
                      $beginarraylcr
                      toprule
                      luadirectmake_array_with_rowsum(#1)
                      bottomrule
                      endarray$par
                      endgroup

                      begindocument
                      makearray16
                      enddocument





                      share|improve this answer















                      Here's a LuaLaTeX-based solution. The number of rows can be set as the argument of the LaTeX macro makearray; this macro calls the Lua function make_array, which does most of the work.



                      enter image description here



                      To make the triangular array right-aligned instead of left-aligned, change beginarray@l@ to beginarray@r@. If you wish to have a bit more space around the + symbols, change tex.sprint ( "+" ) to tex.sprint ( "+" ).



                      % !TEX TS-program = lualatex
                      documentclassarticle
                      usepackageluacode % for 'luacode' environment

                      %% Lua-side code: Define the Lua function 'make_array'
                      beginluacode


                      function make_array ( n )
                      for i=1,n do
                      for j=1,i do
                      tex.sprint ( j )
                      if j<i then
                      tex.sprint ( "+" )
                      else
                      tex.sprint ( "\\" )
                      end
                      end
                      end
                      end


                      endluacode

                      %% LaTeX-side code: Define the macro 'makearray'
                      newcommandmakearray[1]%
                      $beginarray@l@
                      directluamake_array(#1)
                      endarray$


                      begindocument
                      makearray11
                      enddocument



                      Addendum: Here's a solution which typesets each row's sum along the right-hand edge of the (now rectangular) array. Compared with the solution shown above, it also allows for a bit more space around the + symbols. Observe the use of toprule and bottomrule: These instruction are optional and may be left off.



                      enter image description here



                      % !TEX TS-program = lualatex
                      documentclassarticle
                      usepackageluacode % for 'luaexec' macro
                      usepackagebooktabs % for 'toprule' and 'bottomrule' macros

                      %% Lua-side code: Define the function 'make_array_with_rowsum'
                      luaexec%


                      function make_array_with_rowsum ( n )
                      for i=1,n do
                      for j=1,i do
                      tex.sprint ( j )
                      if j<i then
                      tex.sprint ( "+" )
                      else
                      tex.sprint ( "&=&" .. i*(i+1)//2 .. "\\" )
                      end
                      end
                      end
                      end




                      %% LaTeX-side code: Define the macro 'makearray'
                      newcommandmakearray[1]%
                      parnoindent
                      begingroup
                      centering
                      setlengtharraycolsep0pt
                      $beginarraylcr
                      toprule
                      luadirectmake_array_with_rowsum(#1)
                      bottomrule
                      endarray$par
                      endgroup

                      begindocument
                      makearray16
                      enddocument






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited May 5 at 10:05

























                      answered May 5 at 4:07









                      MicoMico

                      291k32399788




                      291k32399788





















                          11














                          documentclassarticle
                          usepackagemultido
                          begindocument
                          noindent$1$
                          multidoiA=2+110\$%
                          multidoiB=1+1numexpriA-1iB+iA$

                          bigskipnoindent$1=1$
                          multidoiA=2+110\$xdefSum0%
                          multidoiB=1+1numexpriA-1%
                          iB+xdefSumthenumexprSum+iBiA=thenumexprSum+iA$

                          enddocument


                          enter image description here






                          share|improve this answer



























                            11














                            documentclassarticle
                            usepackagemultido
                            begindocument
                            noindent$1$
                            multidoiA=2+110\$%
                            multidoiB=1+1numexpriA-1iB+iA$

                            bigskipnoindent$1=1$
                            multidoiA=2+110\$xdefSum0%
                            multidoiB=1+1numexpriA-1%
                            iB+xdefSumthenumexprSum+iBiA=thenumexprSum+iA$

                            enddocument


                            enter image description here






                            share|improve this answer

























                              11












                              11








                              11







                              documentclassarticle
                              usepackagemultido
                              begindocument
                              noindent$1$
                              multidoiA=2+110\$%
                              multidoiB=1+1numexpriA-1iB+iA$

                              bigskipnoindent$1=1$
                              multidoiA=2+110\$xdefSum0%
                              multidoiB=1+1numexpriA-1%
                              iB+xdefSumthenumexprSum+iBiA=thenumexprSum+iA$

                              enddocument


                              enter image description here






                              share|improve this answer













                              documentclassarticle
                              usepackagemultido
                              begindocument
                              noindent$1$
                              multidoiA=2+110\$%
                              multidoiB=1+1numexpriA-1iB+iA$

                              bigskipnoindent$1=1$
                              multidoiA=2+110\$xdefSum0%
                              multidoiB=1+1numexpriA-1%
                              iB+xdefSumthenumexprSum+iBiA=thenumexprSum+iA$

                              enddocument


                              enter image description here







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 5 at 6:15









                              Red-CloudRed-Cloud

                              2,30313




                              2,30313





















                                  8














                                  The mandatory double expl3 loop:



                                  documentclassarticle
                                  usepackagexparse,array

                                  ExplSyntaxOn
                                  NewDocumentCommandtriangletabsm
                                  % #1 = * for totals, #2 = end point
                                  IfBooleanTF #1

                                  begintabular@ l @ c @ r @
                                  int_step_inline:nn #2 panda_row_total:n ##1 \
                                  endtabular


                                  begintabular@ l @
                                  int_step_inline:nn #2 panda_row:n ##1 \
                                  endtabular


                                  cs_new_protected:Nn panda_row:n

                                  $1 int_step_inline:nnn 2 #1 + ##1 $

                                  cs_new_protected:Nn panda_row_total:n

                                  panda_row:n #1 & $=$ & $int_eval:n (#1)*(#1+1)/2 $

                                  ExplSyntaxOff

                                  begindocument

                                  [
                                  triangletab1 qquad triangletab3 qquad triangletab11
                                  ]

                                  [
                                  triangletab*1 qquad triangletab*3 qquad triangletab*11
                                  ]

                                  enddocument


                                  enter image description here






                                  share|improve this answer



























                                    8














                                    The mandatory double expl3 loop:



                                    documentclassarticle
                                    usepackagexparse,array

                                    ExplSyntaxOn
                                    NewDocumentCommandtriangletabsm
                                    % #1 = * for totals, #2 = end point
                                    IfBooleanTF #1

                                    begintabular@ l @ c @ r @
                                    int_step_inline:nn #2 panda_row_total:n ##1 \
                                    endtabular


                                    begintabular@ l @
                                    int_step_inline:nn #2 panda_row:n ##1 \
                                    endtabular


                                    cs_new_protected:Nn panda_row:n

                                    $1 int_step_inline:nnn 2 #1 + ##1 $

                                    cs_new_protected:Nn panda_row_total:n

                                    panda_row:n #1 & $=$ & $int_eval:n (#1)*(#1+1)/2 $

                                    ExplSyntaxOff

                                    begindocument

                                    [
                                    triangletab1 qquad triangletab3 qquad triangletab11
                                    ]

                                    [
                                    triangletab*1 qquad triangletab*3 qquad triangletab*11
                                    ]

                                    enddocument


                                    enter image description here






                                    share|improve this answer

























                                      8












                                      8








                                      8







                                      The mandatory double expl3 loop:



                                      documentclassarticle
                                      usepackagexparse,array

                                      ExplSyntaxOn
                                      NewDocumentCommandtriangletabsm
                                      % #1 = * for totals, #2 = end point
                                      IfBooleanTF #1

                                      begintabular@ l @ c @ r @
                                      int_step_inline:nn #2 panda_row_total:n ##1 \
                                      endtabular


                                      begintabular@ l @
                                      int_step_inline:nn #2 panda_row:n ##1 \
                                      endtabular


                                      cs_new_protected:Nn panda_row:n

                                      $1 int_step_inline:nnn 2 #1 + ##1 $

                                      cs_new_protected:Nn panda_row_total:n

                                      panda_row:n #1 & $=$ & $int_eval:n (#1)*(#1+1)/2 $

                                      ExplSyntaxOff

                                      begindocument

                                      [
                                      triangletab1 qquad triangletab3 qquad triangletab11
                                      ]

                                      [
                                      triangletab*1 qquad triangletab*3 qquad triangletab*11
                                      ]

                                      enddocument


                                      enter image description here






                                      share|improve this answer













                                      The mandatory double expl3 loop:



                                      documentclassarticle
                                      usepackagexparse,array

                                      ExplSyntaxOn
                                      NewDocumentCommandtriangletabsm
                                      % #1 = * for totals, #2 = end point
                                      IfBooleanTF #1

                                      begintabular@ l @ c @ r @
                                      int_step_inline:nn #2 panda_row_total:n ##1 \
                                      endtabular


                                      begintabular@ l @
                                      int_step_inline:nn #2 panda_row:n ##1 \
                                      endtabular


                                      cs_new_protected:Nn panda_row:n

                                      $1 int_step_inline:nnn 2 #1 + ##1 $

                                      cs_new_protected:Nn panda_row_total:n

                                      panda_row:n #1 & $=$ & $int_eval:n (#1)*(#1+1)/2 $

                                      ExplSyntaxOff

                                      begindocument

                                      [
                                      triangletab1 qquad triangletab3 qquad triangletab11
                                      ]

                                      [
                                      triangletab*1 qquad triangletab*3 qquad triangletab*11
                                      ]

                                      enddocument


                                      enter image description here







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered May 5 at 13:23









                                      egregegreg

                                      742k8919423274




                                      742k8919423274



























                                          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%2f489242%2fhow-to-replace-space-with-symbol-in-a-triangular-array%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

                                          Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                                          Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                                          Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020