TeX - LaTeX Asked by user503842 on May 26, 2021
Say I have created a matrix. And now I want to label both the columns and the rows. However, I want to have labels on both sides of the matrix.
I have tried the following:
documentclass[a4paper12pt]{article}
usepackage{geometry}
usepackage{blkarray}
usepackage{amsmath}
usepackage{xcolor}
usepackage{graphicx}
begin{document}
[mathbf{Pairs} =
begin{blockarray}{cc}
Transmitter & Receiver
begin{block}{c(cc)c}
TX_1^C & (x,y) & (x,y) & BS
TX_2^C & (x,y) & (x,y) & BS
&vdots & vdots
TX_{max}^C & (x,y) & (x,y) & BS
BAhhline{......}
TX_1^D & (x,y) & (x,y) &RX_1^D
TX_2^D & (x,y) & (x,y) &RX_2^D
&vdots & vdots
TX_{ax}^D & (x,y) & (x,y) &RX_{max}^D
end{block}
end{blockarray}
]
end{document}
TeXstudio returns the error miscplaced noalign. end{block}
Anyone know why?
I think your example contain some mistakes:
is missing at end of last line before
end{block}
You say blockarray{cc}
but begin{block}{c(cc)c}, therefore it should be
blockarray{cccc}`.
Only one &
appears between Transmitter
and Receiver
, I think they should be three &&&
, but I'm not sure how you want to align these words.
documentclass[a4paper12pt]{article}
usepackage{geometry}
usepackage{blkarray}
usepackage{amsmath}
usepackage{xcolor}
usepackage{graphicx}
begin{document}
[mathbf{Pairs} =
begin{blockarray}{cccc}
Transmitter & && Receiver
begin{block}{c(cc)c}
TX_1^C & (x,y) & (x,y) & BS
TX_2^C & (x,y) & (x,y) & BS
&vdots & vdots
TX_{max}^C & (x,y) & (x,y) & BS
BAhhline{....}
TX_1^D & (x,y) & (x,y) &RX_1^D
TX_2^D & (x,y) & (x,y) &RX_2^D
&vdots & vdots
TX_{ax}^D & (x,y) & (x,y) &RX_{max}^D
end{block}
end{blockarray}
]
end{document}
Correct answer by Ignasi on May 26, 2021
You can do that with nicematrix
.
documentclass[a4paper,12pt]{article}
usepackage{geometry}
usepackage{amsmath}
usepackage{nicematrix}
begin{document}
[mathbf{Pairs} =
begin{NiceMatrix}[baseline=line-6,cell-space-limits=3pt]
text{emph{Transmitter}} & && text{emph{Receiver}}
TX_1^C & (x,y) & (x,y) & BS
TX_2^C & (x,y) & (x,y) & BS
&Vdots & Vdots
TX_{text{max}}^C & (x,y) & (x,y) & BS
hdottedline
TX_1^D & (x,y) & (x,y) &RX_1^D
TX_2^D & (x,y) & (x,y) &RX_2^D
&Vdots & Vdots
TX_{text{max}}^D & (x,y) & (x,y) &RX_{text{max}}^D
CodeAfter
SubMatrix({2-2}{arabic{iRow}-3})
end{NiceMatrix}
]
end{document}
You need several compilations (because nicematrix
uses PGF/Tikz nodes under the hood).
Answered by F. Pantigny on May 26, 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