我想获得矩阵的输出
\begin{pmatrix}
\frac{1}{2} & 0 & \frac{9}{5} \\
-2 & \frac{2}{3} & -\frac{1}{4} \\
12 & 0 & \frac{11}{7} \\
\end{pmatrix}
以及使用并排显示的代码
\begin{example}[side-by-side]
\end{example}
使用cnltx-example
包。当我要编译(使用amsart
documentclass)这个时,它给出错误。如何修复它?
这是我的代码
\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}
答案1
显然,cnltx-example
需要将代码缩进两个空格:
\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}