LaTeX 错误:命令 \numdef 已定义

LaTeX 错误:命令 \numdef 已定义

系统将此错误链接到“/usr/local/texlive/2022/texmf-dist/tex/latex/etoolbox/etoobox.sty, 1003”。我不知道这到底意味着什么,尽管我在安装在我电脑 C: 驱动器中的相同路径的 texlive 2023 文件中找到了这样的定义。

该错误的详细信息如下:

Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...                                              
l.1003   \edef#1{\the\numexpr#2}}
                                  
Here is how much of TeX's memory you used:
23676 strings out of 477679
459511 string characters out of 5829514
763038 words of memory out of 5000000
42069 multiletter control sequences out of 15000+600000
470967 words of font info for 31 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
98i,1n,94p,437b,79s stack positions out of 10000i,1000n,20000p,200000b,200000s
No pages of output.

以下是工作环境:

% if your latex compiler failed to compile, uncomment the command below:
%\RequirePackage[2020-02-02]{latexrelease}
\documentclass{clv3}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{linguex}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{xltabular}
\usepackage{makecell}
\usepackage{metalogo}
\usepackage{array}
\usepackage{tabto}
\usepackage{booktabs}
\usepackage[linguistics]{forest}
\usepackage{tabto}
\usepackage{amssymb}
\let\oldemptyset\emptyset
\let\emptyset\varnothing
\definecolor{darkblue}{rgb}{0, 0, 0.5}
\hypersetup{colorlinks=true,citecolor=darkblue, linkcolor=darkblue, urlcolor=darkblue}
\bibliographystyle{compling}
\usepackage{CJKutf8}
\usepackage{linguex}
\begin{document}
 content
...
\end {document}

系统现在无法编译。希望这是(唯一)原因。提前感谢您的帮助。

答案1

这很简单。clv3该类的作用是

\def\numdefname{Definition}
\newtheorem{numdef}{\numdefname}

etoolbox同时也想定义\numdef

通过为环境添加别名可以很容易地解决这个问题numdef,但还有一个更糟糕的问题:该类还重新定义了\document,这是一个非常坏事: 看计算语言模板问题 - COLI - CLV3.cls

% save the kernel \document and \enddocument
\let\latexdocument\document
\let\latexenddocument\enddocument
%%%

\documentclass{clv3}
% restore the original
\let\document\latexdocument
\let\enddocument\latexenddocument

% add to the standard hooks
\makeatletter
\AtBeginDocument{%
  \if@filesw
    \immediate\openout\@mainqry=\jobname.qry
  \fi
}
\AtEndDocument{%
   \ifx\@biography\@empty\else{\par\ifbrief\vskip10pt\fi\biofont\noindent\@biography\par}\fi
   \immediate\closeout\@mainqry
   %\ifquery
   %   \process@queries\clearpage
   %\else
      \ifodd\c@page\clearpage\thispagestyle{empty}\null\clearpage\else\clearpage\fi
   %\fi
   %\ifquery\clearpage\else\ifodd\c@page\clearpage\thispagestyle{empty}\null\clearpage\else\clearpage\fi\fi
}
\makeatother

% alias numdef to cnumdef
\NewCommandCopy{\cnumdef}{\numdef}
\NewCommandCopy{\endcnumdef}{\endnumdef}
\let\numdef\relax \let\endnumdef\relax

\usepackage{xcolor}
\usepackage{linguex}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{xltabular}
\usepackage{makecell}
\usepackage{metalogo}
\usepackage{array}
\usepackage{tabto}
\usepackage{booktabs}
\usepackage[linguistics]{forest}
\usepackage{tabto}
\usepackage{amssymb}
\usepackage{CJKutf8}
\usepackage{linguex}
\usepackage{hyperref}

\let\oldemptyset\emptyset
\let\emptyset\varnothing

\definecolor{darkblue}{rgb}{0, 0, 0.5}
\hypersetup{colorlinks=true,citecolor=darkblue, linkcolor=darkblue, urlcolor=darkblue}
\bibliographystyle{compling}

\begin{document}

 content
...

\end {document}

注意 的位置\usepackage{hyperref},它应该放在最后。

相关内容