3

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?

2 Answers 2

3

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}

enter image description here

1
  • that's exactly what I wanted. Thx so much, Ignasi!!!!
    – Luk
    Nov 10, 2018 at 17:21
1

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).

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .