Matrix with uneven element lengths with added rows/columnsMatrix with uneven element lengthsSummation of matrix elements / table cellsDefine tikz node based on pagenodesTikZ matrix, style for combination or rows and columnsTikZ/ERD: node (=Entity) label on the insideAdjusting edge alignment and positioning of fitted nodeTikZ graphs: Specify edge target anchorabsolute position of tikzpicture in beamerAutomatically find which nodes are closest, to aid drawing lines within a TikZ matrixThe scope of a node nameMatrix with uneven element lengthsSelecting columns and rows in a matrix

Does a large scratch in an ND filter affect image quality?

Permutations in Disguise

Unable to find solution to 6 simultaneous equations

Why is it called a stateful and a stateless firewall?

What does "boys rule, girls drool" mean?

Why don't Wizards use wrist straps to protect against disarming charms?

Access parent controller attribute from Visual force component

What 68-pin connector is this on my 2.5" solid state drive?

Can I travel to European countries with the Irish passport and without destination Visa?

Is "you will become a subject matter expert" code for "you'll be working on your own 100% of the time"?

Is the Dodge action perceptible to other characters?

Ambiguity in notation resolved by +

What is a "major country" as named in Bernie Sanders' Healthcare debate answers?

geschafft or geschaffen? which one is past participle of schaffen?

Why is the car dealer insisting on a loan instead of cash?

Is there a tool to measure the "maturity" of a code in Git?

Examples of proofs by making reduction to a finite set

Output a Super Mario Image

Is it possible to determine the index of a bip32 address?

Make 2019 with single digits

How to control the output voltage of a solid state relay

Asked to Not Use Transactions and to Use A Workaround to Simulate One

Difference between system uptime and last boot time in windows

Does my opponent need to prove his creature has morph?



Matrix with uneven element lengths with added rows/columns


Matrix with uneven element lengthsSummation of matrix elements / table cellsDefine tikz node based on pagenodesTikZ matrix, style for combination or rows and columnsTikZ/ERD: node (=Entity) label on the insideAdjusting edge alignment and positioning of fitted nodeTikZ graphs: Specify edge target anchorabsolute position of tikzpicture in beamerAutomatically find which nodes are closest, to aid drawing lines within a TikZ matrixThe scope of a node nameMatrix with uneven element lengthsSelecting columns and rows in a matrix






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















From the answer to this question



Using the following code



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows, calc, fit, matrix
begindocument
tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
fi,
insert path=aux) -- (pgfkeysvalueof/tikz/matrix name.south-,%end vline
hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
fi,insert path=-aux),%end hline
full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

beginframe[t,fragile]
frametitle
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
xx & xx & xx & xx & xx & xx & y\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
% Node names: (<name of matrix>-<row>-<column>)
% draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
% (pgfkeysvalueof/tikz/matrix name.south east); %
draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];% drawing the borders
endtikzpicture
endframe
enddocument


When new rows/columns are added, no lines are drawn between the new and previous ones. How can this be fixed?



I tried re-adjusting



matrix rows/.initial=5,matrix cols/.initial=6


to



matrix rows/.initial=0,matrix cols/.initial=0


or to



matrix rows/.initial=10,matrix cols/.initial=10


but it did not work.



From the answers I got, the problem was not on this line; the problem was that I did not re-adjust the line



draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];



to



draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];



enter image description hereenter image description here










share|improve this question


























  • You have to understand the code in the preamble. If you already understand, it will not be difficult.

    – user156344
    Apr 15 at 4:57











  • @AndrewAs I said, I tried this, but it did not work

    – Hany
    Apr 15 at 4:57











  • @JouleVMy programming knowledge is limited. Please if you have a solution to this problem tell me

    – Hany
    Apr 15 at 4:59











  • Off topic: if you want to ping people, you must write e.g. @Andrew As ... instead of @AndrewAs ....

    – user156344
    Apr 15 at 5:01






  • 1





    Look at my answer and Andrew's answer. In short, you changed the initial values of matrix rows, matrix cols, but you reset these values later in your command, that is why it does not work.

    – user156344
    Apr 15 at 5:15

















2















From the answer to this question



Using the following code



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows, calc, fit, matrix
begindocument
tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
fi,
insert path=aux) -- (pgfkeysvalueof/tikz/matrix name.south-,%end vline
hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
fi,insert path=-aux),%end hline
full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

