I'm using the same codes as my the answer of my previous question
\documentclass[12pt,a4paper]{report}
\usepackage{amsfonts,amsmath,amssymb,amsthm,tikz}
\usetikzlibrary{calc,matrix}
\begin{document}
\begin{align*}
D &=
\begin{tikzpicture}[
baseline=-\the\dimexpr\fontdimen22\textfont2\relax,
strip/.style = {
draw=#1,%color
line width=1em, opacity=0.2,
shorten <=-2mm,shorten >=-2mm,
},
]
\matrix (mtrx) [matrix of math nodes,
column sep=1em,
nodes={text height=1ex,text width=2ex},
ampersand replacement=\&]
{
|[red]|+ \& |[red]|+ \& |[red]| +
\\[3.3mm,between origins]
a_1 \& b_1 \& c_1 \& a_1 \& a_2 \\
a_2 \& b_2 \& c_2 \& a_2 \& b_2 \\
a_3 \& b_3 \& c_3 \& a_3 \& b_3 \\
|[blue]|- \& |[blue]|- \& |[blue]|- \\
};
\draw[thick] (mtrx-4-1.south west) -- (mtrx-2-1.north west);
\draw[thick] (mtrx-4-3.south east) -- (mtrx-2-3.north east);
\path[draw,strip=blue]
(mtrx-4-1.center) edge (mtrx-2-3.center)
(mtrx-4-2.center) edge (mtrx-2-4.center)
(mtrx-4-3.center) -- (mtrx-2-5.center);
\path[draw,strip=red]
(mtrx-2-1.center) edge (mtrx-4-3.center)
(mtrx-2-2.center) edge (mtrx-4-4.center)
(mtrx-2-3.center) -- (mtrx-4-5.center);
\end{tikzpicture} \\
&= a+b+c\dots
\end{align*}
\end{document}
However I want to replace
If I replace in the codes
\begin{tikzpicture}[
baseline=-\the\dimexpr\fontdimen22\textfont2\relax,
strip/.style = {
draw=#1,%color
line width=1em, opacity=0.2,
shorten <=-2mm,shorten >=-2mm,
},
]
\matrix (mtrx) [matrix of math nodes,
column sep=1em,
nodes={text height=1ex,text width=2ex},
ampersand replacement=\&]
{
|[red]|+ \& |[red]|+ \& |[red]| +
\\[3.3mm,between origins]
a_1 \& b_1 \& c_1 \& a_1 \& a_2 \\
a_2 \& b_2 \& c_2 \& a_2 \& b_2 \\
a_3 \& b_3 \& c_3 \& a_3 \& b_3 \\
|[blue]|- \& |[blue]|- \& |[blue]|- \\
};
\draw[thick] (mtrx-4-1.south west) -- (mtrx-2-1.north west);
\draw[thick] (mtrx-4-3.south east) -- (mtrx-2-3.north east);
\path[draw,strip=blue]
(mtrx-4-1.center) edge (mtrx-2-3.center)
(mtrx-4-2.center) edge (mtrx-2-4.center)
(mtrx-4-3.center) -- (mtrx-2-5.center);
\path[draw,strip=red]
(mtrx-2-1.center) edge (mtrx-4-3.center)
(mtrx-2-2.center) edge (mtrx-4-4.center)
(mtrx-2-3.center) -- (mtrx-4-5.center);
\end{tikzpicture}
by
\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}
It does not work.


ampersand replacement=\&. Could be this the problem? – vi pa Jun 26 '21 at 21:33ampersand replacement(as already mentioned by @vipa), and in addition you need to remove the empty lines. Didn't think about that earlier, but empty lines are not allowed in math environments. See e.g. https://tex.stackexchange.com/questions/230338/ – Torbjørn T. Jun 27 '21 at 09:40\&=by=\&but it does not complile – Student Jun 27 '21 at 09:46\pathand\foreach? Did you addampersand replacement=\&to the options of thematrix? – Torbjørn T. Jun 27 '21 at 09:58\&outside thetikzpicture, only inside. – Torbjørn T. Jun 27 '21 at 09:59ampersand replacement=\&to the options of the matrix – Student Jun 27 '21 at 10:04ampersand replacement? "Options" in this context is the list of settings that you add in[]after\matrix. – Torbjørn T. Jun 27 '21 at 10:12$. I removed$but it does not work also. – Student Jun 27 '21 at 10:18tikzpicturefrom my code with your new one, and change the new one accordingly. I cannot guess how you managed to get an error about dollar signs. – Torbjørn T. Jun 27 '21 at 10:36? ! Undefined control sequence. \pgf@matrix@last@nextcell@options
l.37 \end{align*}
? Missing character: There is no a in font nullfont! ! Missing $ inserted.
? ``