Matrix with uneven element lengths Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Separating matrix elements by linesAutomatically find which nodes are closest, to aid drawing lines within a TikZ matrixMatrix with uneven element lengths with added rows/columnsLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?TikZ/ERD: node (=Entity) label on the insideTikZ: Drawing an arc from an intersection to an intersectionAdjusting edge alignment and positioning of fitted nodeLine up nested tikz enviroments or how to get rid of themAutomatically find which nodes are closest, to aid drawing lines within a TikZ matrix

Do working physicists consider Newtonian mechanics to be "falsified"?

Was credit for the black hole image misattributed?

Understanding this description of teleportation

Can a zero nonce be safely used with AES-GCM if the key is random and never used again?

Unable to start mainnet node docker container

I'm having difficulty getting my players to do stuff in a sandbox campaign

What's the purpose of writing one's academic bio in 3rd person?

What are the performance impacts of 'functional' Rust?

Who can trigger ship-wide alerts in Star Trek?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

How is simplicity better than precision and clarity in prose?

How to market an anarchic city as a tourism spot to people living in civilized areas?

If I can make up priors, why can't I make up posteriors?

Stopping real property loss from eroding embankment

Cold is to Refrigerator as warm is to?

When to stop saving and start investing?

How widely used is the term Treppenwitz? Is it something that most Germans know?

Stop battery usage [Ubuntu 18]

Is drag coefficient lowest at zero angle of attack?

How do I keep my slimes from escaping their pens?

Autumning in love

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Replacing HDD with SSD; what about non-APFS/APFS?

What do I do if technical issues prevent me from filing my return on time?



Matrix with uneven element lengths



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Separating matrix elements by linesAutomatically find which nodes are closest, to aid drawing lines within a TikZ matrixMatrix with uneven element lengths with added rows/columnsLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?TikZ/ERD: node (=Entity) label on the insideTikZ: Drawing an arc from an intersection to an intersectionAdjusting edge alignment and positioning of fitted nodeLine up nested tikz enviroments or how to get rid of themAutomatically find which nodes are closest, to aid drawing lines within a TikZ matrix










2















From the answer to this question



When editing the elements of the matrix to become uneven in length, the display of the matrix becomes disturbed. How can this be solved



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usepackagepgfplots
usetikzlibraryarrows, arrows.meta, positioning, calc, intersections, decorations.pathreplacing, decorations.pathmorphing, decorations.markings, shapes, shapes.misc, shapes.symbols, shapes.geometric, patterns, backgrounds, trees, shadows, fit,matrix
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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>)
foreach i in 1,...,6
draw ($(x-1-i.north west)+(-5pt,5pt)$) -- ($(x-5-i.south west)+(-5pt,-5pt)$);%vertical lines
foreach i in 1,...,5
draw ($(x-i-1.south west)+(-5pt,-5pt)$) -- ($(x-i-6.south east)+(5pt,-5pt)$);%horizontal lines
draw ($(x-1-1.north west)+(-5pt,5pt)$) -| ($(x-5-6.south east)+(5pt,-5pt)$);%upper and right borders
endtikzpicture
endframe
enddocument


enter image description here



enter image description here










share|improve this question






















  • marmot's code [tex.stackexchange.com/a/484608/31034] runs well for me.

    – ferahfeza
    22 hours ago












  • @ferahfezaWhenthe matrix elements are lengthy, they are displayed beyond borders

    – Hany
    21 hours ago











  • @ferahfezaPlease refer to this image when applying marmot`s code i.stack.imgur.com/aC1bQ.jpg

    – Hany
    21 hours ago












  • @Hany The border is not a feature of the matrix. It is added manually. In this case, you have to find another way to draw the borders.

    – JouleV
    18 hours ago











  • One can certainly add lines by fitting the nodes on both sides and drawing lines in the middle between these fits, see tex.stackexchange.com/a/443198/121799.

    – marmot
    17 hours ago















2















From the answer to this question



When editing the elements of the matrix to become uneven in length, the display of the matrix becomes disturbed. How can this be solved



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usepackagepgfplots
usetikzlibraryarrows, arrows.meta, positioning, calc, intersections, decorations.pathreplacing, decorations.pathmorphing, decorations.markings, shapes, shapes.misc, shapes.symbols, shapes.geometric, patterns, backgrounds, trees, shadows, fit,matrix
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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>)
foreach i in 1,...,6
draw ($(x-1-i.north west)+(-5pt,5pt)$) -- ($(x-5-i.south west)+(-5pt,-5pt)$);%vertical lines
foreach i in 1,...,5
draw ($(x-i-1.south west)+(-5pt,-5pt)$) -- ($(x-i-6.south east)+(5pt,-5pt)$);%horizontal lines
draw ($(x-1-1.north west)+(-5pt,5pt)$) -| ($(x-5-6.south east)+(5pt,-5pt)$);%upper and right borders
endtikzpicture
endframe
enddocument


enter image description here



enter image description here










share|improve this question






















  • marmot's code [tex.stackexchange.com/a/484608/31034] runs well for me.

    – ferahfeza
    22 hours ago












  • @ferahfezaWhenthe matrix elements are lengthy, they are displayed beyond borders

    – Hany
    21 hours ago











  • @ferahfezaPlease refer to this image when applying marmot`s code i.stack.imgur.com/aC1bQ.jpg

    – Hany
    21 hours ago












  • @Hany The border is not a feature of the matrix. It is added manually. In this case, you have to find another way to draw the borders.

    – JouleV
    18 hours ago











  • One can certainly add lines by fitting the nodes on both sides and drawing lines in the middle between these fits, see tex.stackexchange.com/a/443198/121799.

    – marmot
    17 hours ago













2












2








2


0






From the answer to this question



When editing the elements of the matrix to become uneven in length, the display of the matrix becomes disturbed. How can this be solved



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usepackagepgfplots
usetikzlibraryarrows, arrows.meta, positioning, calc, intersections, decorations.pathreplacing, decorations.pathmorphing, decorations.markings, shapes, shapes.misc, shapes.symbols, shapes.geometric, patterns, backgrounds, trees, shadows, fit,matrix
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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>)
foreach i in 1,...,6
draw ($(x-1-i.north west)+(-5pt,5pt)$) -- ($(x-5-i.south west)+(-5pt,-5pt)$);%vertical lines
foreach i in 1,...,5
draw ($(x-i-1.south west)+(-5pt,-5pt)$) -- ($(x-i-6.south east)+(5pt,-5pt)$);%horizontal lines
draw ($(x-1-1.north west)+(-5pt,5pt)$) -| ($(x-5-6.south east)+(5pt,-5pt)$);%upper and right borders
endtikzpicture
endframe
enddocument


enter image description here



enter image description here










share|improve this question














From the answer to this question



When editing the elements of the matrix to become uneven in length, the display of the matrix becomes disturbed. How can this be solved



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usepackagepgfplots
usetikzlibraryarrows, arrows.meta, positioning, calc, intersections, decorations.pathreplacing, decorations.pathmorphing, decorations.markings, shapes, shapes.misc, shapes.symbols, shapes.geometric, patterns, backgrounds, trees, shadows, fit,matrix
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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>)
foreach i in 1,...,6
draw ($(x-1-i.north west)+(-5pt,5pt)$) -- ($(x-5-i.south west)+(-5pt,-5pt)$);%vertical lines
foreach i in 1,...,5
draw ($(x-i-1.south west)+(-5pt,-5pt)$) -- ($(x-i-6.south east)+(5pt,-5pt)$);%horizontal lines
draw ($(x-1-1.north west)+(-5pt,5pt)$) -| ($(x-5-6.south east)+(5pt,-5pt)$);%upper and right borders
endtikzpicture
endframe
enddocument


enter image description here



enter image description here







tikz-pgf beamer tikz-matrix






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 22 hours ago









