TeX - LaTeX Asked by Harley on July 30, 2021
This is actually not a question, but a solution. I looked everywhere and all of the solutions given are super complicated so I thought I would share my own for people who need help!!
I will post my code in the answer!!
In order to label a simple 3x3 matrix, you can either do it by columns/rows or give it a full title over the whole matrix.
This is the code for both the full titles and by each column/row:
begin{document}
begingroup
setlength{tabcolsep}{2pt} % sets spacing horizontally
renewcommand{arraystretch}{1} % sets spacing vertically
begin{tabular}{ c c c }
%===============================================================
%Row 1
%===============================================================
%Column 1
Top Title &
%Column 2
&
%Column 3
%===============================================================
%Row 2
%===============================================================
%Column 1
%this creates the horizontal array
begingroup %make sure to use this to control spacing separately from the bigger array
setlength{tabcolsep}{6pt}
begin{tabular}{cccc}
1 & 2 & 3
end{tabular}
endgroup&
%Column 2
&
%Column 3
%===============================================================
%Row 3
%===============================================================
% Column 1
$begin{bmatrix}
a & b & c
d & e & f
g & h & i
end{bmatrix}$ &
%Column 2
% this creates the vertical array
begin{tabular}{ccc}
x y z
end{tabular} &
%Column 3
Side Title
end{tabular}
endgroup
end{document}
From this code you can adjust what titles you would like to keep/erase. Remember to adjust the matrix size accordingly. Matrices/tables/arrays have a syntax of:
Row1Column1 & Row1Column2 & ... & Row1Column(N)
Row2Column1 & Row2Column2 & ... & Row2Column(N)
.
.
.
Row(N)Column1 & Row(N)Column2 & ... & Row(N)Column(N)
So this is essentially a 3x3 matrix with the first column being:
Second Column:
Third Column:
Answered by Harley on July 30, 2021
Welcome to TEX.SE! It's a nice approach. I use nicematrix
package to do this.
documentclass{article}
usepackage{amsmath}
usepackage{nicematrix}
begin{document}
begin{align*}
begin{array}{cc}
text{Top Title} &
begin{bNiceMatrix}[first-row,last-col]
1 & 2 & 3 &
a & b & c & x
d & e & f & y
g & h & i & z
end{bNiceMatrix} & text{Side Title}
end{array}
end{align*}
end{document}
Here I handled the matrix with exterior with bNiceMatrix
environment.
Answered by Syvshc on July 30, 2021
Here is another way to do that with nicematrix
. In the latest version (5.10 of 2021-02-05), there is a built-in command SubMatrix
which I used to add the brackets in the array previously constructed.
documentclass{article}
usepackage{nicematrix}
begin{document}
$A = enskip
begin{NiceMatrix}[baseline=4]
Block{1-3}{text{Top Title}}
1 & 2 & 3 &
a & b & c & x & Block{3-1}{text{Side Title}}
d & e & f & y
g & h & i & z
CodeAfter SubMatrix[{3-1}{5-3}]
end{NiceMatrix}$
end{document}
You need several compilations (because nicematrix
uses PGF/Tikz nodes).
Answered by F. Pantigny on July 30, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP