# Latex: How to write single cross arrow in a 2x2 matrix?

Is there a way to make a version of the diagram provided above?

Thank you very much.

I'm adapting my answer to "How to add arrow in equations and matrix?"; see there for some explanations on how to draw arrows between text elements.

• First, typeset the text without arrows.
• Wrap all elements, that will be the origin or target of an arrow, into a \tikznode command. This assigns a name to the text element and stores its size and position.
• Add a tikzpicture environment with the options remember picture,overlay below. It contains the graphical elements, in this case the arrows. Here you will use the names assigned in the previous step.
• Run LaTeX at least two times to propagate the information about the nodes and arrows everywhere.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}% only needed for the arrow tip stealth'
\newcommand\tikznode[3][]{%
\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
\begin{document}
\tikznode{-x}{$-x$} & \tikznode{1}{$1$} \\[2ex]
\tikznode{2x}{$2x$} & \tikznode{3}{$3$} \\
\cline{2-2}
& $-x$
\end{tabular}
\begin{tikzpicture}[remember picture,overlay,> = stealth',shorten <= 4pt,shorten > = 4pt]
\draw[->] (-x.east) -- (3.west);
\draw[->] (2x.east) -- (1.west);
\end{tikzpicture}
\end{document}


Here is a solution with {NiceArray} of nicematrix.

That environment is similar to the classical environment {array} (of array) but creates PGF nodes under the cells of the array. Then, it's possible to use Tikz to draw the required arrows.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}

\begin{document}

$\begin{NiceArray}{r@{\qquad}r} -x & 1 \\[2ex] 2x & 3 \\ \cline{2} & -x \CodeAfter \begin{tikzpicture}[shorten <= 4pt,shorten > = 4pt] \draw[->] (1-1.east) -- (2-2.west); \draw[->] (2-1.east) -- (1-2.west); \end{tikzpicture} \end{NiceArray}$

\end{document}


You need several compilations (because nicematrix uses PGF/Tikz nodes).