beginframe[t,fragile]
frametitle
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
xx & xx & xx & xx & xx & xx & y\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
% Node names: (<name of matrix>-<row>-<column>)
% draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
% (pgfkeysvalueof/tikz/matrix name.south east); %
draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];% drawing the borders
endtikzpicture
endframe
enddocument


When new rows/columns are added, no lines are drawn between the new and previous ones. How can this be fixed?



I tried re-adjusting



matrix rows/.initial=5,matrix cols/.initial=6


to



matrix rows/.initial=0,matrix cols/.initial=0


or to



matrix rows/.initial=10,matrix cols/.initial=10


but it did not work.



From the answers I got, the problem was not on this line; the problem was that I did not re-adjust the line



draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];



to



draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];



enter image description hereenter image description here










share|improve this question


























  • You have to understand the code in the preamble. If you already understand, it will not be difficult.

    – user156344
    Apr 15 at 4:57











  • @AndrewAs I said, I tried this, but it did not work

    – Hany
    Apr 15 at 4:57











  • @JouleVMy programming knowledge is limited. Please if you have a solution to this problem tell me

    – Hany
    Apr 15 at 4:59











  • Off topic: if you want to ping people, you must write e.g. @Andrew As ... instead of @AndrewAs ....

    – user156344
    Apr 15 at 5:01






  • 1





    Look at my answer and Andrew's answer. In short, you changed the initial values of matrix rows, matrix cols, but you reset these values later in your command, that is why it does not work.

    – user156344
    Apr 15 at 5:15













2












2








2








From the answer to this question



Using the following code



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows, calc, fit, matrix
begindocument
tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
fi,
insert path=aux) -- (pgfkeysvalueof/tikz/matrix name.south-,%end vline
hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
fi,insert path=-aux),%end hline
full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

beginframe[t,fragile]
frametitle
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
xx & xx & xx & xx & xx & xx & y\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
% Node names: (<name of matrix>-<row>-<column>)
% draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
% (pgfkeysvalueof/tikz/matrix name.south east); %
draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];% drawing the borders
endtikzpicture
endframe
enddocument


When new rows/columns are added, no lines are drawn between the new and previous ones. How can this be fixed?



I tried re-adjusting



matrix rows/.initial=5,matrix cols/.initial=6


to



matrix rows/.initial=0,matrix cols/.initial=0


or to



matrix rows/.initial=10,matrix cols/.initial=10


but it did not work.



From the answers I got, the problem was not on this line; the problem was that I did not re-adjust the line



draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];



to



draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];



enter image description hereenter image description here










share|improve this question
















From the answer to this question



Using the following code



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows, calc, fit, matrix
begindocument
tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
fi,
insert path=aux) -- (pgfkeysvalueof/tikz/matrix name.south-,%end vline
hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
fi,insert path=-aux),%end hline
full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

beginframe[t,fragile]
frametitle
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
xx & xx & xx & xx & xx & xx & y\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
% Node names: (<name of matrix>-<row>-<column>)
% draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
% (pgfkeysvalueof/tikz/matrix name.south east); %
draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];% drawing the borders
endtikzpicture
endframe
enddocument


When new rows/columns are added, no lines are drawn between the new and previous ones. How can this be fixed?



I tried re-adjusting



matrix rows/.initial=5,matrix cols/.initial=6


to



matrix rows/.initial=0,matrix cols/.initial=0


or to



matrix rows/.initial=10,matrix cols/.initial=10


but it did not work.



From the answers I got, the problem was not on this line; the problem was that I did not re-adjust the line



draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];



to



draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];



enter image description hereenter image description here







tikz-pgf tikz-matrix






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 15 at 16:07







user156344

















asked Apr 15 at 4:27









HanyHany

1,3925 silver badges18 bronze badges




