7

I am trying to reproduce something like this:enter image description here

So far, I have got the matrix with the lines from the following code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mleftright}

\begin{document}
\[
\renewcommand\arraystretch{1.3}
A_{ij} = \mleft[
\begin{array}{c|c|c|c|c}
     A_{c,\rho} & A_{c,u_r} & A_{c,u_{\theta}} & A_{c,u_z} & A_{c,T}     \\ \hline
     A_{r,\rho} & A_{r,u_r} & A_{r,u_{\theta}} & A_{r,u_z} & A_{r,T}    \\ \hline
     A_{\theta,\rho} & A_{\theta,u_r} & A_{\theta,u_{\theta}} & A_{\theta,u_z} & A_{u_{\theta},T}   \\ \hline
     A_{z,\rho} & A_{z,u_r} & A_{z,u_{\theta}} & A_{z,u_z} & A_{z,T}   \\ \hline
     A_{e,\rho} & A_{e,u_r} & A_{e,u_{\theta}} & A_{e,u_z} & A_{e,T}   
\end{array}
\mright]
\]

\end{document}

Now, how do I add the labels to rows and columns with arrows?

1

2 Answers 2

4

You can do it with blkarray. A couple of dummy columns are necessary for accommodating the horizontal rules.

\documentclass{article}
\usepackage{amsmath}
\usepackage{blkarray}

\begin{document}
\[
\renewcommand\arraystretch{1.3}
\begin{blockarray}{rcccccccc}
&&& u & v & w & \rho & T & \\
&&& \downarrow & \downarrow & \downarrow & \downarrow & \downarrow & \\
\begin{block}{rc[c@{}c|c|c|c|c@{}c]}
\text{Cont.}  & \to && A_{c,u} & A_{c,v} & A_{c,w} & A_{c,\rho} & A_{c,T} &\vphantom{\smash[b]{\bigg|}} \\
\BAhhline{~~~-----~}
x\text{-mom}  & \to && A_{r,\rho} & A_{r,u_r} & A_{r,u_{\theta}} & A_{r,u_z} & A_{r,T} & \\
\BAhhline{~~~-----~}
A_{ij}=\quad
y\text{-mom}  & \to && A_{\theta,\rho} & A_{\theta,u_r} & A_{\theta,u_{\theta}} & A_{\theta,u_z} & A_{u_{\theta},T} & \\
\BAhhline{~~~-----~}
z\text{-mom}  & \to && A_{z,\rho} & A_{z,u_r} & A_{z,u_{\theta}} & A_{z,u_z} & A_{z,T} & \\
\BAhhline{~~~-----~}
\text{energy} & \to && A_{e,\rho} & A_{e,u_r} & A_{e,u_{\theta}} & A_{e,u_z} & A_{e,T} & \vphantom{\smash[t]{\bigg|}}\\
\end{block}
\end{blockarray}
\]

\end{document}

The \vphantom trick is for getting slightly bigger brackets.

enter image description here

1

With {bNiceMatrix} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\newcommand {\xx} [1] 
  {
    \renewcommand{\arraystretch}{1}
    \begin{array}{c}
      #1 \\
      \downarrow 
    \end{array}
  }

\renewcommand{\arraystretch}{1.2}

$A_{ij} = 
\begin{bNiceMatrix}[hvlines,first-row,first-col,margin]
                    & \xx{u}  & \xx{v}  & \xx{w}  & \xx{\rho}  & \xx{T}  \\
\text{Cont}     \to & A_{c,u} & A_{c,v} & A_{c,w} & A_{c,\rho} & A_{c,T} \\
x - \text{mom.} \to & A_{x,u} & A_{x,v} & A_{x,w} & A_{x,\rho} & A_{x,T} \\
y - \text{mom.} \to & A_{y,u} & A_{y,v} & A_{y,w} & A_{y,\rho} & A_{y,T} \\
z - \text{mom.} \to & A_{z,u} & A_{z,v} & A_{z,w} & A_{z,\rho} & A_{z,T} \\
\text{energy}   \to & A_{e,u} & A_{e,v} & A_{e,w} & A_{e,\rho} & A_{e,T} \\
\end{bNiceMatrix}$

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