From d23537f56720850db3dedce1b78bd65bbd6d0b0a Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 1 Sep 2017 01:31:58 +0000
Subject: acmart (31aug17)

git-svn-id: svn://tug.org/texlive/trunk@45184 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/latex/acmart/acmart.dtx | 354 ++++++++++++++++-------
 1 file changed, 242 insertions(+), 112 deletions(-)

(limited to 'Master/texmf-dist/source/latex/acmart/acmart.dtx')

diff --git a/Master/texmf-dist/source/latex/acmart/acmart.dtx b/Master/texmf-dist/source/latex/acmart/acmart.dtx
index a95593b235c..e4ed2233966 100644
--- a/Master/texmf-dist/source/latex/acmart/acmart.dtx
+++ b/Master/texmf-dist/source/latex/acmart/acmart.dtx
@@ -15,8 +15,8 @@
 % The Current Maintainer of this work is Boris Veytsman,
 % <borisv@lk.net>
 %
-% This work consists of the file acmart.dtx, the derived files
-% acmart.cls, acmthm.sty, the files ACM-Reference-Format.bst, and templates
+% This work consists of the file acmart.dtx, the derived file
+% acmart.cls, the files ACM-Reference-Format.bst, and templates
 % sample-acmlarge.tex, sample-acmsmall.tex, sample-acmtog.tex,
 % samplebody-conf.tex, samplebody-journals.tex, sample-manuscript.tex,
 % sample-sigchi-a.tex, sample-sigchi.tex,
@@ -101,12 +101,14 @@
 %  Michael D.~Adams,
 %  Leif Andersen, 
 %  Dirk Beyer,
+%  Benjamin Byholm,
 %  Michael Ekstrand,
 %  Matthew Fluet,
 %  Paolo G.~Giarrusso,
 %  Ben Greenman,
 %  LianTze Lim,
 %  Ben Liblit,
+%  Kai Mindermann,
 %  Frank Mittelbach, 
 %  Ross Moore,
 %  John Owens,
@@ -128,6 +130,17 @@
 %\label{sec:ug}
 %
 %
+% The class uses many commands and customizaton options, so it might
+% appear intimidating for a casual user.  Do not panic!  Many of these
+% commands and options can be safely left with their default values,
+% or the values recommended by your conference or journal editors.  If
+% you have problems or questions, do not hesitate to ask me directly
+% or the community at \url{https://github.com/borisveytsman/acmart},
+% \url{https://tex.stackexchange.com} or the closest \TeX\ Users
+% Group.  The world-wide \TeX\ Users Group is at
+% \url{https://tug.org/}; please consider joining us if you use \TeX\
+% regularly.
+%
 %\subsection{Installation}
 %\label{sec:ug_install}
 %
@@ -148,9 +161,9 @@
 % and rather rely on their \TeX\ distributions to provide it.  If you
 % decide to install the package yourself, follow the standard rules:
 % \begin{enumerate}
-% \item Run \progname{latex} on |acmart.ins|.  This will produce the files
-% |acmart.cls| and |acmthm.sty|
-% \item Put the files |acmart.cls|, |acmthm.sty| 
+% \item Run \progname{latex} on |acmart.ins|.  This will produce the file
+% |acmart.cls|
+% \item Put the file |acmart.cls|
 %   and the bibliography files |*.bst|
 %   to the places where \LaTeX{} can find them (see \cite{TeXFAQ} or
 %   the documentation for your \TeX{} system).\label{item:install}
@@ -180,6 +193,7 @@
 % \item \textsl{cmap}, \url{http://www.ctan.org/pkg/cmap}
 % \item \textsl{draftwatermark}, \url{http://www.ctan.org/pkg/draftwatermark}
 % \item \textsl{environ}, \url{http://www.ctan.org/pkg/environ}
+% \item \textsl{etoolbox}, \url{http://www.ctan.org/pkg/etoolbox}
 % \item \textsl{fancyhdr}, \url{http://www.ctan.org/pkg/fancyhdr}
 % \item \textsl{float}, \url{http://www.ctan.org/pkg/float}
 % \item \textsl{fontaxes}, \url{http://www.ctan.org/pkg/fontaxes}
@@ -291,9 +305,12 @@
 % option: it provides a version suitable for reviewers and
 % copyeditors.  
 %
-% The option |screen| may in the future involve
-% additional features  suitable for on-screen versions of the
-% articles.  
+% The default for the option |screen| depends on the publication.  At
+% present it is |false| for all publications \emph{but} PACM, since
+% PACM is now electronic-only.  Thus PACM titles (see
+% Table~\ref{tab:pubs} set this option to |true|.  This option may in
+% the future involve additional features suitable for on-screen
+% versions of the articles.
 % 
 % The option |natbib| is used when the corresponding
 % \BibTeX\ style is based on |natbib|.  In most cases you do not need
@@ -328,7 +345,8 @@
 %     \midrule
 %     review & false & A review version: lines are numbered,
 %     hyperlinks are colored\\
-%     screen & false & A screen version: hyperlinks are colored\\
+%     screen & {\rmfamily see text} & A screen version:
+%     hyperlinks are colored\\ 
 %     natbib & true & Whether to use |natbib| package (see
 %     Section~\ref{sec:ug_bibliography})\\
 %     anonymous & false & Whether to make author(s) anonymous\\
@@ -338,7 +356,7 @@
 %     timestamp & false & Whether to put a time stamp in the
 %     footer of each page\\
 %     authordraft & false & Whether author's draft mode is enabled\\
-%     acmthm & true & Whether to load |acmthm.sty|, see
+%     acmthm & true & Whether to define theorem-like environments, see
 %     Section~\ref{sec:ug_theorems}\\
 %     \bottomrule
 %   \end{tabularx}
@@ -734,23 +752,34 @@
 % It is expected that these commands are inserted by the author of the
 % manuscript.
 %
-% \DescribeMacro{\thanks}
-% Like \progname{amsart} (and unlike standard \LaTeX{}),
-% we allow |\thanks| only \emph{outside} of
-% commands |\title| and |\author|.  Example:
+% \DescribeMacro{\thanks}%
+% Like \progname{amsart} (and unlike standard \LaTeX{}), we allow
+% |\thanks| only \emph{outside} of commands |\title| and |\author|.
+% This command is obsolete, and should \emph{not} be used in most
+% cases.  Do not list your acknowledgements and grant sponsors here:
+% put this information in the |acks| environment (see
+% Section~\ref{sec:ug_acks}).
+%
+% \DescribeMacro{\authorsaddresses}%
+% In some formats the addresses are printed as a footnote on the first
+% page.  By default \LaTeX\ typesets them itself using the information
+% you give it.  However, you can override its choice using the
+% commmand \cs{authorsaddresses}\marg{contact addresses}, for example,
 % \begin{verbatim}
-% \thanks{This work is supported by the Widget Corporation Grant
-% \#312-001.\\
-% Author's address: D. Pineo, Kingsbury Hall, 33 Academic Way, Durham,
-% N.H. 03824; email: dspineo@comcast.net; Colin Ware, Jere A. Chase
-% Ocean Engineering Lab, 24 Colovos Road, Durham, NH 03824; email:
-% cware@ccom.unh.edu;
-% Sean Fogarty, (Current address) NASA Ames Research Center, Moffett
-% Field, California 94035.}
+% \authorsaddresses{%
+%  Authors' addresses: G.~Zhou, Computer Science Department, College of
+%  William and Mary, 104 Jameson Rd, Williamsburg, PA 23185, US;
+%  V.~B\'eranger, Inria Paris-Rocquencourt, Rocquencourt, France;
+%  A.~Patel, Rajiv Gandhi University, Rono-Hills, Doimukh, Arunachal
+%  Pradesh, India; H.~Chan, Tsinghua University, 30 Shuangqing Rd,
+%  Haidian Qu, Beijing Shi, China; T.~Yan, Eaton Innovation Center,
+%  Prague, Czech Republic; T.~He, C.~Huang, J.~A.~Stankovic University
+%  of Virginia, School of Engineering Charlottesville, VA 22903, USA;
+%  T. F. Abdelzaher, (Current address) NASA Ames Research Center,
+%  Moffett Field, California 94035.}
 % \end{verbatim}
-%
-% It is expected that this command is inserted by the author of the
-% manuscript.
+% You can \emph{suppress} printing authors' addresses by setting them
+% to an empty string:  |\authorsaddresses{}|.   
 %
 % \DescribeMacro{\titlenote}%
 % \DescribeMacro{\subtitlenote}%
@@ -1230,18 +1259,10 @@
 % \end{description}
 %
 %
-% These definitions are in the separate style file |acmthm.sty|, which
-% is loaded by default.  However, sometimes the user might want to
-% delay loading this package, for example, if she wants for load
-% package like |cleveref| first.  In this case use the option
-% |acmthm=false| in the preamble, for example,
-% \begin{verbatim}
-% \documentclass[acmsmall, acmthm=false]{acmart}
-% \usepackage{cleveref}
-% \usepackage{acmthm}
-% \end{verbatim}
-% 
-%
+% These environments are defined by default.  In the unusual
+% circumstance that a user does not wish to have these environments
+% defined, the option |acmthm=false| in the preamble will suppress
+% them.
 %
 %\subsection{Online-only and offline-only material}
 %\label{sec:ug_screen}
@@ -1629,8 +1650,7 @@
 \ProvidesFile{acmart.dtx}
 %</gobble>
 %<class>\ProvidesClass{acmart}
-%<acmthm>\ProvidesPackage{acmthm}
-[2017/08/15 v1.45 Typesetting articles for Association of
+[2017/08/29 v1.46 Typesetting articles for Association of
 Computing Machinery]
 %    \end{macrocode}
 %
@@ -1697,6 +1717,10 @@ Computing Machinery]
 % \changes{v1.44}{2017/07/30}{Added package refcount}
 % \changes{v1.44}{2017/07/30}{Deleted package cleveref}
 % \changes{v1.44}{2017/07/30}{Put theorem defs in a separate style}
+% \changes{v1.46}{2017/08/17}{Bst file bug fixes: label width is
+% calculated correctly}
+% \changes{v1.46}{2017/08/25}{Added etoolbox}
+% \changes{v1.46}{2017/08/29}{Restore theorem defs to class file}
 %
 %
 % And the driver code:
@@ -1790,7 +1814,8 @@ Computing Machinery]
 %
 % \begin{macro}{\if@ACM@acmthm}
 % \changes{v1.44}{2017/07/30}{Added macro}
-%   Whether we load |acmthm|
+% \changes{v1.46}{2017/08/29}{Modified description}
+%   Whether we define theorem-like environments.
 %    \begin{macrocode}
 \define@boolkey+{acmart.cls}[@ACM@]{acmthm}[true]{%
   \if@ACM@acmthm
@@ -2039,6 +2064,11 @@ Computing Machinery]
 \RequirePackage{microtype}
 %    \end{macrocode}
 %
+% We need |etoolbox| for delayed code
+%    \begin{macrocode}
+\RequirePackage{etoolbox}
+%    \end{macrocode}
+% 
 %
 % We need |totpages| package to calculate the number of pages and
 % |refcount| to use the number
@@ -2350,6 +2380,8 @@ Computing Machinery]
 %
 % And |hyperref|
 % \changes{v1.28}{2017/01/07}{Got rid of warnings in pdf keywords}
+% \changes{v1.46}{2017/08/25}{Delayed hypersetup since journal options
+% may change screen mode}
 %    \begin{macrocode}
 \let\@footnotemark@nolink\@footnotemark
 \let\@footnotetext@nolink\@footnotetext
@@ -2374,15 +2406,16 @@ Computing Machinery]
 \or % sigchi-a
   \urlstyle{sf}
 \fi
-\if@ACM@screen
-  \hypersetup{colorlinks,
-    linkcolor=ACMRed,
-    citecolor=ACMPurple,
-    urlcolor=ACMDarkBlue,
-    filecolor=ACMDarkBlue}
-\else
-  \hypersetup{hidelinks}
-\fi
+\AtEndPreamble{%
+  \if@ACM@screen
+    \hypersetup{colorlinks,
+      linkcolor=ACMRed,
+      citecolor=ACMPurple,
+      urlcolor=ACMDarkBlue,
+      filecolor=ACMDarkBlue}
+    \else
+    \hypersetup{hidelinks}
+  \fi}
 %    \end{macrocode}
 %
 % Bibliography mangling. 
@@ -2595,6 +2628,8 @@ Computing Machinery]
 %    \begin{macrocode}
 \RequirePackage{manyfoot}
 \SelectFootnoteRule[2]{copyrightpermission}
+\DeclareNewFootnote{authorsaddresses}
+\SelectFootnoteRule[2]{copyrightpermission}
 \DeclareNewFootnote{copyrightpermission}
 %    \end{macrocode}
 % 
@@ -2757,6 +2792,19 @@ Computing Machinery]
 \fi
 %    \end{macrocode}
 %
+% \begin{macro}{\liningnums}
+% \changes{v1.46}{2017/08/28}{Workaround for compatibility with fontspec} 
+% Libertine defines \cs{liningnums}, which makes fontspec unhappy.
+% While we do not use fontspec, some users do\dots
+%    \begin{macrocode}
+\let\liningnums\@undefined
+\AtEndPreamble{%
+  \DeclareTextFontCommand{\liningnums}{\libertineLF}}
+%    \end{macrocode}
+% 
+% \end{macro}
+%
+%
 % The SIGCHI extended abstracts are sans serif:
 %    \begin{macrocode}
 \if@ACM@sigchiamode
@@ -3023,6 +3071,7 @@ Computing Machinery]
 % \changes{v1.25}{2016/12/03}{Updated PACMPL}
 % \changes{v1.30}{2017/02/15}{Updated IMWUT and PACMPL}
 % \changes{v1.36}{2017/05/13}{Added PACMHCI journal options}
+% \changes{v1.46}{2017/08/25}{PACM now set screen to true}
 %
 % We use keyval interface to define journal title and relevant
 % information
@@ -3094,6 +3143,8 @@ Computing Machinery]
     Wearable and Ubiquitous Technologies}%  
   \def\@journalNameShort{Proc. ACM Interact. Mob. Wearable Ubiquitous Technol.}%
   \def\@permissionCodeOne{2474-9567}%
+  \@ACM@screentrue
+  \PackageInfo{\@classname}{Using screen mode due to \@journalCode}%
 \or % JACM
   \def\@journalName{Journal of the ACM}%
   \def\@journalNameShort{J. ACM}%
@@ -3121,14 +3172,20 @@ Computing Machinery]
   \def\@journalName{Proceedings of the ACM on Human-Computer Interaction}%
   \def\@journalName{Proc. ACM Hum.-Comput. Interact.}%
   \def\@permissionCodeOne{2573-0142}%
+  \@ACM@screentrue
+  \PackageInfo{\@classname}{Using screen mode due to \@journalCode}%
 \or % PACMPL
   \def\@journalName{Proceedings of the ACM on Programming Languages}%
   \def\@journalName{Proc. ACM Program. Lang.}%
   \def\@permissionCodeOne{2475-1421}%
+  \@ACM@screentrue
+  \PackageInfo{\@classname}{Using screen mode due to \@journalCode}%
 \or % POMACS
   \def\@journalName{Proceedings of the ACM on Measurement and Analysis of Computing Systems}%
   \def\@journalName{Proc. ACM Meas. Anal. Comput. Syst.}%
   \def\@permissionCodeOne{2476-1249}%
+  \@ACM@screentrue
+  \PackageInfo{\@classname}{Using screen mode due to \@journalCode}%
 \or % TAAS
   \def\@journalName{ACM Transactions on Autonomous and Adaptive Systems}%
   \def\@journalNameShort{ACM Trans. Autonom. Adapt. Syst.}%
@@ -3384,6 +3441,19 @@ Computing Machinery]
 %
 % \end{macro}
 %
+% \begin{macro}{\num@authors}
+% \changes{v1.46}{2017/08/27}{Introduced macro}
+%   The total number of authors.
+%    \begin{macrocode}
+\newcount\num@authors
+\num@authors=0\relax
+%    \end{macrocode}
+%
+% \end{macro}
+%
+%
+%
+%
 % \begin{macro}{\if@insideauthorgroup}
 % \changes{v1.15}{2016/06/25}{Introduced macro}
 %  Whether we are continuing an author group
@@ -3393,9 +3463,11 @@ Computing Machinery]
 %
 % \begin{macro}{\author}
 % \changes{v1.15}{2016/06/25}{Added code for author groups}
+% \changes{v1.46}{2017/08/27}{Started counting authors}
 %   Adding an author to the list of authors and addresses
 %    \begin{macrocode}
 \renewcommand\author[2][]{%
+  \global\advance\num@authors by 1\relax
   \if@insideauthorgroup\else
     \global\advance\num@authorgroups by 1\relax
     \global\@insideauthorgrouptrue
@@ -3512,7 +3584,15 @@ Computing Machinery]
 %   Right now we do not typeset orcids
 \def\orcid#1{\unskip\ignorespaces}
 % \end{macro}
-% 
+%
+% \begin{macro}{\authorsaddresses}
+% \changes{v1.46}{2017/08/27}{Introduced macro}
+% Setting up authors' addresses
+\def\authorsaddresses#1{\def\@authorsaddresses{#1}}
+\authorsaddresses{\@mkauthorsaddresses}
+% \end{macro}
+%
+%
 % \begin{macro}{\@titlenotes}
 %   The titlenotes
 %    \begin{macrocode}
@@ -4368,6 +4448,8 @@ Computing Machinery]
 % \changes{v1.34}{2017/04/11}{Rearranged bibstrip}
 % \changes{v1.44}{2017/07/30}{Empty DOI or ISBN are not printed (by
 % Michael Ekstrand)} 