1,3925 silver badges18 bronze badges















  • You have to understand the code in the preamble. If you already understand, it will not be difficult.

    – user156344
    Apr 15 at 4:57











  • @AndrewAs I said, I tried this, but it did not work

    – Hany
    Apr 15 at 4:57











  • @JouleVMy programming knowledge is limited. Please if you have a solution to this problem tell me

    – Hany
    Apr 15 at 4:59











  • Off topic: if you want to ping people, you must write e.g. @Andrew As ... instead of @AndrewAs ....

    – user156344
    Apr 15 at 5:01






  • 1





    Look at my answer and Andrew's answer. In short, you changed the initial values of matrix rows, matrix cols, but you reset these values later in your command, that is why it does not work.

    – user156344
    Apr 15 at 5:15

















  • You have to understand the code in the preamble. If you already understand, it will not be difficult.

    – user156344
    Apr 15 at 4:57











  • @AndrewAs I said, I tried this, but it did not work

    – Hany
    Apr 15 at 4:57











  • @JouleVMy programming knowledge is limited. Please if you have a solution to this problem tell me

    – Hany
    Apr 15 at 4:59











  • Off topic: if you want to ping people, you must write e.g. @Andrew As ... instead of @AndrewAs ....

    – user156344
    Apr 15 at 5:01






  • 1





    Look at my answer and Andrew's answer. In short, you changed the initial values of matrix rows, matrix cols, but you reset these values later in your command, that is why it does not work.

    – user156344
    Apr 15 at 5:15
















You have to understand the code in the preamble. If you already understand, it will not be difficult.

– user156344
Apr 15 at 4:57





You have to understand the code in the preamble. If you already understand, it will not be difficult.

– user156344
Apr 15 at 4:57













@AndrewAs I said, I tried this, but it did not work

– Hany
Apr 15 at 4:57





@AndrewAs I said, I tried this, but it did not work

– Hany
Apr 15 at 4:57













@JouleVMy programming knowledge is limited. Please if you have a solution to this problem tell me

– Hany
Apr 15 at 4:59





@JouleVMy programming knowledge is limited. Please if you have a solution to this problem tell me

– Hany
Apr 15 at 4:59













Off topic: if you want to ping people, you must write e.g. @Andrew As ... instead of @AndrewAs ....

– user156344
Apr 15 at 5:01





Off topic: if you want to ping people, you must write e.g. @Andrew As ... instead of @AndrewAs ....

– user156344
Apr 15 at 5:01




1




1





Look at my answer and Andrew's answer. In short, you changed the initial values of matrix rows, matrix cols, but you reset these values later in your command, that is why it does not work.

– user156344
Apr 15 at 5:15





Look at my answer and Andrew's answer. In short, you changed the initial values of matrix rows, matrix cols, but you reset these values later in your command, that is why it does not work.

– user156344
Apr 15 at 5:15










2 Answers
2






active

oldest

votes


















4
















You need to change the line:



draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


to



draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];


All that this line is doing is drawing a grid with the specified number of rows and columns. In this case, this produces:



enter image description here



Here is the full code:



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows, calc, fit, matrix
begindocument
tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
fi,
insert path=aux),%end vline
hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
ifnumXX=1
xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
else
xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
fi,insert path=node[fit=MatLstA,inner sep=0pt] (fitA)
node[fit=MatLstB,inner sep=0pt] (fitB)
($(fitA.south)!0.5!(fitB.north)$) coordinate (aux)
(pgfkeysvalueof/tikz/matrix name.west,%end hline
full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

beginframe[t,fragile]
frametitle
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
xx & xx & xx & xx & xx & xx & y\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
% Node names: (<name of matrix>-<row>-<column>)
% draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
% (pgfkeysvalueof/tikz/matrix name.south east); %
draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];% drawing the borders
endtikzpicture
endframe
enddocument





share|improve this answer
































    3
















    Andrew has pointed out the right thing. Now let me dig into it. This is the tikzset, aligned (in my favorite way)



    tikzset
    matrix rows/.initial=5,
    matrix cols/.initial=6,
    matrix name/.initial=x,
    vline/.style=
    /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
    ifnumXX=1
    xdefMatLstA
    (pgfkeysvalueof/tikz/matrix name-XX-#1)
    xdefMatLstB
    (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
    else
    xdefMatLstA
    MatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
    xdefMatLstB
    MatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
    fi,
    insert path=aux)
    ,%end vline
    hline/.style=
    /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
    ifnumXX=1
    xdefMatLstA
    (pgfkeysvalueof/tikz/matrix name-#1-XX)
    xdefMatLstB
    (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
    else
    xdefMatLstA
    MatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
    xdefMatLstB
    MatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
    fi,
    insert path=-aux)
    ,%end hline
    full matrix grid/.style=
    vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
    hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
    insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)




    Without any knowledge in advance, I think we can still understand vline style will add vertical lines in a given list, and hline for horizontal lines.



    Now, look at full matrix grid:



    full matrix grid/.style=
    vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
    hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
    insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)



    It outputs a set of hlines and vlines, in a given list. The list is controled by matrix cols and matrix rows (thenumexprpgfkeysvalueof/tikz/matrix cols-1, etc.), so you have to change the values of these options to change the grid.



    The initial value of matrix rows and matrix cols are 5 and 6, but that doesn't matter, because you already reset it again in the command



    draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


    Now, change the value of matrix cols and matrix rows in the above command, you will get what you want.



    For the sake of completeness, see the compilable code in Andrew's answer.






    share|improve this answer



























    • Thank you all very much, I got it. and it works fine. By the way, I put @JouleV with a space after it, before Thank you, and it did not show

      – Hany
      Apr 15 at 5:22












    • @Hany It is off topic here, but you can find out more how @ in comments work by reading this question.

      – user156344
      Apr 15 at 16:12











    • Thank you @JouleV

      – Hany
      Apr 16 at 2:48













    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/4.0/"u003ecc by-sa 4.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%2f484879%2fmatrix-with-uneven-element-lengths-with-added-rows-columns%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4
















    You need to change the line:



    draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


    to



    draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];


    All that this line is doing is drawing a grid with the specified number of rows and columns. In this case, this produces:



    enter image description here



    Here is the full code:



    documentclassbeamer
    beamertemplatenavigationsymbolsempty
    usepackageverbatim
    usepackagetikz
    usetikzlibraryarrows, calc, fit, matrix
    begindocument
    tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
    vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
    ifnumXX=1
    xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
    xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
    else
    xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
    xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
    fi,
    insert path=aux),%end vline
    hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
    ifnumXX=1
    xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
    xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
    else
    xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
    xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
    fi,insert path=node[fit=MatLstA,inner sep=0pt] (fitA)
    node[fit=MatLstB,inner sep=0pt] (fitB)
    ($(fitA.south)!0.5!(fitB.north)$) coordinate (aux)
    (pgfkeysvalueof/tikz/matrix name.west,%end hline
    full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
    hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
    insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

    beginframe[t,fragile]
    frametitle
    begintikzpicture
    matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
    15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
    17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
    10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
    23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
    xx & xx & xx & xx & xx & xx & y\
    13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
    draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
    % Node names: (<name of matrix>-<row>-<column>)
    % draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
    % (pgfkeysvalueof/tikz/matrix name.south east); %
    draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];% drawing the borders
    endtikzpicture
    endframe
    enddocument





    share|improve this answer





























      4
















      You need to change the line:



      draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


      to



      draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];


      All that this line is doing is drawing a grid with the specified number of rows and columns. In this case, this produces:



      enter image description here



      Here is the full code:



      documentclassbeamer
      beamertemplatenavigationsymbolsempty
      usepackageverbatim
      usepackagetikz
      usetikzlibraryarrows, calc, fit, matrix
      begindocument
      tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
      vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
      ifnumXX=1
      xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
      xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
      else
      xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
      xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
      fi,
      insert path=aux),%end vline
      hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
      ifnumXX=1
      xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
      xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
      else
      xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
      xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
      fi,insert path=node[fit=MatLstA,inner sep=0pt] (fitA)
      node[fit=MatLstB,inner sep=0pt] (fitB)
      ($(fitA.south)!0.5!(fitB.north)$) coordinate (aux)
      (pgfkeysvalueof/tikz/matrix name.west,%end hline
      full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
      hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
      insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

      beginframe[t,fragile]
      frametitle
      begintikzpicture
      matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
      15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
      17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
      10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
      23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
      xx & xx & xx & xx & xx & xx & y\
      13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
      draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
      % Node names: (<name of matrix>-<row>-<column>)
      % draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
      % (pgfkeysvalueof/tikz/matrix name.south east); %
      draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];% drawing the borders
      endtikzpicture
      endframe
      enddocument





      share|improve this answer



























        4














        4










        4









        You need to change the line:



        draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


        to



        draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];


        All that this line is doing is drawing a grid with the specified number of rows and columns. In this case, this produces:



        enter image description here



        Here is the full code:



        documentclassbeamer
        beamertemplatenavigationsymbolsempty
        usepackageverbatim
        usepackagetikz
        usetikzlibraryarrows, calc, fit, matrix
        begindocument
        tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
        vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
        ifnumXX=1
        xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
        xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
        else
        xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
        xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
        fi,
        insert path=aux),%end vline
        hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
        ifnumXX=1
        xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
        xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
        else
        xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
        xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
        fi,insert path=node[fit=MatLstA,inner sep=0pt] (fitA)
        node[fit=MatLstB,inner sep=0pt] (fitB)
        ($(fitA.south)!0.5!(fitB.north)$) coordinate (aux)
        (pgfkeysvalueof/tikz/matrix name.west,%end hline
        full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
        hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
        insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

        beginframe[t,fragile]
        frametitle
        begintikzpicture
        matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
        15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
        17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
        10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
        23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
        xx & xx & xx & xx & xx & xx & y\
        13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
        draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
        % Node names: (<name of matrix>-<row>-<column>)
        % draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
        % (pgfkeysvalueof/tikz/matrix name.south east); %
        draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];% drawing the borders
        endtikzpicture
        endframe
        enddocument





        share|improve this answer













        You need to change the line:



        draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


        to



        draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];


        All that this line is doing is drawing a grid with the specified number of rows and columns. In this case, this produces:



        enter image description here



        Here is the full code:



        documentclassbeamer
        beamertemplatenavigationsymbolsempty
        usepackageverbatim
        usepackagetikz
        usetikzlibraryarrows, calc, fit, matrix
        begindocument
        tikzsetmatrix rows/.initial=5,matrix cols/.initial=6,matrix name/.initial=x,
        vline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
        ifnumXX=1
        xdefMatLstA(pgfkeysvalueof/tikz/matrix name-XX-#1)
        xdefMatLstB(pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
        else
        xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
        xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
        fi,
        insert path=aux),%end vline
        hline/.style=/utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
        ifnumXX=1
        xdefMatLstA(pgfkeysvalueof/tikz/matrix name-#1-XX)
        xdefMatLstB(pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
        else
        xdefMatLstAMatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
        xdefMatLstBMatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
        fi,insert path=node[fit=MatLstA,inner sep=0pt] (fitA)
        node[fit=MatLstB,inner sep=0pt] (fitB)
        ($(fitA.south)!0.5!(fitB.north)$) coordinate (aux)
        (pgfkeysvalueof/tikz/matrix name.west,%end hline
        full matrix grid/.style=vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
        hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
        insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)

        beginframe[t,fragile]
        frametitle
        begintikzpicture
        matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
        15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0 & y\
        17.4 & 18.6 & 12.9 & 20.320.320.3 & 13.7 & 21.45 & y\
        10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8 & y\
        23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8 & y\
        xx & xx & xx & xx & xx & xx & y\
        13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6 & y\;
        draw<2->[ultra thick, blue, latex'-] (x-2-1) node [fill, red!40!white, circle, inner sep=8pt, opacity=.4] -- (x-4-5) node [fill, blue!40!white, circle, inner sep=8pt, opacity=.4];
        % Node names: (<name of matrix>-<row>-<column>)
        % draw[vline/.list=1,...,5,hline/.list=1,...,4] (pgfkeysvalueof/tikz/matrix name.north west) rectangle
        % (pgfkeysvalueof/tikz/matrix name.south east); %
        draw[matrix name=x,matrix cols=7,matrix rows=6,full matrix grid];% drawing the borders
        endtikzpicture
        endframe
        enddocument






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 15 at 4:59









        AndrewAndrew

        34.2k3 gold badges50 silver badges88 bronze badges




        34.2k3 gold badges50 silver badges88 bronze badges


























            3
















            Andrew has pointed out the right thing. Now let me dig into it. This is the tikzset, aligned (in my favorite way)



            tikzset
            matrix rows/.initial=5,
            matrix cols/.initial=6,
            matrix name/.initial=x,
            vline/.style=
            /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
            ifnumXX=1
            xdefMatLstA
            (pgfkeysvalueof/tikz/matrix name-XX-#1)
            xdefMatLstB
            (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
            else
            xdefMatLstA
            MatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
            xdefMatLstB
            MatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
            fi,
            insert path=aux)
            ,%end vline
            hline/.style=
            /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
            ifnumXX=1
            xdefMatLstA
            (pgfkeysvalueof/tikz/matrix name-#1-XX)
            xdefMatLstB
            (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
            else
            xdefMatLstA
            MatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
            xdefMatLstB
            MatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
            fi,
            insert path=-aux)
            ,%end hline
            full matrix grid/.style=
            vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
            hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
            insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)




            Without any knowledge in advance, I think we can still understand vline style will add vertical lines in a given list, and hline for horizontal lines.



            Now, look at full matrix grid:



            full matrix grid/.style=
            vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
            hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
            insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)



            It outputs a set of hlines and vlines, in a given list. The list is controled by matrix cols and matrix rows (thenumexprpgfkeysvalueof/tikz/matrix cols-1, etc.), so you have to change the values of these options to change the grid.



            The initial value of matrix rows and matrix cols are 5 and 6, but that doesn't matter, because you already reset it again in the command



            draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


            Now, change the value of matrix cols and matrix rows in the above command, you will get what you want.



            For the sake of completeness, see the compilable code in Andrew's answer.






            share|improve this answer



























            • Thank you all very much, I got it. and it works fine. By the way, I put @JouleV with a space after it, before Thank you, and it did not show

              – Hany
              Apr 15 at 5:22












            • @Hany It is off topic here, but you can find out more how @ in comments work by reading this question.

              – user156344
              Apr 15 at 16:12











            • Thank you @JouleV

              – Hany
              Apr 16 at 2:48















            3
















            Andrew has pointed out the right thing. Now let me dig into it. This is the tikzset, aligned (in my favorite way)



            tikzset
            matrix rows/.initial=5,
            matrix cols/.initial=6,
            matrix name/.initial=x,
            vline/.style=
            /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
            ifnumXX=1
            xdefMatLstA
            (pgfkeysvalueof/tikz/matrix name-XX-#1)
            xdefMatLstB
            (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
            else
            xdefMatLstA
            MatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
            xdefMatLstB
            MatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
            fi,
            insert path=aux)
            ,%end vline
            hline/.style=
            /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
            ifnumXX=1
            xdefMatLstA
            (pgfkeysvalueof/tikz/matrix name-#1-XX)
            xdefMatLstB
            (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
            else
            xdefMatLstA
            MatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
            xdefMatLstB
            MatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
            fi,
            insert path=-aux)
            ,%end hline
            full matrix grid/.style=
            vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
            hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
            insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)




            Without any knowledge in advance, I think we can still understand vline style will add vertical lines in a given list, and hline for horizontal lines.



            Now, look at full matrix grid:



            full matrix grid/.style=
            vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
            hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
            insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)



            It outputs a set of hlines and vlines, in a given list. The list is controled by matrix cols and matrix rows (thenumexprpgfkeysvalueof/tikz/matrix cols-1, etc.), so you have to change the values of these options to change the grid.



            The initial value of matrix rows and matrix cols are 5 and 6, but that doesn't matter, because you already reset it again in the command



            draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


            Now, change the value of matrix cols and matrix rows in the above command, you will get what you want.



            For the sake of completeness, see the compilable code in Andrew's answer.






            share|improve this answer



























            • Thank you all very much, I got it. and it works fine. By the way, I put @JouleV with a space after it, before Thank you, and it did not show

              – Hany
              Apr 15 at 5:22












            • @Hany It is off topic here, but you can find out more how @ in comments work by reading this question.

              – user156344
              Apr 15 at 16:12











            • Thank you @JouleV

              – Hany
              Apr 16 at 2:48













            3














            3










            3









            Andrew has pointed out the right thing. Now let me dig into it. This is the tikzset, aligned (in my favorite way)



            tikzset
            matrix rows/.initial=5,
            matrix cols/.initial=6,
            matrix name/.initial=x,
            vline/.style=
            /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
            ifnumXX=1
            xdefMatLstA
            (pgfkeysvalueof/tikz/matrix name-XX-#1)
            xdefMatLstB
            (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
            else
            xdefMatLstA
            MatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
            xdefMatLstB
            MatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
            fi,
            insert path=aux)
            ,%end vline
            hline/.style=
            /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
            ifnumXX=1
            xdefMatLstA
            (pgfkeysvalueof/tikz/matrix name-#1-XX)
            xdefMatLstB
            (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
            else
            xdefMatLstA
            MatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
            xdefMatLstB
            MatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
            fi,
            insert path=-aux)
            ,%end hline
            full matrix grid/.style=
            vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
            hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
            insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)




            Without any knowledge in advance, I think we can still understand vline style will add vertical lines in a given list, and hline for horizontal lines.



            Now, look at full matrix grid:



            full matrix grid/.style=
            vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
            hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
            insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)



            It outputs a set of hlines and vlines, in a given list. The list is controled by matrix cols and matrix rows (thenumexprpgfkeysvalueof/tikz/matrix cols-1, etc.), so you have to change the values of these options to change the grid.



            The initial value of matrix rows and matrix cols are 5 and 6, but that doesn't matter, because you already reset it again in the command



            draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


            Now, change the value of matrix cols and matrix rows in the above command, you will get what you want.



            For the sake of completeness, see the compilable code in Andrew's answer.






            share|improve this answer















            Andrew has pointed out the right thing. Now let me dig into it. This is the tikzset, aligned (in my favorite way)



            tikzset
            matrix rows/.initial=5,
            matrix cols/.initial=6,
            matrix name/.initial=x,
            vline/.style=
            /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix rows
            ifnumXX=1
            xdefMatLstA
            (pgfkeysvalueof/tikz/matrix name-XX-#1)
            xdefMatLstB
            (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
            else
            xdefMatLstA
            MatLstA (pgfkeysvalueof/tikz/matrix name-XX-#1)
            xdefMatLstB
            MatLstB (pgfkeysvalueof/tikz/matrix name-XX-thenumexpr1+#1relax)
            fi,
            insert path=aux)
            ,%end vline
            hline/.style=
            /utils/exec=foreach XX in 1,...,pgfkeysvalueof/tikz/matrix cols
            ifnumXX=1
            xdefMatLstA
            (pgfkeysvalueof/tikz/matrix name-#1-XX)
            xdefMatLstB
            (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
            else
            xdefMatLstA
            MatLstA (pgfkeysvalueof/tikz/matrix name-#1-XX)
            xdefMatLstB
            MatLstB (pgfkeysvalueof/tikz/matrix name-thenumexpr1+#1relax-XX)
            fi,
            insert path=-aux)
            ,%end hline
            full matrix grid/.style=
            vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
            hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
            insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)




            Without any knowledge in advance, I think we can still understand vline style will add vertical lines in a given list, and hline for horizontal lines.



            Now, look at full matrix grid:



            full matrix grid/.style=
            vline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix cols-1,
            hline/.list=1,...,thenumexprpgfkeysvalueof/tikz/matrix rows-1,
            insert path=(pgfkeysvalueof/tikz/matrix name.south west) rectangle (pgfkeysvalueof/tikz/matrix name.north east)



            It outputs a set of hlines and vlines, in a given list. The list is controled by matrix cols and matrix rows (thenumexprpgfkeysvalueof/tikz/matrix cols-1, etc.), so you have to change the values of these options to change the grid.



            The initial value of matrix rows and matrix cols are 5 and 6, but that doesn't matter, because you already reset it again in the command



            draw[matrix name=x,matrix cols=6,matrix rows=5,full matrix grid];


            Now, change the value of matrix cols and matrix rows in the above command, you will get what you want.



            For the sake of completeness, see the compilable code in Andrew's answer.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 15 at 5:12

























            answered Apr 15 at 5:06







            user156344






















            • Thank you all very much, I got it. and it works fine. By the way, I put @JouleV with a space after it, before Thank you, and it did not show

              – Hany
              Apr 15 at 5:22












            • @Hany It is off topic here, but you can find out more how @ in comments work by reading this question.

              – user156344
              Apr 15 at 16:12











            • Thank you @JouleV

              – Hany
              Apr 16 at 2:48

















            • Thank you all very much, I got it. and it works fine. By the way, I put @JouleV with a space after it, before Thank you, and it did not show

              – Hany
              Apr 15 at 5:22












            • @Hany It is off topic here, but you can find out more how @ in comments work by reading this question.

              – user156344
              Apr 15 at 16:12











            • Thank you @JouleV

              – Hany
              Apr 16 at 2:48
















            Thank you all very much, I got it. and it works fine. By the way, I put @JouleV with a space after it, before Thank you, and it did not show

            – Hany
            Apr 15 at 5:22






            Thank you all very much, I got it. and it works fine. By the way, I put @JouleV with a space after it, before Thank you, and it did not show

            – Hany
            Apr 15 at 5:22














            @Hany It is off topic here, but you can find out more how @ in comments work by reading this question.

            – user156344
            Apr 15 at 16:12





            @Hany It is off topic here, but you can find out more how @ in comments work by reading this question.

            – user156344
            Apr 15 at 16:12













            Thank you @JouleV

            – Hany
            Apr 16 at 2:48





            Thank you @JouleV

            – Hany
            Apr 16 at 2:48


















            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%2f484879%2fmatrix-with-uneven-element-lengths-with-added-rows-columns%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

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?