添加 Overbrace 来描述矩阵的一列

添加 Overbrace 来描述矩阵的一列

我想向矩阵添加一些大括号以获得以下输出:

在此处输入图片描述

然而,这是我设法得到的:

在此处输入图片描述

我不知道如何获取神经元 1 和神经元 2 的标题...我考虑过使用过度括号,但不确定在这种情况下如何使用它。矩阵右侧的内容未正确对齐...我的方程编号也移动到了下一行...有人能帮帮我吗?

我的代码如下(我正在使用 amsmath 包):

    \begin{equation}

    \begin{matrix}
     J
     =
     \begin{bmatrix}
     \frac{\delta e_{1,1}}{\delta w_{1,1}}  & \frac{\delta e_{1,1}}{\delta w_{1,2}} &
     \cdots & \frac{\delta e_{1,1}}{\delta w_{j,1}}  & \cdots \\[0.5em]

     \frac{\delta e_{1,2}}{\delta w_{1,1}}  & \frac{\delta e_{1,2}}{\delta w_{1,2}} & 
     \cdots & \frac{\delta e_{1,2}}{\delta w_{j,1}}  & \cdots \\[0.5em]

     \cdots & \cdots & \cdots &
     \cdots & \cdots \\[0.5em]

     \frac{\delta e_{1,M}}{\delta w_{1,1}}  & \frac{\delta e_{1,M}}{\delta w_{1,2}} & 
     \cdots & \frac{\delta e_{1,M}}{\delta w_{j,1}}  & \cdots \\[0.5em]

     \cdots & \cdots & \cdots &
     \cdots & \cdots \\[0.5em]

     \frac{\delta e_{P,1}}{\delta w_{1,1}}  & \frac{\delta e_{P,1}}{\delta w_{1,2}} & 
     \cdots & \frac{\delta e_{P,1}}{\delta w_{j,1}}  & \cdots \\[0.5em]

     \frac{\delta e_{P,1}}{\delta w_{1,1}}  & \frac{\delta e_{np,2}}{\delta w_{1,2}} &
     \cdots & \frac{\delta e_{P,2}}{\delta w_{j,1}}  & \cdots \\[0.5em]

     \cdots & \cdots & \cdots &
     \cdots & \cdots \\[0.5em]

      \frac{\delta e_{P,M}}{\delta w_{1,1}}  & \frac{\delta e_{P,M}}{\delta w_{1,2}} & 
      \cdots & \frac{\delta e_{P,M}}{\delta w_{j,1}}  & \cdots \\[0.5em]
      \end{bmatrix} %\!\! 
      \begin{aligned}
      &\left.\begin{matrix}
      m = 1  \\[0.5em]
      m = 2  \\[0.5em]
      \cdots \\[0.5em]
      m = M  \\[0.5em]
      \end{matrix} \right\} %
      p = 1\\
      &\begin{matrix}
      \phantom{\cdots}\cdots\\[0.5em]
      \end{matrix}\\ %
      &\left.\begin{matrix}
      m = 1  \\[0.5em]
      m = 2  \\[0.5em]
      \cdots \\[0.5em]
      m = M\\[0.5em]
      \end{matrix}\right\}%
      p = P\\
     \end{aligned}
     \end{matrix}
     \end{equation}

答案1