HanyHany

1,344417




1,344417












  • marmot's code [tex.stackexchange.com/a/484608/31034] runs well for me.

    – ferahfeza
    22 hours ago












  • @ferahfezaWhenthe matrix elements are lengthy, they are displayed beyond borders

    – Hany
    21 hours ago











  • @ferahfezaPlease refer to this image when applying marmot`s code i.stack.imgur.com/aC1bQ.jpg

    – Hany
    21 hours ago












  • @Hany The border is not a feature of the matrix. It is added manually. In this case, you have to find another way to draw the borders.

    – JouleV
    18 hours ago











  • One can certainly add lines by fitting the nodes on both sides and drawing lines in the middle between these fits, see tex.stackexchange.com/a/443198/121799.

    – marmot
    17 hours ago

















  • marmot's code [tex.stackexchange.com/a/484608/31034] runs well for me.

    – ferahfeza
    22 hours ago












  • @ferahfezaWhenthe matrix elements are lengthy, they are displayed beyond borders

    – Hany
    21 hours ago











  • @ferahfezaPlease refer to this image when applying marmot`s code i.stack.imgur.com/aC1bQ.jpg

    – Hany
    21 hours ago












  • @Hany The border is not a feature of the matrix. It is added manually. In this case, you have to find another way to draw the borders.

    – JouleV
    18 hours ago











  • One can certainly add lines by fitting the nodes on both sides and drawing lines in the middle between these fits, see tex.stackexchange.com/a/443198/121799.

    – marmot
    17 hours ago
















marmot's code [tex.stackexchange.com/a/484608/31034] runs well for me.

– ferahfeza
22 hours ago






marmot's code [tex.stackexchange.com/a/484608/31034] runs well for me.

– ferahfeza
22 hours ago














@ferahfezaWhenthe matrix elements are lengthy, they are displayed beyond borders

– Hany
21 hours ago





@ferahfezaWhenthe matrix elements are lengthy, they are displayed beyond borders

– Hany
21 hours ago













@ferahfezaPlease refer to this image when applying marmot`s code i.stack.imgur.com/aC1bQ.jpg

– Hany
21 hours ago






@ferahfezaPlease refer to this image when applying marmot`s code i.stack.imgur.com/aC1bQ.jpg

– Hany
21 hours ago














@Hany The border is not a feature of the matrix. It is added manually. In this case, you have to find another way to draw the borders.

– JouleV
18 hours ago





@Hany The border is not a feature of the matrix. It is added manually. In this case, you have to find another way to draw the borders.

– JouleV
18 hours ago













One can certainly add lines by fitting the nodes on both sides and drawing lines in the middle between these fits, see tex.stackexchange.com/a/443198/121799.

– marmot
17 hours ago





One can certainly add lines by fitting the nodes on both sides and drawing lines in the middle between these fits, see tex.stackexchange.com/a/443198/121799.

– marmot
17 hours ago










1 Answer
1






active

oldest

votes


















4














One can use the fit library to always draw the lines between the tallest/widest matrix entries. I added a style full matrix grid which can be used as



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


If you want to draw only a subset of vertical or horizontal lines, you can use the redefined vlines or hlines styles, which now also use fit.



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows,calc,fit,matrix
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-,
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,
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)
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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]; %

endtikzpicture
endframe
enddocument


enter image description here



P.S. The outer lines can be drawn with draw, too.






share|improve this answer


















  • 1





    @marmotThank you very much for your time and effort. I appreciate your answer very much

    – Hany
    17 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%2f484763%2fmatrix-with-uneven-element-lengths%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














One can use the fit library to always draw the lines between the tallest/widest matrix entries. I added a style full matrix grid which can be used as



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


If you want to draw only a subset of vertical or horizontal lines, you can use the redefined vlines or hlines styles, which now also use fit.



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows,calc,fit,matrix
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-,
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,
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)
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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]; %

endtikzpicture
endframe
enddocument


enter image description here



P.S. The outer lines can be drawn with draw, too.






share|improve this answer


















  • 1





    @marmotThank you very much for your time and effort. I appreciate your answer very much

    – Hany
    17 hours ago
















4














One can use the fit library to always draw the lines between the tallest/widest matrix entries. I added a style full matrix grid which can be used as



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


If you want to draw only a subset of vertical or horizontal lines, you can use the redefined vlines or hlines styles, which now also use fit.



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows,calc,fit,matrix
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-,
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,
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)
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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]; %

endtikzpicture
endframe
enddocument


enter image description here



P.S. The outer lines can be drawn with draw, too.






share|improve this answer


















  • 1





    @marmotThank you very much for your time and effort. I appreciate your answer very much

    – Hany
    17 hours ago














4












4








4







One can use the fit library to always draw the lines between the tallest/widest matrix entries. I added a style full matrix grid which can be used as



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


If you want to draw only a subset of vertical or horizontal lines, you can use the redefined vlines or hlines styles, which now also use fit.



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows,calc,fit,matrix
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-,
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,
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)
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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]; %

endtikzpicture
endframe
enddocument


enter image description here



P.S. The outer lines can be drawn with draw, too.






share|improve this answer













One can use the fit library to always draw the lines between the tallest/widest matrix entries. I added a style full matrix grid which can be used as



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


If you want to draw only a subset of vertical or horizontal lines, you can use the redefined vlines or hlines styles, which now also use fit.



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usetikzlibraryarrows,calc,fit,matrix
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-,
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,
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)
begindocument
beginframe[t,fragile]
frametitlematrix
begintikzpicture
matrix (x) [matrix of nodes, row sep=10pt, column sep=10pt] %
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\
10.3 & 26.1 & 15.718.918.9 & 14.0 & 17.8 & 33.8\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\
13.5 & 17.1 & 20.7 & 27.1 & 18.918.9 & 16.6\;
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]; %

endtikzpicture
endframe
enddocument


enter image description here



P.S. The outer lines can be drawn with draw, too.







share|improve this answer












share|improve this answer



share|improve this answer










answered 17 hours ago









marmotmarmot

118k6151284




118k6151284







  • 1





    @marmotThank you very much for your time and effort. I appreciate your answer very much

    – Hany
    17 hours ago













  • 1





    @marmotThank you very much for your time and effort. I appreciate your answer very much

    – Hany
    17 hours ago








1




1





@marmotThank you very much for your time and effort. I appreciate your answer very much

– Hany
17 hours ago






@marmotThank you very much for your time and effort. I appreciate your answer very much

– Hany
17 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%2f484763%2fmatrix-with-uneven-element-lengths%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







-beamer, tikz-matrix, tikz-pgf

Popular posts from this blog

Creating 100m^2 grid automatically using QGIS?Creating grid constrained within polygon in QGIS?Createing polygon layer from point data using QGIS?Creating vector grid using QGIS?Creating grid polygons from coordinates using R or PythonCreating grid from spatio temporal point data?Creating fields in attributes table using other layers using QGISCreate .shp vector grid in QGISQGIS Creating 4km point grid within polygonsCreate a vector grid over a raster layerVector Grid Creates just one grid

Nikolai Prilezhaev Bibliography References External links Navigation menuEarly Russian Organic Chemists and Their Legacy092774english translationRussian Biography

How to link a C library to an Assembly library on Mac with clangHow do you set, clear, and toggle a single bit?Find (and kill) process locking port 3000 on MacWho is listening on a given TCP port on Mac OS X?How to start PostgreSQL server on Mac OS X?Compile assembler in nasm on mac osHow do I install pip on macOS or OS X?AFNetworking 2.0 “_NSURLSessionTransferSizeUnknown” linking error on Mac OS X 10.8C++ code for testing the Collatz conjecture faster than hand-written assembly - why?How to link a NASM code and GCC in Mac OS X?How to run x86 .asm on macOS Sierra