14

I'm able to draw matrices on LaTeX but I don't know how to put crossing arrows on it as the second matrix in the figure.

Example of what I want

I tried to make it 5 x 5 matrices and put \diagup, \diagdown on diagonals but it didn't seem like a good idea.

3
28

I once worked out a similar thing with pgf/tikZ (surprise, surprise!) as a solution to a question where else.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}

\begin{document}
  \begin{tikzpicture}[>=stealth]
    \matrix [%
      matrix of math nodes,
      column sep=1em,
      row sep=1em
    ] (sarrus) {%
      a_{11} & a_{12} & a_{13} & a_{11} & a_{12} \\
      a_{21} & a_{22} & a_{23} & a_{21} & a_{22} \\
      a_{31} & a_{32} & a_{33} & a_{31} & a_{32} \\
    };

    \path ($(sarrus-1-1.north west)-(0.5em,0)$) edge ($(sarrus-3-1.south west)-(0.5em,0)$)
          ($(sarrus-1-3.north east)+(0.5em,0)$) edge ($(sarrus-3-3.south east)+(0.5em,0)$)
          (sarrus-1-1)                          edge            (sarrus-2-2)
          (sarrus-2-2)                          edge[->]        (sarrus-3-3)
          (sarrus-1-2)                          edge            (sarrus-2-3)
          (sarrus-2-3)                          edge[->]        (sarrus-3-4)
          (sarrus-1-3)                          edge            (sarrus-2-4)
          (sarrus-2-4)                          edge[->]        (sarrus-3-5)
          (sarrus-3-1)                          edge[dashed]    (sarrus-2-2)
          (sarrus-2-2)                          edge[->,dashed] (sarrus-1-3)
          (sarrus-3-2)                          edge[dashed]    (sarrus-2-3)
          (sarrus-2-3)                          edge[->,dashed] (sarrus-1-4)
          (sarrus-3-3)                          edge[dashed]    (sarrus-2-4)
          (sarrus-2-4)                          edge[->,dashed] (sarrus-1-5);

    \foreach \c in {1,2,3} {\node[anchor=south] at (sarrus-1-\c.north) {$+$};};
    \foreach \c in {1,2,3} {\node[anchor=north] at (sarrus-3-\c.south) {$-$};};
  \end{tikzpicture}
\end{document}

If you need help with further adaptations, feel free to ask.


enter image description here

3
  • 1
    +1 for the picture. I usually don't teach the Sarrus' rule. – egreg Oct 28 '11 at 15:57
  • Hi! there is a way to transforme your command in a 9-arguments math-command that we can call, for istance, '' \sarrus{arg1}{arg2}{arg3}{arg4}{arg5}{arg6}{arg7}{arg8}{arg9} '' ? @Thorsten Donig – Andrea Leo Oct 14 '16 at 11:45
  • @egreg I want to reproduce the picture. I tried wit align. I want to write D=. Could you please help me? I tried \begin{align*} D & = \begin{tikzpicture}[>=stealth].....but it does not work – Student Jun 26 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.