这里有一个(不使用 TikZ 的)可能性;\overmat将其第一个参数写在第二个参数所包含的条目上方;\bovermat(在下面的第二个示例中)操作类似,但显示过度括号。我还使用一些幻像修复了表达式向右对齐的问题:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\newcommand\overmat[2]{%
  \makebox[0pt][l]{$\smash{\color{white}\overbrace{\phantom{%
    \begin{matrix}#2\end{matrix}}}^{\text{\color{black}#1}}}$}#2}
\newcommand\partialphantom{\vphantom{\frac{\partial e_{P,M}}{\partial w_{1,1}}}}

\begin{document}

\begin{equation}
\begin{matrix}
 J
 =
 \begin{bmatrix}
 \overmat{neuron 1}{\frac{\partial e_{1,1}}{\partial w_{1,1}}  & \frac{\partial e_{1,1}}{\partial w_{1,2}}} &
 \overmat{$\mkern-3.5mu\cdots$}{\cdots} & \overmat{neuron $j$}{\frac{\partial e_{1,1}}{\partial w_{j,1}} & \frac{\partial e_{1,1}}{\partial w_{j,1}}} & \cdots \\[0.5em]
%
 \frac{\partial e_{1,2}}{\partial w_{1,1}}  & \frac{\partial e_{1,2}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{1,2}}{\partial w_{j,1}}  & \cdots \\[0.5em]
%
 \cdots & \cdots & \cdots &
 \cdots & \cdots \\[0.5em]
%
 \frac{\partial e_{1,M}}{\partial w_{1,1}}  & \frac{\partial e_{1,M}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{1,M}}{\partial w_{j,1}}  & \cdots \\[0.5em]
%
 \cdots & \cdots & \cdots &
 \cdots & \cdots \\[0.5em]
%
 \frac{\partial e_{P,1}}{\partial w_{1,1}}  & \frac{\partial e_{P,1}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{P,1}}{\partial w_{j,1}}  & \cdots \\[0.5em]
%
 \frac{\partial e_{P,1}}{\partial w_{1,1}}  & \frac{\partial e_{np,2}}{\partial w_{1,2}} &
 \cdots & \frac{\partial e_{P,2}}{\partial w_{j,1}}  & \cdots \\[0.5em]
%
 \cdots & \cdots & \cdots &
 \cdots & \cdots \\[0.5em]
%
  \frac{\partial e_{P,M}}{\partial w_{1,1}}  & \frac{\partial e_{P,M}}{\partial w_{1,2}} & 
  \cdots & \frac{\partial e_{P,M}}{\partial w_{j,1}}  & \cdots \\[0.5em]
  \end{bmatrix}
  \begin{aligned}
  &\left.\begin{matrix}
  \partialphantom m = 1  \\[0.5em]
  \partialphantom m = 2  \\[0.5em]
  \cdots \\[0.5em]
  \partialphantom m = M  \\[0.5em]
  \end{matrix} \right\} %
  p = 1\\
  &\begin{matrix}
  \\[-1.67em]\phantom{\cdots}\cdots
  \end{matrix}\\ %
  &\left.\begin{matrix}
  \partialphantom m = 1  \\[0.5em]
  \partialphantom m = 2  \\[0.5em]
  \cdots \\[0.5em]
  \partialphantom m = M\\[0.5em]
  \end{matrix}\right\}%
  p = P\\
 \end{aligned}
 \end{matrix}
 \end{equation}

\end{document}

在此处输入图片描述

还有带括号的变体:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\newcommand\overmat[2]{%
  \makebox[0pt][l]{$\smash{\color{white}\overbrace{\phantom{%
    \begin{matrix}#2\end{matrix}}}^{\text{\color{black}#1}}}$}#2}
\newcommand\bovermat[2]{%
  \makebox[0pt][l]{$\smash{\overbrace{\phantom{%
    \begin{matrix}#2\end{matrix}}}^{\text{#1}}}$}#2}
\newcommand\partialphantom{\vphantom{\frac{\partial e_{P,M}}{\partial w_{1,1}}}}

\begin{document}

\begin{equation}
\begin{matrix}
 J
 =
 \begin{bmatrix}
 \bovermat{neuron 1}{\frac{\partial e_{1,1}}{\partial w_{1,1}}  & \frac{\partial e_{1,1}}{\partial w_{1,2}}} &
 \overmat{$\mkern-3.5mu\cdots$}{\cdots} & \bovermat{neuron $j$}{\frac{\partial e_{1,1}}{\partial w_{j,1}} & \frac{\partial e_{1,1}}{\partial w_{j,1}}} & \cdots \\[0.5em]
%
 \frac{\partial e_{1,2}}{\partial w_{1,1}}  & \frac{\partial e_{1,2}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{1,2}}{\partial w_{j,1}}  & \cdots \\[0.5em]
%
 \cdots & \cdots & \cdots &
 \cdots & \cdots \\[0.5em]
%
 \frac{\partial e_{1,M}}{\partial w_{1,1}}  & \frac{\partial e_{1,M}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{1,M}}{\partial w_{j,1}}  & \cdots \\[0.5em]
%
 \cdots & \cdots & \cdots &
 \cdots & \cdots \\[0.5em]
%
 \frac{\partial e_{P,1}}{\partial w_{1,1}}  & \frac{\partial e_{P,1}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{P,1}}{\partial w_{j,1}}  & \cdots \\[0.5em]
%
 \frac{\partial e_{P,1}}{\partial w_{1,1}}  & \frac{\partial e_{np,2}}{\partial w_{1,2}} &
 \cdots & \frac{\partial e_{P,2}}{\partial w_{j,1}}  & \cdots \\[0.5em]
%
 \cdots & \cdots & \cdots &
 \cdots & \cdots \\[0.5em]
%
  \frac{\partial e_{P,M}}{\partial w_{1,1}}  & \frac{\partial e_{P,M}}{\partial w_{1,2}} & 
  \cdots & \frac{\partial e_{P,M}}{\partial w_{j,1}}  & \cdots \\[0.5em]
  \end{bmatrix}
  \begin{aligned}
  &\left.\begin{matrix}
  \partialphantom m = 1  \\[0.5em]
  \partialphantom m = 2  \\[0.5em]
  \cdots \\[0.5em]
  \partialphantom m = M  \\[0.5em]
  \end{matrix} \right\} %
  p = 1\\
  &\begin{matrix}
  \\[-1.67em]\phantom{\cdots}\cdots
  \end{matrix}\\ %
  &\left.\begin{matrix}
  \partialphantom m = 1  \\[0.5em]
  \partialphantom m = 2  \\[0.5em]
  \cdots \\[0.5em]
  \partialphantom m = M\\[0.5em]
  \end{matrix}\right\}%
  p = P\\
 \end{aligned}
 \end{matrix}
 \end{equation}

\end{document}

在此处输入图片描述

答案2

这是一个解决方案{NiceMatrix}nicematrix您需要多次编译)。

\documentclass{article}
\usepackage{nicematrix}

\begin{document}


\[
 J
 =
 \begin{NiceMatrix}[margin,cell-space-limits=3pt,first-row]
\Block{1-2}{\text{neuron } 1} & & \cdots & \Block{1-2}{\text{neuron } j} \\
 \frac{\partial e_{1,1}}{\partial w_{1,1}}  & \frac{\partial e_{1,1}}{\partial w_{1,2}} &
 & \frac{\partial e_{1,1}}{\partial w_{j,1}} & \frac{\partial e_{1,1}}{\partial w_{j,1}} & \cdots  & m=1 &
 \Block{4-1}{p=1} \\
%
 \frac{\partial e_{1,2}}{\partial w_{1,1}}  & \frac{\partial e_{1,2}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{1,2}}{\partial w_{j,1}}  & \cdots & & m=2\\
%
 \cdots & \cdots & & \cdots &
 \cdots & & \cdots \\
%
 \frac{\partial e_{1,M}}{\partial w_{1,1}}  & \frac{\partial e_{1,M}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{1,M}}{\partial w_{j,1}}  & \cdots & & m=M\\
%
 \cdots & \cdots & \cdots &
 \cdots & \cdots & & \cdots \\
%
 \frac{\partial e_{P,1}}{\partial w_{1,1}}  & \frac{\partial e_{P,1}}{\partial w_{1,2}} & 
 \cdots & \frac{\partial e_{P,1}}{\partial w_{j,1}}  & \cdots & & m=1 & \Block{4-1}{p=P}\\
%
 \frac{\partial e_{P,1}}{\partial w_{1,1}}  & \frac{\partial e_{np,2}}{\partial w_{1,2}} &
 \cdots & \frac{\partial e_{P,2}}{\partial w_{j,1}}  & \cdots & & m=2\\
%
 \cdots & \cdots & \cdots &
 \cdots & \cdots & & \cdots \\
%
  \frac{\partial e_{P,M}}{\partial w_{1,1}}  & \frac{\partial e_{P,M}}{\partial w_{1,2}} & 
  \cdots & \frac{\partial e_{P,M}}{\partial w_{j,1}}  & \cdots & & m = M\\
\CodeAfter
  \SubMatrix[{1-1}{9-6}]
  \SubMatrix{.}{1-7}{4-7}{\}}
  \SubMatrix{.}{6-7}{9-7}{\}}
\end{NiceMatrix}\]

\end{document}

上述代码的输出

答案3

我没有使用你的矩阵,但我认为我的例子会对我们的社区有所帮助。

\documentclass{article}
\usepackage{amsmath}

\[
\begin{array}{| c | c | c | c | c | c | c | c | c | c |}
\multicolumn{3}{c}{\rho_1 } &
\multicolumn{3}{c}{\rho_2} &
\multicolumn{1}{c}{ \ }   & 
\multicolumn{3}{c}{\rho_k} \\
%
\multicolumn{3}{c}{\overbrace{\rule{4cm}{0pt}}} &
\multicolumn{3}{c}{\overbrace{\rule{4cm}{0pt}}} &
\multicolumn{1}{c}{ \ }   & 
\multicolumn{3}{c}{\overbrace{\rule{4cm}{0pt}}} \\[-3pt]
\hline
p(t_1) & \cdots & p^{(\rho_1-1)}(t_1) & p(t_2) & \cdots & 
p^{(\rho_2-1)}(t_2) & \cdots  & p(t_k) & \cdots & 
p^{(\rho_k-1)}(t_k) \\
\hline
\end{array}
\] 

\end{document}

结果: 在此处输入图片描述

相关内容