将文本添加到矩阵行或列

将文本添加到矩阵行或列

矩阵中的单列和单行可以突出显示吗?想要添加一些文本和箭头来描述矩阵中的给定行,例如:

在此处输入图片描述

上述矩阵的乳胶代码:

\begin{gather*}
\begin{bmatrix}
  1 & 2 & 3 \\ 1 & 2 & 3
\end{bmatrix}
*
\begin{bmatrix}
  1 & 2 & 3 \\ 1 & 2 & 3
\end{bmatrix}
\end{gather*}

答案1

这非常简单tikz

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}
\tikzset{%
    myarrow/.style = {-Stealth, shorten >=5pt}
} 
\newcommand{\mypoint}[2]{\tikz[remember picture]{\node[inner sep=0, anchor=base](#1){$#2$};}}

\begin{document}
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
    \begin{gather*}
    \begin{bmatrix}
    1 & 2 & 3 \\ \mypoint{here1}{1} & 2 & 3
    \end{bmatrix}
    *
    \begin{bmatrix}
    1 & 2 & \mypoint{here2}{3} \\ 1 & 2 & 3
    \end{bmatrix}
    \end{gather*}
    \begin{tikzpicture}[remember picture, overlay]
      \node[below=30pt of here1](textofhere1){some text};
      \draw[myarrow] (textofhere1) -- (here1);
      \node[right=30pt of here2](textofhere2){some other text};
      \draw[myarrow] (textofhere2) -- (here2);
    \end{tikzpicture}
    \vspace{7ex}

    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{document}

在此处输入图片描述

答案2

pstricks

\documentclass[11pt, svgnames]{article}
\usepackage{amsmath}
\usepackage{pst-node}
\usepackage{auto-pst-pdf} %% to compile with pdflatex --enable-write18 (MiKTeX) or pdflatex -shell-escape (TeXLive, MacTeX)

\begin{document}

\[ \begin{pspicture}
    \begin{bmatrix}
      1 & 2 & 3 \\ \rnode{B}{1} & 2 & 3
    \end{bmatrix}
    *
    \begin{bmatrix}
      1 & 2 & \rnode{T}{3} \\ 1 & 2 & 3
    \end{bmatrix}
    \psset{labelsep = 2em, nodesepA = 0.3ex, nodesepB = 0.8ex, arrows = ->, arrowinset = 0.12, linewidth = 0.6pt, linecolor = Tomato}
    \everypsbox{\color{Tomato}}
    \uput[r](T){\rnode{T1}{\text{Text1}}}\ncline{T1}{T}
    \uput[d](B){\rnode{T2}{\text{Text2}}}\ncline{T2}{B}
  \end{pspicture} \]

\end{document} 

(如果不想使用 进行编译pdflatex,请删除 的加载auto-pst-pdf

在此处输入图片描述

答案3

如果可以将箭头放在矩阵上方,则可以(滥用)使用包gmatrix中的环境gauss来放置它们。显示了制作箭头的两种可能性。

沒有\vspace必須。

代码输出

\documentclass{article}
\usepackage{amsmath,gauss,tikz}
% modify some things in gmatrix environments
\renewcommand\rowmultlabel{}
\renewcommand\colmultlabel{}
\setlength\rowarrowsep{0pt}
\setlength\rowopminsize{0pt}
\begin{document}
Some text text text text and so on.
\begin{equation*}
\begin{gmatrix}[b]
  1 & 2 & 3 \\
  1 & 2 & 3
\colops
\mult{0}{\begin{array}{c}\text{text 1}\\\downarrow\end{array}}
\end{gmatrix}
\!*
\begin{gmatrix}[b]
  1 & 2 & 3 \\
  1 & 2 & 3
\rowops
\mult{0}{\leftarrow\text{text 2}}
\end{gmatrix}
\end{equation*}
More text text text text text and so on.
\begin{equation*}
\begin{gmatrix}[b]
  1 & 2 & 3 \\
  1 & 2 & 3
\colops
\mult{0}{\tikz\draw[<-](0,0)--(0,5mm)node[above]{text 1};}
\end{gmatrix}
\!*
\begin{gmatrix}[b]
  1 & 2 & 3 \\
  1 & 2 & 3
\rowops
\mult{0}{\tikz[baseline=(a.base)]\draw[<-](0,0)--(5mm,0)node[name=a,right]{text 2};}
\end{gmatrix}
\end{equation*}
\end{document}

相关内容