+% \changes{v1.46}{2017/08/27}{Added authors' addresses} 
+% \changes{v1.46}{2017/08/28}{Thankses go before authors' addresses} 
 %   The (in)famous \cs{maketitle}.  Note that in sigchi-a mode authors
 %   are \emph{not} in the title box.
 %
@@ -4401,9 +4483,17 @@ Computing Machinery]
   \let\@makefnmark\relax  \let\@thefnmark\relax
   \let\@makefntext\noindent
   \ifx\@empty\thankses\else
-    \footnotetextcopyrightpermission{%
+    \footnotetextauthorsaddresses{%
       \def\par{\let\par\@par}\parindent\z@\@setthanks}%
   \fi
+  \ifx\@empty\@authorsaddresses\else
+     \if@ACM@anonymous\else
+       \if@ACM@journal
+         \footnotetextauthorsaddresses{%
+           \def\par{\let\par\@par}\parindent\z@\@setauthorsaddresses}%
+       \fi
+     \fi
+  \fi
   \footnotetextcopyrightpermission{%
     \if@ACM@authordraft
         \raisebox{-2ex}[\z@][\z@]{\makebox[0pt][l]{\large\bfseries 
@@ -4521,6 +4611,7 @@ Computing Machinery]
 %
 % \begin{macro}{\@printtopmatter}
 % \changes{v1.06}{2016/05/01}{Added processing badges}
+% \changes{v1.46}{2017/08/29}{Deleted rule}
 %   The printing of top matter starts the new page, and uses the given
 %   title box.  Note that for sigchi-a we print badges here rather
 %   than in \cs{mktitle} since we want them on the margins.
@@ -4536,13 +4627,10 @@ Computing Machinery]
   \ifcase\ACM@format@nr
   \relax % manuscript
     \box\mktitle@bx\par
-    \noindent\hrulefill\par
   \or % acmsmall
     \box\mktitle@bx\par
-    \noindent\hrulefill\par
   \or % acmlarge
     \box\mktitle@bx\par
-    \noindent\hrulefill\par
   \or % acmtog
     \twocolumn[\box\mktitle@bx]%
   \or % sigconf
@@ -4816,6 +4904,7 @@ Computing Machinery]
 % \changes{v1.33}{2017/03/28}{Added obeypunctuation code}
 % \changes{v1.40}{2017/05/27}{Fixed bugs with extra spaces}
 % \changes{v1.43}{2017/07/11}{Added comma before country for journals}
+% \changes{v1.46}{Corrected spacing for institution}
 %   Theoretically we can define the macros for \cs{affiliation} inside
 %   the \cs{@mkauthors}-style commands.  However, this would lead to a
 %   strange error if an author uses them outside \cs{affiliation}.  Of
@@ -4825,10 +4914,10 @@ Computing Machinery]
 \def\postcode#1{\unskip\ignorespaces}
 \if@ACM@journal
   \def\position#1{\unskip\ignorespaces}
-  \def\institution#1{#1\ignorespaces}
+  \def\institution#1{\unskip~#1\ignorespaces}
   \def\city#1{\unskip\ignorespaces}
   \def\state#1{\unskip\ignorespaces}
-  \newcommand\department[2][0]{}
+  \newcommand\department[2][0]{\unskip\ignorespaces}
   \def\country#1{\if@ACM@affiliation@obeypunctuation\else, \fi#1\ignorespaces}
 \else
   \def\position#1{\if@ACM@affiliation@obeypunctuation#1\else#1\par\fi}%
@@ -5178,6 +5267,39 @@ Computing Machinery]
 %
 % \end{macro}
 %
