我想得到矩陣的輸出
\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{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}