Matrix with uneven element lengths with added rows/columns Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Matrix with uneven element lengthsTikZ matrix decorationDefine tikz node based on pagenodesTikZ/ERD: node (=Entity) label on the insideHow to draw inside a TikZ node using node style with arguments?Adjusting 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 lengths

Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?

3 doors, three guards, one stone

What does the "x" in "x86" represent?

Did Xerox really develop the first LAN?

Is the Standard Deduction better than Itemized when both are the same amount?

Compressing georeferenced images

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]

What makes black pepper strong or mild?

Why there are no cargo aircraft with "flying wing" design?

IndentationError when pasting code in Python 3 interpreter mode

Do you forfeit tax refunds/credits if you aren't required to and don't file by April 15?

What happens to sewage if there is no river near by?

What are 'alternative tunings' of a guitar and why would you use them? Doesn't it make it more difficult to play?

Should gear shift center itself while in neutral?

How do I keep my slimes from escaping their pens?

How can players work together to take actions that are otherwise impossible?

Does polymorph use a PC’s CR or its level?

How to deal with a team lead who never gives me credit?

How to motivate offshore teams and trust them to deliver?

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

How can I make names more distinctive without making them longer?

Does surprise arrest existing movement?

macOS-like app switching in Plasma 5

Why does Python start at index 1 when iterating an array backwards?



Matrix with uneven element lengths with added rows/columns



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Matrix with uneven element lengthsTikZ matrix decorationDefine tikz node based on pagenodesTikZ/ERD: node (=Entity) label on the insideHow to draw inside a TikZ node using node style with arguments?Adjusting 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 lengths










3















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=node[fit=MatLstA,inner sep=0pt] (fitA)
node[fit=MatLstB,inner sep=0pt] (fitB)
($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
(pgfkeysvalueof/tikz/matrix name.north-,%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.

    – JouleV
    17 hours ago











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

    – Hany
    17 hours ago











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

    – Hany
    17 hours ago











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

    – JouleV
    17 hours ago











  • @JouleV When I leave a space after the name, sometimes the name does not appear in the comment!

    – Hany
    17 hours ago
















3















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=node[fit=MatLstA,inner sep=0pt] (fitA)
node[fit=MatLstB,inner sep=0pt] (fitB)
($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
(pgfkeysvalueof/tikz/matrix name.north-,%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.

    – JouleV
    17 hours ago











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

    – Hany
    17 hours ago











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

    – Hany
    17 hours ago











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

    – JouleV
    17 hours ago











  • @JouleV When I leave a space after the name, sometimes the name does not appear in the comment!

    – Hany
    17 hours ago














3












3








3








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=node[fit=MatLstA,inner sep=0pt] (fitA)
node[fit=MatLstB,inner sep=0pt] (fitB)
($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
(pgfkeysvalueof/tikz/matrix name.north-,%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=node[fit=MatLstA,inner sep=0pt] (fitA)
node[fit=MatLstB,inner sep=0pt] (fitB)
($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
(pgfkeysvalueof/tikz/matrix name.north-,%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 5 hours ago









JouleV

13.7k22664




13.7k22664










asked 17 hours ago









HanyHany

1,359417




1,359417












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

    – JouleV
    17 hours ago











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

    – Hany
    17 hours ago











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

    – Hany
    17 hours ago











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

    – JouleV
    17 hours ago











  • @JouleV When I leave a space after the name, sometimes the name does not appear in the comment!

    – Hany
    17 hours ago


















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

    – JouleV
    17 hours ago











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

    – Hany
    17 hours ago











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

    – Hany
    17 hours ago











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

    – JouleV
    17 hours ago











  • @JouleV When I leave a space after the name, sometimes the name does not appear in the comment!

    – Hany
    17 hours ago

















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

– JouleV
17 hours ago





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

– JouleV
17 hours ago













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

– Hany
17 hours ago





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

– Hany
17 hours ago













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

– Hany
17 hours ago





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

– Hany
17 hours ago













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

– JouleV
17 hours ago





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

– JouleV
17 hours ago













@JouleV When I leave a space after the name, sometimes the name does not appear in the comment!

– Hany
17 hours ago






@JouleV When I leave a space after the name, sometimes the name does not appear in the comment!

– Hany
17 hours ago











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=node[fit=MatLstA,inner sep=0pt] (fitA)
node[fit=MatLstB,inner sep=0pt] (fitB)
($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
(pgfkeysvalueof/tikz/matrix name.north-,%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=7,matrix rows=6,full matrix grid];% drawing the borders
endtikzpicture
endframe
enddocument





share|improve this answer






























    4














    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) -- (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
    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
      16 hours ago












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

      – JouleV
      5 hours ago











    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%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=node[fit=MatLstA,inner sep=0pt] (fitA)
    node[fit=MatLstB,inner sep=0pt] (fitB)
    ($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
    (pgfkeysvalueof/tikz/matrix name.north-,%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=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=node[fit=MatLstA,inner sep=0pt] (fitA)
      node[fit=MatLstB,inner sep=0pt] (fitB)
      ($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
      (pgfkeysvalueof/tikz/matrix name.north-,%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=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=node[fit=MatLstA,inner sep=0pt] (fitA)
        node[fit=MatLstB,inner sep=0pt] (fitB)
        ($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
        (pgfkeysvalueof/tikz/matrix name.north-,%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=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=node[fit=MatLstA,inner sep=0pt] (fitA)
        node[fit=MatLstB,inner sep=0pt] (fitB)
        ($(fitA.east)!0.5!(fitB.west)$) coordinate (aux)
        (pgfkeysvalueof/tikz/matrix name.north-,%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=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 17 hours ago









        AndrewAndrew

        31k34482




        31k34482





















            4














            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) -- (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
            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
              16 hours ago












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

              – JouleV
              5 hours ago















            4














            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) -- (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
            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
              16 hours ago












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

              – JouleV
              5 hours ago













            4












            4








            4







            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) -- (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
            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) -- (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
            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 16 hours ago

























            answered 16 hours ago









            JouleVJouleV

            13.7k22664




            13.7k22664












            • 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
              16 hours ago












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

              – JouleV
              5 hours ago

















            • 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
              16 hours ago












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

              – JouleV
              5 hours ago
















            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
            16 hours ago






            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
            16 hours ago














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

            – JouleV
            5 hours ago





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

            – JouleV
            5 hours ago

















            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







            -tikz-matrix, tikz-pgf

            Popular posts from this blog

            Frič See also Navigation menuinternal link

            Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant

            fontconfig warning: “/etc/fonts/fonts.conf”, line 100: unknown “element blank” The 2019 Stack Overflow Developer Survey Results Are In“tar: unrecognized option --warning” during 'apt-get install'How to fix Fontconfig errorHow do I figure out which font file is chosen for a system generic font alias?Why are some apt-get-installed fonts being ignored by fc-list, xfontsel, etc?Reload settings in /etc/fonts/conf.dTaking 30 seconds longer to boot after upgrade from jessie to stretchHow to match multiple font names with a single <match> element?Adding a custom font to fontconfigRemoving fonts from fontconfig <match> resultsBroken fonts after upgrading Firefox ESR to latest Firefox