如何將箭頭放置在矩陣的頂部和右側

如何將箭頭放置在矩陣的頂部和右側

我正在嘗試創建一個如下所示的矩陣

在此輸入影像描述

但我想要左箭頭是在矩陣的右側

因為我想在左側顯示矩陣的名稱。

這是我所擁有的:

\[
M =\begin{bmatrix} 
f(1,1) & f(1,2) & \dots \\
f(2,1) & f(2,2) & \dots  \\
\vdots & \vdots & \vdots 
\end{bmatrix}
\]

我不知道之後該如何繼續。有人有建議嗎?

答案1

我稍微修改了土撥鼠的解決方案以避免使用tikzmark.

我還使用了Triangle箭頭提示和其他小改動。

如果您尚未更新您的發行版,我的解決方案也適用。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary[arrows.meta]

\begin{document}
\[
M =\tikz[remember picture, baseline=(mat.center)]{\node[inner sep=0](mat){$\begin{bmatrix} 
f(1,1) & f(1,2) & \dots \\
f(2,1) & f(2,2) & \dots  \\
f(3,1) & f(3,2) & \dots  \\
\vdots & \vdots & \ddots \\
 & &  \\
\end{bmatrix}$};}
\begin{tikzpicture}[overlay,remember picture,
>=Triangle]
\draw[blue,thick,->] node[anchor=south west] (nn1) at (mat.north west)
{$n$ columns} (nn1.east) -- (nn1-|mat.north east) 
node[midway,above,black]{$i$ changes};
\draw[red,thick,->] node[anchor=north west,align=center, inner xsep=0pt] (nn2) at 
(mat.north east)
{$m$\\ rows} (nn2.south) -- (nn2.south|-mat.south) 
node[midway,above,black,rotate=-90]{$j$ changes};
\end{tikzpicture}
\]
\end{document}

在此輸入影像描述

答案2

有了tikzmark它就很簡單了。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[
M =\hspace*{1.5cm}\tikzmarknode{mat}{\begin{bmatrix} 
f(1,1) & f(1,2) & \dots \\
f(2,1) & f(2,2) & \dots  \\
f(3,1) & f(3,2) & \dots  \\
\vdots & \vdots & \ddots \\
 & &  \\
\end{bmatrix}}
\begin{tikzpicture}[overlay,remember picture]
\draw[blue,thick,-latex] node[anchor=south west] (nn1) at (mat.north west)
{$n$ columns} (nn1.east) -- (nn1-|mat.north east) 
node[midway,above,black]{$i$ changes};
\draw[red,thick,-latex] node[anchor=north east,align=center] (nn2) at (mat.north west)
{$m$\\ rows} (nn2.south) -- (nn2.south|-mat.south west) 
node[midway,above,black,rotate=90]{$j$ changes};
\end{tikzpicture}
\]
\end{document}

在此輸入影像描述

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[
M =\tikzmarknode{mat}{\begin{bmatrix} 
f(1,1) & f(1,2) & \dots \\
f(2,1) & f(2,2) & \dots  \\
f(3,1) & f(3,2) & \dots  \\
\vdots & \vdots & \ddots \\
 & &  \\
\end{bmatrix}}
\begin{tikzpicture}[overlay,remember picture]
\draw[blue,thick,-latex] node[anchor=south west] (nn1) at (mat.north west)
{$n$ columns} (nn1.east) -- (nn1-|mat.north east) 
node[midway,above,black]{$i$ changes};
\draw[red,thick,-latex] node[anchor=north west,align=center] (nn2) at 
(mat.north east)
{$m$\\ rows} (nn2.south) -- (nn2.south|-mat.south) 
node[midway,above,black,rotate=90]{$j$ changes};
\end{tikzpicture}
\]
\end{document}

在此輸入影像描述

相關內容