+% \begin{macro}{\@mkauthorsaddresses}
+% \changes{v1.46}{2017/08/27}{Introduced macro}
+% Typesetting authors' addresses in the footnote style
+\def\@mkauthorsaddresses{%
+  \ifnum\num@authors>1\relax
+  Authors' \else Author's \fi
+  \ifnum\num@authorgroups>1\relax
+  addresses: \else address: \fi
+  \bgroup
+  \def\streetaddress##1{\unskip\@addpunct, ##1}%
+  \def\postcode##1{\unskip\@addpunct, ##1}%
+  \def\position##1{\unskip\ignorespaces}%
+  \def\institution##1{\unskip\@addpunct, ##1}%
+  \def\city##1{\unskip\@addpunct, ##1}%
+  \def\state##1{\unskip\@addpunct, ##1}%
+  \renewcommand\department[2][0]{\unskip\@addpunct, ##2}%
+  \def\country##1{\unskip\@addpunct, ##1}%
+  \def\and{\unskip\@addpunct; }%
+  \def\@author##1{##1}%
+  \def\email##1##2{\unskip\@addpunct, \nolinkurl{##2}}%
+  \addresses
+  \egroup}
+% \end{macro}
+%
+% \begin{macro}{\@setaddresses}
+%   This is an |amsart| macro, which we do not need.
+%    \begin{macrocode}
+\def\@setaddresses{}
+%    \end{macrocode}
+%
+% \end{macro}
+%
+%
 % \begin{macro}{\@authornotemark}
 % Adding footnotemark to authors.  This version adds ``normal''
 % footnotemark.
@@ -5210,14 +5332,6 @@ Computing Machinery]
 %
 % \end{macro}
 %
-% \begin{macro}{\@setaddresses}
-%   This is an |amsart| macro, which we do not need.
-%    \begin{macrocode}
-\def\@setaddresses{}
-%    \end{macrocode}
-%
-% \end{macro}
-%
 % \begin{macro}{\@mkabstract}
 % \changes{v1.19}{2016/07/28}{Include 'Abstract' in PDF bookmarks
 % (Matthew Fluet)}
@@ -5246,6 +5360,7 @@ Computing Machinery]
 % \changes{v1.34}{2017/04/09}{Deleted DOI from doi numbers}
 % \changes{v1.44}{2017/07/30}{If the paper has just one page, use
 % `page' instead of `pages'}
+% \changes{v1.46}{2017/08/25}{Added subtitle}
 %   Print bibcitation format
 %    \begin{macrocode}
 \def\@mkbibcitation{\bgroup  
@@ -5258,7 +5373,8 @@ Computing Machinery]
   \def\@article@string{\ifx\@acmArticle\@empty{\ }\else,
     Article~\@acmArticle\ \fi}%
   \par\medskip\small\noindent{\bfseries ACM Reference Format:}\par\nobreak
-  \noindent\authors. \@acmYear. \@title. 
+  \noindent\authors. \@acmYear. \@title
+  \ifx\@subtitle\@empty. \else: \@subtitle. \fi
   \if@ACM@journal
      \textit{\@journalNameShort}
      \@acmVolume, \@acmNumber \@article@string (\@acmPubDate), 
@@ -5270,37 +5386,18 @@ Computing Machinery]
      \fi\ 
      ACM, New York, NY, USA%
        \@article@string\unskip, \ref{TotPages}~\@pages@word.
