TeX - LaTeX Asked by BrandNewStory on June 23, 2021
I am using an ACM template, and the minimum document is put below:
documentclass[sigconf]{acmart}
begin{document}
begin{algorithm}[H]
begin{algorithmic}[1]
Input{}
Output{}
Function{}{}
EndFunction
end{algorithmic}
end{algorithm}
end{document}
To install the algorithm environment, I’m trying to add more packages to the existing one, such as algorithm, algorithmic
, and also some new commands, such as Input, Output
, etc. But I’m not sure if it’s okay to simply put them under documentclass[sigconf]{acmart}
or I need to put them into other files(I used some other templates before, and they have this .sty file where you can add packages and customize commands, but this acm template doesn’t have such a file). I already read several documents from acm website but I can’t find the instructions.
You can load packages like algorithmic
and algorithm2e
right after documentclass[sigconf]{acmart}
I put together a shot MWE starting from sample-sigconf.tex
included in the distribution from
https://www.acm.org/publications/proceedings-template.
Note: [H]
in two columns mode is not allowed for algorithms.
The acmart
class loads many packages. You can get a list at the end of the log file by adding the command listfiles
before documentclass [sigconf] {acmart}
.
Check the list before adding a new package.
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}
Correct answer by Simon Dispa on June 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP