# How to place an arrow on top and to the right of a matrix

by AL B   Last Updated March 14, 2019 20:23 PM - source

I am trying to create a matrix like this

but I want the left arrow to be on the right side of the image because I want to have the name of the matrix on the left side. Here is what I have:

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


I am not sure how to proceed after that. Anyone has any suggestions?

Tags :

With tikzmark it is straightforward.

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


marmot
March 14, 2019 20:19 PM