Latex 错误“命令 \AND 已经定义。\REQUIRE”与 ifacconf 文档类

Latex 错误“命令 \AND 已经定义。\REQUIRE”与 ifacconf 文档类

我在 ifacconf 文档类中使用算法时,一直收到以下错误“命令 \AND 已定义。\REQUIRE”。我无法找出原因。示例代码如下:

    \documentclass{ifacconf}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{multirow}

\usepackage{amsmath}
\usepackage{graphicx}      % include this line if your document contains figures
\usepackage{natbib}        % required for bibliography
%===============================================================================
\usepackage{array}
\usepackage{algorithm}
\usepackage{algorithmic}

\floatname{algorithm}{Algorithm}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\renewcommand{\algorithmicendif}{\textbf{end}}




\newcolumntype{C}{>{\centering\arraybackslash}m{2.1cm}}% for convenience you can also define a new column type

\begin{document}
\begin{frontmatter}

\title{Test\thanksref{footnoteinfo}}
% Title, preferably not more than 10 words.

\thanks[footnoteinfo]{Test.}

\author[First]{Test} 

\address[First]{Department of Electrical Engineering, Qatar University, Doha, Qatar (e-mail: [email protected], [email protected]).}


\begin{abstract}                % Abstract of not more than 250 words.
test
\end{abstract}

\begin{keyword}
test
\end{keyword}

\end{frontmatter}
%===============================================================================
\maketitle
\thispagestyle{plain}
\pagestyle{plain}

\section{test}

\iffalse
\begin{algorithm}
\small
    \caption{Caption.}
    \label{alg1}
    \begin{algorithmic} 
        \REQUIRE {$L$ - level, $L_{\textrm{max}}$ -  Maximum level}
        \ENSURE {$P_{\textrm{main}}$ -  Main status}
        \IF{$L \leq  L_{\textrm{min}}$} \STATE {$P_{\textrm{main}}$  is ON} 
        \ELSIF{$L \geq L_{\textrm{max}}$} \STATE {$P_{\textrm{main}}$  is OFF}
        \ELSE \STATE {$P_{\textrm{main}}$ status does not change}
        \ENDIF
    \end{algorithmic}
\end{algorithm}
                                                          % in the appendices.
\end{document}

答案1

不幸的是,该类定义\AND代表 &(周围有空格)用于作者块。

您仍然可以加载algorithmic,但需要做一些扭曲。

\documentclass{ifacconf}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{multirow}

\usepackage{amsmath}
\usepackage{graphicx}      % include this line if your document contains figures
\usepackage{natbib}        % required for bibliography
%===============================================================================
\usepackage{array}
\usepackage{algorithm}
\usepackage{etoolbox}

% save the meaning of \AND and undefine it to keep algorithmic happy
\let\classAND\AND
\let\AND\relax
% load algorithmic
\usepackage{algorithmic}
% save the new meaning of \AND and restore the one of the class
\let\algoAND\AND
\let\AND\classAND
% but when we start \begin{algorithmic} we want its own \AND
\AtBeginEnvironment{algorithmic}{\let\AND\algoAND}

\floatname{algorithm}{Algorithm}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\renewcommand{\algorithmicendif}{\textbf{end}}




\newcolumntype{C}{>{\centering\arraybackslash}m{2.1cm}}% for convenience you can also define a new column type

\begin{document}
\begin{frontmatter}

\title{Test\thanksref{footnoteinfo}}
% Title, preferably not more than 10 words.

\thanks[footnoteinfo]{Test.}

\author[First]{Test} 

\address[First]{Department of Electrical Engineering, Qatar University, Doha, Qatar (e-mail: [email protected], [email protected]).}


\begin{abstract}                % Abstract of not more than 250 words.
test
\end{abstract}

\begin{keyword}
test
\end{keyword}

\end{frontmatter}
%===============================================================================
\maketitle
\thispagestyle{plain}
\pagestyle{plain}

\section{test}

\begin{algorithm}
\small
    \caption{Caption.}
    \label{alg1}
    \begin{algorithmic} 
        \REQUIRE {$L$ - level, $L_{\textrm{max}}$ -  Maximum level}
        \ENSURE {$P_{\textrm{main}}$ -  Main status}
        \IF{$L \leq  L_{\textrm{min}}$} \STATE {$P_{\textrm{main}}$  is ON} 
        \ELSIF{$L \geq L_{\textrm{max}}$} \STATE {$P_{\textrm{main}}$  is OFF}
        \ELSE \STATE {$P_{\textrm{main}}$ status does not change}
        \ENDIF
    \end{algorithmic}
\end{algorithm}
                                                          % in the appendices.
\end{document}

我相信你们都\textrm应该如此\mathrm

相关内容