-  \fi\par
-  \noindent\@formatdoi{\@acmDOI}
+  \fi
+  \@formatdoi{\@acmDOI}
 \par\egroup}
 %    \end{macrocode}
 %
 % \end{macro}
 %
 % \begin{macro}{\@printendtopmatter}
+% \changes{v1.46}{2017/08/28}{Made it \cs{par}\cs{bigskip} uniformly}
 %   End the top matter
 %    \begin{macrocode}
-\def\@printendtopmatter{\par\medskip
-  \ifcase\ACM@format@nr
-  \relax % manuscript
-    \noindent\hrulefill\par\medskip
-  \or % acmsmall
-    \noindent\hrulefill\par\medskip
-  \or % acmlarge
-    \noindent\hrulefill\par\medskip
-  \or % acmtog
-    \par\bigskip
-  \or % sigconf
-    \par\bigskip
-  \or % siggraph
-    \par\bigskip
-  \or % sigplan
-    \par\bigskip
-  \or % sigchi
-    \par\bigskip
-  \or % sigchi-a
-  \fi
-}
+\def\@printendtopmatter{\par\bigskip}
 %    \end{macrocode}
 %
 % \end{macro}
@@ -5313,6 +5410,14 @@ Computing Machinery]
 %
 % \end{macro}
 %
+% \begin{macro}{\@setauthorsaddresses}
+% \changes{v1.46}{2018/08/25}{Introduced macro}
+%    \begin{macrocode}
+\def\@setauthorsaddresses{\@authorsaddresses\unskip\@addpunct.}
+%    \end{macrocode}
+%
+% \end{macro}
+%
 %
 %
 %\subsection{Headers and Footers}
@@ -5327,6 +5432,8 @@ Computing Machinery]
 % \changes{v1.34}{2017/04/10}{Rulers now are continuous}
 % \changes{v1.40}{2017/05/27}{Work around a bug in xcolor: looks like
 % cmyk colors in boxes do not work}
+% \changes{v1.46}{2017/08/28}{Rearranged the code to get rid of
+% spurious underfull messages (Benjamin Byholm)}
 %   This is the box displayed in the review mode
 %    \begin{macrocode}
 \if@ACM@review
@@ -5336,11 +5443,13 @@ Computing Machinery]
   \ACM@linecount\@ne\relax
   \def\ACM@mk@linecount{%
     \savebox{\ACM@linecount@bx}[4em][t]{\parbox[t]{4em}{%
-        \setlength{\ACM@linecount@bxht}{-\baselineskip}%
+        \setlength{\ACM@linecount@bxht}{0pt}%
         \loop{\color{red}\scriptsize\the\ACM@linecount}\\
         \global\advance\ACM@linecount by \@ne
         \addtolength{\ACM@linecount@bxht}{\baselineskip}%
-        \ifdim\ACM@linecount@bxht<\textheight\repeat}}}
+        \ifdim\ACM@linecount@bxht<\textheight\repeat
+        {\color{red}\scriptsize\the\ACM@linecount}\hfill
+        \global\advance\ACM@linecount by \@ne}}}
 \fi
 %    \end{macrocode}
 %
