添加 mathtools 包时出错

添加 mathtools 包时出错

我正在用 latex 写一份报告,我需要使用 cuthesis 库(位于http://www.nmai.ca/resources)。我不知道为什么当我添加 mathtools 库时,会产生很多错误。你能帮我修复这个错误吗?错误之一:未定义的控制序列\@calc@post@scan ...st@scan \else \def \calc@next{\calc@error #1}\fi \fi \f...\newtheorem{thy}{Theorem}[chapter]

以下是代码

\documentclass{report}
\usepackage[phd,4committee,nonsequential]{cuthesis}
\usepackage{mathtools}  
\usepackage{amssymb, amsbsy, amsthm, eqnarray}             % Mathematical symbols by AMS-LaTeX
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}    % see http://ctan.org/pkg/xcolor
\usepackage{setspace,etoolbox,titlesec,sectsty}



%-------------------------------------------------------------------------------------------------------------------------------------------
% Define some colors
%-------------------------------------------------------------------------------------------------------------------------------------------
\definecolor{cadmiumred}{rgb}{0.89, 0.0, 0.13}
\definecolor{darkBlue}{rgb}{0,0,.6}
\definecolor{darkRed}{rgb}{.7,0,0}

%-------------------------------------------------------------------------------------------------------------------------------------------
% Set the counter
%-------------------------------------------------------------------------------------------------------------------------------------------
\setlength\parindent{0pt}
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{3}  % Displying the section/subsection number
\interfootnotelinepenalty=10000

%-------------------------------------------------------------------------------------------------------------------------------------------
% Define Chapters and Section Headers font, Color and Shape
%-------------------------------------------------------------------------------------------------------------------------------------------
\newcommand{\colbox}{\colorbox[rgb]{1,0.41,0.13}}
\sectionfont{\color{orange}}                 % sets colour of sections
\subsectionfont{\color{RoyalBlue}}           % sets colour of subsections
\subsubsectionfont{\color{ForestGreen}}      % sets colour of subsubsections
\titleformat{\chapter}[display]{\normalfont\huge\bfseries\color{darkBlue}}{\chaptertitlename\ \thechapter}{2pt}{\Huge} 
\titlespacing{\chapter}{0pt}{1pt}{1pt} 
\titlespacing{\section}{0pt}{2pt}{4pt}
\titlespacing{\subsection}{0pt}{2pt}{4pt}
\makeatletter % changes the catcode/category code of @ to 11
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname)\;} % Add bracket after section # and small space by\;
\makeatother % changes the catcode/category code of @ back to 12

%-------------------------------------------------------------------------------------------------------------------------------------------
% Define the some styles
%-------------------------------------------------------------------------------------------------------------------------------------------
\newtheoremstyle{exstyle}                % name
  {3pt}                                          % Space above
  {3pt}                                          % Space below
  {}                                             % Body font
  {}                                             % Indent amount (empty = no indent, \parindent = para indent)
  {\normalfont\color{cadmiumred}}% Thm head font
  {:}                                            % Punctuation after thm head
  %{.5em}                                        % Space after thm head: " " = normal interword space;
  {\newline}                                     %\newline = linebreak
  {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}} %Thm head spec (can be left empty, meaning 'normal')

\theoremstyle{exstyle}
%\newtheorem{mydef}{Definition}[chapter]
%\newtheorem{ex}{Example}[chapter]

\newtheoremstyle{mytheoremstyle}  % name
        {\topsep}                     % Space above
        {\topsep}                     % Space below
        {\slshape\selectfont}         % Body font
        {}                            % Indent amount
        {\bfseries\color{cadmiumred}} % Theorem head font {\bfseries\itshape\
        {:}                           % Punctuation after theorem head
        %{.5em}                       % Space after theorem head
        {\newline}                                    %\newline = linebreak
        {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}} % Theorem head spec (can be left empty, meaning 'normal')

