%%%% ijcai21.tex
\typeout{IJCAI--21 Instructions for Authors}
% These are the instructions for authors for IJCAI-21.
\documentclass{article}
\pdfpagewidth=8.5in
\pdfpageheight=11in
% The file ijcai21.sty is NOT the same than previous years'
\usepackage{ijcai21}
% Use the postscript times font!
\usepackage{times}
\usepackage{soul}
\usepackage{url}
\usepackage[hidelinks]{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[small]{caption}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{booktabs}
\usepackage{algorithm}
\usepackage{algorithmic}
\urlstyle{same}
\newtheorem{example}{Example}
\newtheorem{theorem}{Theorem}
\pdfinfo{
/TemplateVersion (IJCAI.2021.0)
}
\title{IJCAI--21 Formatting Instructions}
% Single author syntax
\author{
}
\begin{document}
\maketitle
\begin{algorithm}[tb]
\caption{Example algorithm}
\label{alg:algorithm}
\textbf{Input}: Your algorithm's input\\
\textbf{Parameter}: Optional list of parameters\\
\textbf{Output}: Your algorithm's output
\begin{algorithmic}[1] %[1] enables line numbers
\STATE Let $t=0$.
\WHILE{condition}
\STATE Do some action.
\IF {conditional}
\STATE Perform task A.
\ELSE
\STATE Perform task B.
\ENDIF
\ENDWHILE
\STATE \textbf{return} solution
\end{algorithmic}
\end{algorithm}
\end{document}
我想要使用的过程包含输入和三个语句。
答案1
如果您想要/必须使用该algorithmic
包,则必须自己定义过程语句。将以下代码放入您的序言中。
\usepackage{algorithmic}
\newcommand\algorithmicprocedure{\textbf{procedure}}
\newcommand{\algorithmicendprocedure}{\algorithmicend\ \algorithmicprocedure}
\makeatletter
\newcommand\PROCEDURE[3][default]{%
\ALC@it
\algorithmicprocedure\ \textsc{#2}(#3)%
\ALC@com{#1}%
\begin{ALC@prc}%
}
\newcommand\ENDPROCEDURE{%
\end{ALC@prc}%
\ifthenelse{\boolean{ALC@noend}}{}{%
\ALC@it\algorithmicendprocedure
}%
}
\newenvironment{ALC@prc}{\begin{ALC@g}}{\end{ALC@g}}
\makeatother
使用方法如下:
\PROCEDURE[optional comment]{proc name}{arguments}
...
\ENDPROCEDURE
如果您使用该algpseudocode
包(基于该algorithmicx
包),则程序是预定义的。
算法包
\documentclass{article}
\usepackage{algorithmic}
\newcommand\algorithmicprocedure{\textbf{procedure}}
\newcommand{\algorithmicendprocedure}{\algorithmicend\ \algorithmicprocedure}
\makeatletter
\newcommand\PROCEDURE[3][default]{%
\ALC@it
\algorithmicprocedure\ \textsc{#2}(#3)%
\ALC@com{#1}%
\begin{ALC@prc}%
}
\newcommand\ENDPROCEDURE{%
\end{ALC@prc}%
\ifthenelse{\boolean{ALC@noend}}{}{%
\ALC@it\algorithmicendprocedure
}%
}
\newenvironment{ALC@prc}{\begin{ALC@g}}{\end{ALC@g}}
\makeatother
\begin{document}
\begin{flushleft}
\textbf{Input}: Your algorithm's input\\
\textbf{Parameter}: Optional list of parameters\\
\textbf{Output}: Your algorithm's output
\begin{algorithmic}[1] %[1] enables line numbers
\PROCEDURE[some comment]{MyProc}{$a,b\colon \mathrm{int}$}
\STATE Let $t=0$.
\WHILE{condition}
\STATE Do some action.
\IF {conditional}
\STATE Perform task A.
\ELSE
\STATE Perform task B.
\ENDIF
\ENDWHILE
\STATE \textbf{return} solution
\ENDPROCEDURE
\end{algorithmic}
\end{flushleft}
\end{document}
软件包“algpseudocode”
\documentclass{article}
\usepackage{algpseudocode}
\begin{document}
\begin{flushleft}
\textbf{Input}: Your algorithm's input\\
\textbf{Parameter}: Optional list of parameters\\
\textbf{Output}: Your algorithm's output
\begin{algorithmic}[1] %[1] enables line numbers
\Procedure{MyProc}{$a,b\colon \mathrm{int}$}\Comment{some comment}
\State Let $t=0$.
\While{condition}
\State Do some action.
\If{conditional}
\State Perform task A.
\Else
\State Perform task B.
\EndIf
\EndWhile
\State \textbf{return} solution
\EndProcedure
\end{algorithmic}
\end{flushleft}
\end{document}