生成列向量在右边、行向量在底部的矩阵

生成列向量在右边、行向量在底部的矩阵

我需要这个;

需要这个

但是在尝试了 TeX.SE 上提供的答复后,我只能做到这一点;

设法得到这个

获取此代码的代码如下

\begin{equation}\label{eqn:designRule}
\begin{split}
&{\textrm{\rotatebox[origin=c]{90}{$M$ Rules}}
    \stackrel{\mbox{$N$ Vars}}{%
        \begin{bmatrix}
        a_{11} & a_{12} & \cdots & a_{1N} \\
        a_{21} & a_{22} & \cdots & a_{2N} \\
        \vdots & \vdots & \ddots & \vdots \\
        a_{M1} & a_{M2} & \cdots & a_{MN}
        \end{bmatrix}%
    }
    %  
    \stackrel{G}{%
        \begin{matrix}
        g_1 \\
        g_2 \\
        \vdots \\
        g_M
        \end{matrix}%
    }}\\
    &{C     
        \begin{matrix}
        \quad\;\;c_{1} &\quad c_{2} &\; \cdots &\;\; c_{N}
        \end{matrix}%
    }
    \end{split}
\end{equation}

答案1

更简单,对于简单的某些定义来说。

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{blkarray}
\usepackage{lipsum} % just for the example

\begin{document}
\lipsum*[2]
\[
\begin{blockarray}{ccccc|c}
\smash{\makebox(0,0){\rotatebox{90}{$M$ Rules\hspace{6em}}}}
& \BAmulticolumn{4}{c|}{N \text{ Vars}} & G \\
\begin{block}{c[cccc]|[c]}
 & a_{11} & a_{12} & \dots & a_{1N} & g_1 \\
 & a_{21} & a_{22} & \dots & a_{2N} & g_2 \\
 & \vdots & \vdots & \ddots & \vdots & \vdots \\
 & a_{M1} & a_{M2} & \dots & a_{MN} & g_N \\
\BAhline
\end{block}
\begin{block}{c[cccc]|c}
C & c_1 & c_2 & \dots & c_N \\
\end{block}
\end{blockarray}
\]
\lipsum[3]

\end{document}

在此处输入图片描述

答案2

这里有一个使用 tikzmatrix库的解决方案

代码

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}

\begin{document}

\begin{equation}
\begin{tikzpicture}[baseline=(current bounding box.center)]
\matrix(M) [matrix of math nodes,left delimiter={[},right delimiter={]},nodes={minimum width=1cm}]
{
a_{11} & a_{12} & \cdots  & a_{1N}      \\
a_{21} & a_{22} & \cdots  & a_{2N}      \\
\vdots & \vdots & \ddots  & \vdots      \\
a_{M1} & a_{M2} & \cdots  & a_{MN}      \\
};
\matrix(L)at (M.east) [anchor=west,xshift=1cm,matrix of math nodes,left delimiter={[},right delimiter={]}]
{
  g_1    \\
  g_2    \\
  \vdots \\
  g_M    \\
};
\matrix(K)at (M.south) [anchor=north,yshift=-5mm,matrix of math nodes,nodes={minimum width=1cm},left delimiter={[},right delimiter={]}]
{
  c_{1} &  c_{2} & \cdots &  c_{N} \\
};
\node [rotate=90,yshift=5mm]at (M.west) {M Rules};
\node [xshift=-5mm]at (K.west) {$C$};
\node [yshift=5mm]at  (M.north) {N Vars};
\node [yshift=5mm]at (L.north) {$G$};
\draw ($(M.north east)!0.5!(L.north west)+(0,8mm)$)--($(M.south east)!0.5!(L.south west)+(0,-8mm)$);
\draw ($(M.south west)!0.5!(K.north west)+(-8mm,0)$)--($(M.south east)!0.5!(K.north east)+(2.5cm,0)$);
\end{tikzpicture}
\end{equation}

\end{document}

输出

出去

答案3

这是一个使用环境(无 TikZ)的解决方案array

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath,graphicx,array}
\begin{document}
\begin{equation}\label{eqn:designRule}
\renewcommand\arraystretch{1.33}
\begin{array}{@{}c@{\hspace{\arraycolsep}}c|c@{}}
 & \text{$N$ Vars} & G \\[0.5ex]
\rotatebox[origin=c]{90}{$M$ Rules} &
        \begin{bmatrix}
        a_{11} & a_{12} & \dots & a_{1N} \\
        a_{21} & a_{22} & \dots & a_{2N} \\
        \vdots & \vdots & \ddots& \vdots \\
        a_{M1} & a_{M2} & \dots & a_{MN}
        \end{bmatrix} 
    &
        \begin{matrix}
        g_1 \\
        g_2 \\
        \vdots \\
        g_M
        \end{matrix}\\
\hline     
C  & \begin{matrix}
        \quad c_{1} &\quad c_{2} & \,\cdots &\;\; c_{N}\\ 
     \end{matrix} &
\end{array}
\end{equation}
\end{document}

相关内容