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?
How can I make number pattern like this
But, all spaces are replaced with plus signs ?
diagrams
add a comment |
How can I make number pattern like this
But, all spaces are replaced with plus signs ?
diagrams
1
Welcome to TeX.SE!
– Kurt
May 5 at 4:03
3
In the final row of your screenshot, should there be a space between10
and11
?
– Mico
May 5 at 4:12
add a comment |
How can I make number pattern like this
But, all spaces are replaced with plus signs ?
diagrams
How can I make number pattern like this
But, all spaces are replaced with plus signs ?
diagrams
diagrams
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 between10
and11
?
– Mico
May 5 at 4:12
add a comment |
1
Welcome to TeX.SE!
– Kurt
May 5 at 4:03
3
In the final row of your screenshot, should there be a space between10
and11
?
– 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
add a comment |
5 Answers
5
active
oldest
votes
Just for fun: without packages.
documentclassarticle
newcounterpft
newcounterpfft
begindocument
setcounterpft0loop%
stepcounterpft%
setcounterpfft0noindent$loop%
stepcounterpfftnumbervaluepfft%
ifnumnumbervaluepfft<numbervaluepft+repeat$par%
ifnumnumbervaluepft<11repeat%
enddocument
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
add a comment |
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
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
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
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
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.
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
|
show 1 more comment
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.
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.
% !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
add a comment |
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
add a comment |
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
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%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
Just for fun: without packages.
documentclassarticle
newcounterpft
newcounterpfft
begindocument
setcounterpft0loop%
stepcounterpft%
setcounterpfft0noindent$loop%
stepcounterpfftnumbervaluepfft%
ifnumnumbervaluepfft<numbervaluepft+repeat$par%
ifnumnumbervaluepft<11repeat%
enddocument
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
add a comment |
Just for fun: without packages.
documentclassarticle
newcounterpft
newcounterpfft
begindocument
setcounterpft0loop%
stepcounterpft%
setcounterpfft0noindent$loop%
stepcounterpfftnumbervaluepfft%
ifnumnumbervaluepfft<numbervaluepft+repeat$par%
ifnumnumbervaluepft<11repeat%
enddocument
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
add a comment |
Just for fun: without packages.
documentclassarticle
newcounterpft
newcounterpfft
begindocument
setcounterpft0loop%
stepcounterpft%
setcounterpfft0noindent$loop%
stepcounterpfftnumbervaluepfft%
ifnumnumbervaluepfft<numbervaluepft+repeat$par%
ifnumnumbervaluepft<11repeat%
enddocument
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
Just for fun: without packages.
documentclassarticle
newcounterpft
newcounterpfft
begindocument
setcounterpft0loop%
stepcounterpft%
setcounterpfft0noindent$loop%
stepcounterpfftnumbervaluepfft%
ifnumnumbervaluepfft<numbervaluepft+repeat$par%
ifnumnumbervaluepft<11repeat%
enddocument
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
edited May 8 at 21:20
answered May 5 at 3:58
marmotmarmot
127k6162308
127k6162308
add a comment |
add a comment |
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
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
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
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
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.
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
|
show 1 more comment
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
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
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
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
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.
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
|
show 1 more comment
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
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
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
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
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.
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
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
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
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
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.
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
|
show 1 more comment
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
|
show 1 more comment
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.
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.
% !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
add a comment |
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.
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.
% !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
add a comment |
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.
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.
% !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
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.
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.
% !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
edited May 5 at 10:05
answered May 5 at 4:07
MicoMico
291k32399788
291k32399788
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered May 5 at 6:15
Red-CloudRed-Cloud
2,30313
2,30313
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered May 5 at 13:23
egregegreg
742k8919423274
742k8919423274
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f489242%2fhow-to-replace-space-with-symbol-in-a-triangular-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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
and11
?– Mico
May 5 at 4:12