## LaTeX forum ⇒ Math & Science ⇒ Rule of Sarrus Topic is solved

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Math12345
Posts: 8
Joined: Sun Aug 07, 2011 7:20 am

### Rule of Sarrus

I have a problem! I need to write the Sarrus rule for 3x3 determinant, indicating additional two columns (to the right of the matrix) and diagonal lines for positive and negative products. How should I proceed? any idea?
Last edited by Math12345 on Mon Aug 08, 2011 11:42 am, edited 1 time in total.

LaTeXguide.org • LaTeX-Cookbook.net

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

### Rule of Sarrus  Topic is solved

A usual environment like array won't help you on here. The pgf/tikZ package can help you to construct a matrix with the necessary properties and the capability to connect the matrix elements with lines (or arrows). Let's take the example from the Wikipedia article [1].
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}

\begin{document}
\begin{tikzpicture}
\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-3.north east)+(0.5em,0)$) edge[dotted] ($(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}

For further adjustments and modifications take a look at the very comprehensive package manual.

[1] Rule of Sarrus — Wikipedia, the free encyclopedia

Best regards and welcome to the board
Thorsten
Attachments
Rendered output of the given code.
Sarrus.png (8.52 KiB) Viewed 9297 times
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Math12345
Posts: 8
Joined: Sun Aug 07, 2011 7:20 am

### Rule of Sarrus

Thanks Torsten for the code.
However, when trying to run it I get the message
l.3 \usetikzlibrary{calc,matrix}
Please type another input file name:

And then nothing more....
I am not so skilled in Latex and am not sure how to ommit it.

Best, and thanks.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

### Re: Rule of Sarrus

Submit the complete log file produced by my example code by upload to the forum server.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Stefan Kottwitz
Posts: 9845
Joined: Mon Mar 10, 2008 9:44 pm

### Re: Rule of Sarrus

You could check if you use the current version of pgf/TikZ, which is 2.10. If not, I recommend updating it.

Stefan

Math12345
Posts: 8
Joined: Sun Aug 07, 2011 7:20 am

### Re: Rule of Sarrus

Thanks Torsten and Stefan,
I noticed that I didn't have PGF/TikZ installed on my Mac at all. I downloaded version 2.10 but here is no information what so ever how to install it or were to put the files. As soon as I solve this problem I will check the code from Thorsten. If you have an idea how to handle the installation, please advice (I use TexShop)

All the best.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

### Rule of Sarrus

Math12345 wrote:[…] If you have an idea how to handle the installation, please advice (I use TexShop) […]

I guess that the TeX Live Utility will be very helpful in this regard. I don't know how to get it. Perhaps it is already installed with MacTeX.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

### Rule of Sarrus

Don't try to install it manually. Use the package manager of your TeX distribution. E.g., try (from a terminal):

sudo tlmgr install pgf

You might also look into the possibility of a GUI frontend for your distribution; some info here for MacTeX.

Math12345
Posts: 8
Joined: Sun Aug 07, 2011 7:20 am

### Re: Rule of Sarrus

IT WORKS !!!!!!
I'd like to say THANK YOU to all wonderful contributors!