# How to write matrix and its source code using cnltx-example

I want to get output of the matrix

\begin{pmatrix}
\frac{1}{2} & 0 & \frac{9}{5} \\
-2 & \frac{2}{3} & -\frac{1}{4} \\
12 & 0 & \frac{11}{7} \\
\end{pmatrix}


along with the code displayed side by side using

\begin{example}[side-by-side]
\end{example}


with cnltx-example package. When I am going to compile (with amsart documentclass) this, it gives an error. How to fix this?

Here is my code

\documentclass{amsart}
\usepackage{amsmath,amsthm,amssymb,amsxtra,amsopn}
\usepackage{cnltx-example}

\begin{document}

\begin{example}[side-by-side]
Consider the following example.
$(x + y)^2 = x^2 + 2xy + y^2$
\end{example}

%The following gives an error at the time of compiling
\begin{example}[side-by-side]
Consider the following matrix.
$\begin{pmatrix} \frac{1}{2} & 0 & \frac{9}{5} \\ -2 & \frac{2}{3} & -\frac{1}{4} \\ 12 & 0 & \frac{11}{7} \\ \end{pmatrix}$
\end{example}

\end{document}


Apparently, cnltx-example requires an indentation of the code by two spaces:

\documentclass{amsart}
\usepackage{amssymb}
\usepackage{cnltx-example}

\begin{document}

\begin{example}[side-by-side]
Consider the following example.
$(x + y)^2 = x^2 + 2xy + y^2$
\end{example}

%The following gives an error at the time of compiling
\begin{example}[side-by-side]
Consider the following matrix.
$\begin{pmatrix} \frac{1}{2} & 0 & \frac{9}{5} \\ -2 & \frac{2}{3} & -\frac{1}{4} \\ 12 & 0 & \frac{11}{7} \\ \end{pmatrix}$
\end{example}

\end{document}