\theoremstyle{mytheoremstyle}
\newtheorem{thy}{Theorem}[chapter]   
\newtheorem{coly}{Corollary}[chapter] 
\newtheorem{lem}{Lemma}[chapter] 
\newtheorem{pro}{Proposition}[chapter] 
\newtheorem{Res}{Result}[chapter] 
\newtheorem{prop}{Property}[chapter] 
\newtheorem{remark}{Remark}[chapter] 
\newtheorem{note}{Note}[chapter]

\numberwithin{equation}{chapter}


\DeclarePairedDelimiterX{\innp}[2]{\langle}{\rangle}{#1, #2}              %\innp[\bigg]{x}{y}
\DeclarePairedDelimiterX\norm[1]\lVert\rVert{\ifblank{#1}{\:\cdot\:}{#1}} %\norm[\bigg]{x}

\begin{document}

\chapter{First Chapter}\label{ch1:1}
\section{First Section}\label{ch1:sec1}

This is the first section

\section{Second Section}\label{ch1:sec2}

This is the second section

\subsection{Sub Section}\label{ch1:ssec2}

\begin{itemize}
   \item $\innp{S-\mathbf{d}}{\mathbf{d}}_\mathbf{w} = 0$ i.e. $S-\mathbf{d}$ is orthogonal to $\mathbf{d}$, so we obtain 
            \[
                    S^T\mathbf{d}=(S^T+\mathbf{d}^T-\mathbf{d}^T) \mathbf{d}= \norm[\big]{\mathbf{d}}^2
            \]
\end{itemize}



\end{document}

当我注释掉下面的代码时,这些错误消失了,我不知道这是为什么。

\newtheorem{thy}{Theorem}[chapter]   
\newtheorem{coly}{Corollary}[chapter] 
\newtheorem{lem}{Lemma}[chapter] 
\newtheorem{pro}{Proposition}[chapter] 
\newtheorem{Res}{Result}[chapter] 
\newtheorem{prop}{Property}[chapter] 
\newtheorem{remark}{Remark}[chapter] 
\newtheorem{note}{Note}[chapter]

\numberwithin{equation}{chapter}

非常感谢您的帮助。

答案1

如果您删除一些部分cuthesis.cls直到错误消失,您会发现这是一个更简单的例子:

\documentclass{report}
\makeatletter



\newcounter{mychapcitecount}




\def\cl@chapter{%
  \setcounter{mychapcitecount}{0}%
  \@ifundefined{@nonsequential}{%
    \@elt{section}\@elt{footnote}%
  }{%
    \@elt{equation}\@elt{figure}\@elt{footnote}\@elt{section}\@elt{table}%
  }}


\makeatother



\usepackage{calc}
\usepackage{amsthm}             % Mathematical symbols by AMS-LaTeX

\usepackage{setspace,etoolbox,titlesec,sectsty}



%-------------------------------------------------------------------------------------------------------------------------------------------
% Define some colors
%-------------------------------------------------------------------------------------------------------------------------------------------
% Set the counter
%-------------------------------------------------------------------------------------------------------------------------------------------


\newtheorem{thy}{Theorem}[chapter]   


\begin{document}



\end{document}

因此,您可以撤消该包的定义\cl@chapter,并发现此版本的示例运行时没有错误

\documentclass{report}
\makeatletter
\let\foo\cl@chapter
\usepackage[phd,4committee,nonsequential]{cuthesis}
\let\cl@chapter\foo
\makeatother

\usepackage{mathtools}  
\usepackage{amssymb, amsbsy, amsthm, eqnarray}             % Mathematical symbols by AMS-LaTeX
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}    % see http://ctan.org/pkg/xcolor
\usepackage{setspace,etoolbox,titlesec,sectsty}



%-------------------------------------------------------------------------------------------------------------------------------------------
% Define some colors
%-------------------------------------------------------------------------------------------------------------------------------------------
\definecolor{cadmiumred}{rgb}{0.89, 0.0, 0.13}
\definecolor{darkBlue}{rgb}{0,0,.6}
\definecolor{darkRed}{rgb}{.7,0,0}

%-------------------------------------------------------------------------------------------------------------------------------------------
% Set the counter
%-------------------------------------------------------------------------------------------------------------------------------------------
\setlength\parindent{0pt}
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{3}  % Displying the section/subsection number
\interfootnotelinepenalty=10000

%-------------------------------------------------------------------------------------------------------------------------------------------
% Define Chapters and Section Headers font, Color and Shape
%-------------------------------------------------------------------------------------------------------------------------------------------
\newcommand{\colbox}{\colorbox[rgb]{1,0.41,0.13}}
\sectionfont{\color{orange}}                 % sets colour of sections
\subsectionfont{\color{RoyalBlue}}           % sets colour of subsections
\subsubsectionfont{\color{ForestGreen}}      % sets colour of subsubsections
\titleformat{\chapter}[display]{\normalfont\huge\bfseries\color{darkBlue}}{\chaptertitlename\ \thechapter}{2pt}{\Huge} 
\titlespacing{\chapter}{0pt}{1pt}{1pt} 
\titlespacing{\section}{0pt}{2pt}{4pt}
\titlespacing{\subsection}{0pt}{2pt}{4pt}
\makeatletter % changes the catcode/category code of @ to 11
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname)\;} % Add bracket after section # and small space by\;
\makeatother % changes the catcode/category code of @ back to 12

%-------------------------------------------------------------------------------------------------------------------------------------------
% Define the some styles
%-------------------------------------------------------------------------------------------------------------------------------------------
\newtheoremstyle{exstyle}                % name
  {3pt}                                          % Space above
  {3pt}                                          % Space below
  {}                                             % Body font
  {}                                             % Indent amount (empty = no indent, \parindent = para indent)
  {\normalfont\color{cadmiumred}}% Thm head font
  {:}                                            % Punctuation after thm head
  %{.5em}                                        % Space after thm head: " " = normal interword space;
  {\newline}                                     %\newline = linebreak
  {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}} %Thm head spec (can be left empty, meaning 'normal')

\theoremstyle{exstyle}
%\newtheorem{mydef}{Definition}[chapter]
%\newtheorem{ex}{Example}[chapter]

\newtheoremstyle{mytheoremstyle}  % name
        {\topsep}                     % Space above
        {\topsep}                     % Space below
        {\slshape\selectfont}         % Body font
        {}                            % Indent amount
        {\bfseries\color{cadmiumred}} % Theorem head font {\bfseries\itshape\
        {:}                           % Punctuation after theorem head
        %{.5em}                       % Space after theorem head
        {\newline}                                    %\newline = linebreak
        {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}} % Theorem head spec (can be left empty, meaning 'normal')

\theoremstyle{mytheoremstyle}
\newtheorem{thy}{Theorem}[chapter]   
\newtheorem{coly}{Corollary}[chapter] 
\newtheorem{lem}{Lemma}[chapter] 
\newtheorem{pro}{Proposition}[chapter] 
\newtheorem{Res}{Result}[chapter] 
\newtheorem{prop}{Property}[chapter] 
\newtheorem{remark}{Remark}[chapter] 
\newtheorem{note}{Note}[chapter]

\numberwithin{equation}{chapter}


\DeclarePairedDelimiterX{\innp}[2]{\langle}{\rangle}{#1, #2}              %\innp[\bigg]{x}{y}
\DeclarePairedDelimiterX\norm[1]\lVert\rVert{\ifblank{#1}{\:\cdot\:}{#1}} %\norm[\bigg]{x}

\begin{document}

\chapter{First Chapter}\label{ch1:1}
\section{First Section}\label{ch1:sec1}

This is the first section

\section{Second Section}\label{ch1:sec2}

This is the second section

\subsection{Sub Section}\label{ch1:ssec2}

\begin{itemize}
   \item $\innp{S-\mathbf{d}}{\mathbf{d}}_\mathbf{w} = 0$ i.e. $S-\mathbf{d}$ is orthogonal to $\mathbf{d}$, so we obtain 
            \[
                    S^T\mathbf{d}=(S^T+\mathbf{d}^T-\mathbf{d}^T) \mathbf{d}= \norm[\big]{\mathbf{d}}^2
            \]
\end{itemize}



\end{document}

相关内容