我正在使用ACM 模板,最低限度的文件如下:
\documentclass[sigconf]{acmart}
\begin{document}
\begin{algorithm}[H]
\begin{algorithmic}[1]
\Input{}
\Output{}
\Function{}{}
\EndFunction
\end{algorithmic}
\end{algorithm}
\end{document}
为了安装算法环境,我尝试在现有环境中添加更多软件包,例如algorithm, algorithmic
,以及一些新命令,例如Input, Output
,等等。但我不确定是否可以简单地将它们放在下面\documentclass[sigconf]{acmart}
,或者我需要将它们放入其他文件中(我之前使用过其他一些模板,它们有这个 .sty 文件,您可以在其中添加软件包和自定义命令,但这个 acm 模板没有这样的文件)。我已经从 acm 网站上阅读了几篇文档,但我找不到说明。
答案1
您可以加载类似algorithmic
和algorithm2e
之后的包\documentclass[sigconf]{acmart}
sample-sigconf.tex
我整理了从包含在发行版中的 MWE 镜头https://www.acm.org/publications/proceedings-template。
注意:[H]
算法不允许使用双列模式。
该类acmart
加载了许多包。您可以在日志文件末尾通过在\listfiles
前添加命令来获取列表\documentclass [sigconf] {acmart}
。
添加新包之前请检查列表。
\documentclass[sigconf]{acmart}
\usepackage[]{algorithm2e} % added <<<<<<<<<<<<<<
\usepackage{algorithmic} % added <<<<<<<<<<<<<<
\begin{document}
\title{The Name of the Title is Hope}
\author{Ben Trovato}
\authornote{Both authors contributed equally to this research.}
\email{[email protected]}
\orcid{1234-5678-9012}
\author{G.K.M. Tobin}
\authornotemark[1]
\email{[email protected]}
\affiliation{%
\institution{Institute for Clarity in Documentation}
\streetaddress{P.O. Box 1212}
\city{Dublin}
\state{Ohio}
\country{USA}
\postcode{43017-6221}
}
\begin{abstract}
A clear and well-documented \LaTeX\ document is presented as an
article formatted for publication by ACM in a conference proceedings
or journal publication. Based on the ``acmart'' document class, this
article presents and explains many of the common variations, as well
as many of the formatting elements an author may use in the
preparation of the documentation of their work.
\end{abstract}
\maketitle
\section{Introduction}
ACM's consolidated article template, introduced in 2017, provides a
consistent \LaTeX\ style for use across ACM publications, and
incorporates accessibility and metadata-extraction functionality
necessary for future Digital Library endeavors. Numerous ACM and
SIG-specific \LaTeX\ templates have been examined, and their unique
features incorporated into this single new template.
If you are new to publishing with ACM, this document is a valuable
guide to the process of preparing your work for publication. If you
have published with ACM before, this document provides insight and
instruction into more recent changes to the article template.
The ``\verb|acmart|'' document class can be used to prepare articles
for any ACM publication --- conference or journal, and for any stage
of publication, from review to final ``camera-ready'' copy, to the
author's own version, with {\itshape very} few changes to the source.
\section{Algorithms}
You may want to display math equations in three distinct styles:
inline, numbered or non-numbered display. Each of the three are
discussed in the next sections.
Unlike algorithmic, algorithm2e provides a relatively huge number of customization options to the algorithm suiting to the needs of various users.
\textbf{[H] in two columns mode is not allowed for algorithms.}
\begin{algorithm}
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
\begin{algorithm} %[H] % [H] in two columns mode is not allowed for algorithms.
\caption{Calculate $y = x^n$. From the manual, page 14.} % give the algorithm a caption
\label{alg1} % and a label for \ref{} commands later in the document
\begin{algorithmic} % enter the algorithmic environment
\REQUIRE $n \geq 0 \vee x \neq 0$
\ENSURE $y = x^n$
\STATE $y \Leftarrow 1$
\IF{$n < 0$}
\STATE $X \Leftarrow 1 / x$
\STATE $N \Leftarrow -n$
\ELSE
\STATE $X \Leftarrow x$
\STATE $N \Leftarrow n$
\ENDIF
\WHILE{$N \neq 0$}
\IF{$N$ is even}
\STATE $X \Leftarrow X \times X$
\STATE $N \Leftarrow N / 2$
\ELSE[$N$ is odd]
\STATE $y \Leftarrow y \times X$
\STATE $N \Leftarrow N - 1$
\ENDIF
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\end{document}