newlistof 代码有什么错误?

newlistof 代码有什么错误?

我替换了列表名称 -myeqations by example- 但出现错误?

\documentclass[11pt]{report}
\usepackage{tocloft, xparse}

\newcommand{\listexample}{List of examples}
\newlistof{example}{exp}{\listexample}

\newcommand{\example}[1]{%
    \refstepcounter{example}%
    \par\noindent\textbf{example \theexample. #1}
    \addcontentsline{exp}{example}{\protect\numberline{\thechapter.\theexample}#1}\par}

\DeclareDocumentEnvironment{example}{ m m }{%
    \example\label{#1}}{\endexample\example{#2}}

\begin{document}
    \tableofcontents
    \listofexample
    \listoftables
    \chapter{Introduction}
    \begin{example}{ex:SOE}{Second Order example}
        g(\pi_j)= \alpha_{jk} \alpha_{kg}\theta_g + \alpha_{jk}\xi_k + \beta_j
    \end{example}
\end{document}

答案1

\documentclass[11pt]{report}
\usepackage{tocloft, xparse}

\newcommand{\listexamplename}{List of examples}
\newlistof{example}{exp}{\listexamplename}
\newcommand{\example}[1]{%
    \refstepcounter{example}%
    \par\noindent\textbf{Example\theexample. #1}
    \addcontentsline{exp}{example}
    {\protect\numberline{\thechapter.\theexample}#1}\par}

\DeclareDocumentEnvironment{examplee}{ m m }{%
    \equation\label{#1}}{\endequation\example{#2}}

\begin{document}
    \tableofcontents
    \listofexample
    \listoftables
    \chapter{Introduction}
    \begin{examplee}{eq:SOE}{Second Order Equation}
        g(\pi_j)= \alpha_{jk} \alpha_{kg}\theta_g + \alpha_{jk}\xi_k + \beta_j
    \end{examplee}

\end{document}

相关内容