@@ -5796,18 +5905,9 @@ Computing Machinery]
 %\subsection{Theorems}
 %\label{sec:theorems}
 %
-% The conditional loading
-%    \begin{macrocode}
-\if@ACM@acmthm
-  \RequirePackage{acmthm}
-\fi
-%    \end{macrocode}
-% 
 % \begin{macro}{\@acmplainbodyfont}
 %   The font to typeset the |acmplain| theorem style body.
 %    \begin{macrocode}
-%</class>
-%<*acmthm>
 \def\@acmplainbodyfont{\itshape}
 %    \end{macrocode}
 %
@@ -5944,18 +6044,49 @@ Computing Machinery]
 %
 % \end{macro}
 %
-% The definitions for theorems:
+% Make |acmplain| the default theorem style.
 %    \begin{macrocode}
 \theoremstyle{acmplain}
-\newtheorem{theorem}{Theorem}[section]
-\newtheorem{conjecture}[theorem]{Conjecture}
-\newtheorem{proposition}[theorem]{Proposition}
-\newtheorem{lemma}[theorem]{Lemma}
-\newtheorem{corollary}[theorem]{Corollary}
-\theoremstyle{acmdefinition}
-\newtheorem{example}[theorem]{Example}
-\newtheorem{definition}[theorem]{Definition}
-\theoremstyle{acmplain}
+%    \end{macrocode}
+%
+% Delay defining the theorem environments until after other packages
+% have been loaded.  In particular, the |cleveref| package must be
+% loaded before the theorem environments are defined in order to show
+% the correct environment name (see
+% https://github.com/borisveytsman/acmart/issues/138).  The |acmthm|
+% option is used to suppress the definition of any theorem
+% environments.  Also, to avoid obscure errors arising from these
+% environment definitions conflicting with environments defined by the
+% user or by user-loaded packages, we only define environments that
+% have not yet been defined.
+%    \begin{macrocode}
+\AtEndPreamble{%
+  \if@ACM@acmthm
+  \theoremstyle{acmplain}
+  \@ifundefined{theorem}{%
+  \newtheorem{theorem}{Theorem}[section]
+  }{}
+  \@ifundefined{conjecture}{%
+  \newtheorem{conjecture}[theorem]{Conjecture}
+  }{}
+  \@ifundefined{proposition}{%
+  \newtheorem{proposition}[theorem]{Proposition}
+  }{}
+  \newtheorem{lemma}[theorem]{Lemma}
+  \@ifundefined{lemma}{}{}
+  \@ifundefined{corollary}{%
+  \newtheorem{corollary}[theorem]{Corollary}
+  }{}
+  \theoremstyle{acmdefinition}
+  \@ifundefined{example}{%
+  \newtheorem{example}[theorem]{Example}
+  }{}
+  \@ifundefined{definition}{%
+  \newtheorem{definition}[theorem]{Definition}
+  }{}
+  \fi
+  \theoremstyle{acmplain}
+}
 %    \end{macrocode}
 %
 %
@@ -6004,8 +6135,6 @@ Computing Machinery]
 }{%
   \popQED\endtrivlist\@endpefalse
 }
-%</acmthm>
-%<*class>
 %    \end{macrocode}
 %
 % \end{macro}
@@ -6056,6 +6185,7 @@ Computing Machinery]
 %
 % We use the |comment| package for conditional typesetting:
 %    \begin{macrocode}
+\AtEndPreamble{%
 \if@ACM@screen
   \includecomment{screenonly}
   \excludecomment{printonly}
@@ -6068,7 +6198,7 @@ Computing Machinery]
   \excludecomment{acks}
 \else
   \includecomment{anonsuppress}
-\fi
+\fi}
 %    \end{macrocode}
 %
 %
-- 
cgit v1.2.3

