我正在使用新的 ACMacmart
模板我的论文。在新论文中,我对算法部分有一个问题:
\documentclass[acmlarge]{acmart}
\usepackage{booktabs} % For formal tables
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{listings}
\usepackage[ruled]{algorithm2e} % For algorithms
\renewcommand{\algorithmcfname}{ALGORITHM}
\SetAlFnt{\small}
\SetAlCapFnt{\small}
\SetAlCapNameFnt{\small}
\SetAlCapHSkip{0pt}
\IncMargin{-\parindent}
% Metadata Information
\acmJournal{POMACS}
\acmVolume{9}
\acmNumber{4}
\acmArticle{39}
\acmYear{2010}
\acmMonth{3}
\acmArticleSeq{11}
%\acmBadgeR[http://ctuning.org/ae/ppopp2016.html]{ae-logo}
%\acmBadgeL[http://ctuning.org/ae/ppopp2016.html]{ae-logo}
% Copyright
%\setcopyright{acmcopyright}
%\setcopyright{acmlicensed}
%\setcopyright{rightsretained}
%\setcopyright{usgov}
\setcopyright{usgovmixed}
%\setcopyright{cagov}
%\setcopyright{cagovmixed}
% DOI
\acmDOI{0000001.0000001}
% Paper history
\received{February 2007}
\received{March 2009}
\received[accepted]{June 2009}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newtheorem{myDefine}{Definition}
\newcommand{\img}{\includegraphics[width=.15\linewidth,height=20pt]{example-image}}
\lstset{language=Java, breaklines=true, captionpos=b, numbers=left, keywordstyle=\color{blue}, numbersep=3pt, basicstyle=\footnotesize, %or \small or \footnotesize etc.
}
% Document starts
\begin{document}
% Title portion
\title{Your title}
\author{Your name}
\orcid{1234-5678-9012-3456}
\affiliation{%
\institution{College of William and Mary}
\streetaddress{104 Jamestown Rd}
\city{Williamsburg}
\state{VA}
\postcode{23185}
\country{USA}}
\author{Tian He}
\affiliation{%
\institution{University of Minnesota}
\country{USA}}
\author{Chengdu Huang}
\author{John A. Stankovic}
\author{Tarek F. Abdelzaher}
\affiliation{%
\institution{University of Virginia}
\department{School of Engineering}
\city{Charlottesville}
\state{VA}
\postcode{22903}
\country{USA}
}
\begin{abstract}
helkoi
\end{abstract}
%
% The code below should be generated by the tool at
% http://dl.acm.org/ccs.cfm
% Please copy and paste the code instead of the example below.
%
\ccsdesc[500]{Computer systems organization~Embedded systems}
\ccsdesc[300]{Computer systems organization~Redundancy}
\ccsdesc{Computer systems organization~Robotics}
\ccsdesc[100]{Networks~Network reliability}
%
% End generated code
%
% We no longer use \terms command
\terms{Design, Algorithms, Performance}
\keywords{Wireless sensor networks, media access control,
multi-channel, radio interference, time synchronization}
\thanks{This work is supported by the National Science Foundation,
under grant CNS-0435060, grant CCR-0325197 and grant EN-CS-0329609.
Author's addresses: G. Zhou, Computer Science Department, College of
William and Mary; Y. Wu {and} J. A. Stankovic, Computer Science
Department, University of Virginia; T. Yan, Eaton Innovation Center;
T. He, Computer Science Department, University of Minnesota; C.
Huang, Google; T. F. Abdelzaher, (Current address) NASA Ames
Research Center, Moffett Field, California 94035.}
\maketitle
% The default list of authors is too long for headers}
\renewcommand{\shortauthors}{G. Zhou et al.}
\section{Introduction}
.....
\begin{algorithm}[H]
\caption{Bytecode Generation Overview}
\label{alg:generator}
%\begin{algorithmic}[1]
Map store=new Map(obj, queue)
\function{\textit{generate}}{Object pivot}
\ForAll{child $c$ in pivot}{
\If{ $c$'s FieldContext is not set and $c$ is fusible}{
generate($c$);
}
}
build pivot's fieldContext $fc$;
EmitClassName;
EmitFields($fc$);
EmitMethods($fc$);
%\end{algorithmic}
\end{algorithm}
\end{document}
编译latex file.tex
失败并显示以下消息:
! Missing } inserted.
<inserted text>
}
l.464 \end{algorithm}
如果我添加了一个}
after EmitMethods($fc$);
,那么错误消息将变成:
Overfull \hbox (1.5003pt too wide) detected at line 464
[][]
! Extra }, or forgotten \endgroup.
\@algocf@finish ... {\skipalgocfslide }}{}\egroup
\end {lrbox}\algocf@maketh...
l.464 \end{algorithm}
我读了这条消息,但半天没发现问题?哪里出了问题?有人能帮忙吗?
答案1
Algorithm2e 定义function
为 的替代方案algortihm
。我猜你想要类似
\begin{algorithm}[H]
\caption{Bytecode Generation Overview}
\label{alg:generator}
\SetKwProg{generate}{Function \emph{generate}}{}{end}
Map store=new Map(obj, queue)\;
\generate{Object pivot}{
\ForAll{child $c$ in pivot}{
\If{ $c$'s FieldContext is not set and $c$ is fusible}{
generate($c$)\;
}
}
build pivot's fieldContext $fc$\;
EmitClassName\;
EmitFields($fc$)\;
EmitMethods($fc$)\;
}
\end{algorithm}