Draw arrows between elements inside math matrix
tikz-cd can be used for this. Up-right arrows are drawn by \arrow[ur]
and Down-right arrows are drawn by \arrow[dr]
. Normal tikz options apply here. You can control row sep
and column sep
by specifying any lengths for them, or simply use [cramped, sep=small]
as a fast key.
\documentclass[12pt,norsk, fleqn]{article}
\usepackage{amssymb, amsmath, tikz-cd}
\begin{document}
\begin{tikzcd}[cramped, sep=small]
x_1 & y_1\arrow[dr] & z_1\arrow[dr] & x_1\arrow[dr] & y_1 & z_1 \\
x_2 & y_2\arrow[ur] & z_2\arrow[ur] & x_2\arrow[ur] & y_2 & z_2
\end{tikzcd}
\end{document}
Without tikz
.
\documentclass{article}
\usepackage{amssymb, amsmath,graphicx,tabstackengine}
\newcommand\crisscross{\ooalign{%
\rotatebox[origin=c]{30}{${-}\mkern-4mu{-}\mkern-4mu{\rightarrow}$}\cr
\rotatebox[origin=c]{-30}{${-}\mkern-4mu{-}\mkern-4mu{\rightarrow}$}}
}
\TABstackMath
\begin{document}
\[
{}={}\tabbedCenterstack{
x_1&&y_1&&z_1&&x_1&&y_1&&z_1\\
&\phantom{\crisscross}&&\crisscross&&\crisscross&&\crisscross&&\phantom{\crisscross}&\\
x_2&&y_2&&z_2&&x_2&&y_2&&z_2}
\]
\end{document}
The question reads “without having to do the entire thing in TikZ”, so here is a solution that keeps the original matrix
:
\documentclass[12pt,norsk, fleqn]{article}
\usepackage{amssymb, amsmath}
\usepackage{tikz}
\newcommand{\rn}[2]{%% "rn": "remember node"
\tikz[remember picture,baseline=(#1.base)]\node [inner sep=0] (#1) {$#2$};%
}
\begin{document}
%% The original matrix, but with commands to remember the nodes:
\begin{equation*}
\begin{matrix}
x_1 & \rn{11}{y_1} & \rn{12}{z_1} & \rn{13}{x_1} & \rn{14}{y_1} & z_1
\\
x_2 & \rn{21}{y_2} & \rn{22}{z_2} & \rn{23}{x_2} & \rn{24}{y_2} & z_2
\end{matrix}
\end{equation*}
%% Draw the arrows:
\begin{tikzpicture}[overlay,remember picture]
\draw [->] (11) -- (22);
\draw [->] (12) -- (23);
\draw [->] (13) -- (24);
\draw [->] (21) -- (12);
\draw [->] (22) -- (13);
\draw [->] (23) -- (14);
\end{tikzpicture}
\end{document}
Explanation:
The command \rn
puts its second argument in a tikz
node. The option remember picture
makes these nodes available even after the mini tikzpicture, i.e., after the equation.
Later, another tikzpicture draws the arrows. The option overlay
ensures that it takes no space and can draw on top of the matrix above.
It looks like before, but with the desired arrows: