% -----------------------------*- LaTeX -*------------------------------
%
%   fixacm.sty -- Fix ACM's brain-damaged and ugly proceedings package
%   
%   Jeff Erickson (jeffe@cs.uiuc.edu)
%   Last modified 22 Mar 2011
%   Latest version at http://www.cs.uiuc.edu/~jeffe/pubs/tex/fixacm.sty
%
%   This is free; caveat emptor!  Comments welcome.
%
% ----------------------------------------------------------------------
%   ****IMPORTANT****   ****IMPORTANT****   ****IMPORTANT****
%
%   ALWAYS DELETE ANY MENTION OF FIXACM FROM ANY .TEX FILE YOU
%	SUBMIT TO SHERIDAN/ACM!
%
%	Sheridan, ACM’s publication subcontractor, WILL block your paper
%   from publication or inclusion in the ACM Digital Library if
%   your submitted a .tex file includes the line “\usepackage{fixacm}”.
%	On the other hand, they don’t seem to care whether the submitted
%   .tex and .pdf files are actually consistent.  (I regularly submit
%	.tex files with the entire body text replaced with a single line:
%	“See the pdf file for the text.”)
%
%   Before submitting your .tex file, but after compiling your final
%	camera-ready .pdf file, *DELETE* the line “\usepackage{fixacm}”
%	from your .tex file.  (Commenting it out might also work, but I
%	haven’t tried that.)
%
%   ****IMPORTANT****   ****IMPORTANT****   ****IMPORTANT****
% ----------------------------------------------------------------------
%
%   ACM, in its infinite wisdom, requires authors to use an
%   uneditable document class file.  The results of using this class
%   file are ugly.  Embarassingly ugly.  In short, ACM designed an
%   ugly Microsoft Word template and then hacked some LaTeX --
%   badly -- to produce approximately the same results.  The style is
%   poorly designed, and the design is poorly implemented; the
%   implementation is both buggy and inelegant.  Seeing code this
%   awful does not inspire much faith in “the premiere society for
%   computing professionals”.
%
%   This package tries to counter most of ACM's horrible decisions,
%   without being so different that they actually notice.
%
%   + Allow arbitrarily many authors on the title page.  ACM decided
%     that at most three authors (or with some sanctioned hacking, at
%     most six) should appear on the front page, with everyone else
%     relegated to an ``Additional authors'' section at the end of
%     the paper.  Naturally, people like me with the occasional
%     10-author paper were deeply offended.  (You can also avoid this
%     limit simply by using \and instead of \alignauthor.
%
%   + No hardwired fonts!  If you like Times, you'll get Times.  If
%     you prefer Computer Modern, you'll get Computer Modern.  If you 
%     like Concrete, you'll get Concrete.  And so on.  The only
%     exception is the copyright notice at the bottom of page 1, which
%     is left in Times Roman so as not to attract lawyers' attention,
%     and (with the [obey] option) the title, authors, and affiliations.
%
%     To be fair to ACM, their style does look better (but still bad)
%     if the document is typeset using Times or Times New Roman instead
%     of Computer Modern.  To do this, I recommend \usepackage{txfonts}
%     rather than \usepackage{times}, which still uses Computer Modern
%     to typeset mathematics, or \usepackage{mathtime}, which seems to
%     interact badly with either type-1 fonts or AMS math packages, at
%     least on my system (TeXShop 1.37 + teTeX).
%
%   + Make the required metadata sections (keywords, subject descriptors,
%     general terms) less visually obnoxious.
%
%   + Make captions less visually obnoxious.
%
%   + Restore standard LaTeX bibliography appearance (justified text,
%     proper line spacing, etc.)  The ostensible reason for ragged
%     right was to avoid bad line breaks around URLs, but this is
%     much better done using the url or hyperref packages, which
%     intelligently breaks URLs across line boundaries.  **SHERIDAN
%	  OBJECTS TO THIS CHANGE.**
%
%   + Use consistent spacing after section headings, especially when
%     immediately followed by theorems.
%
%   + Make footnotes smaller than normal text (but not \small text).
%
%   + Make \large, \Large, etc. type (for example, in titles and
%     section headers) slightly smaller than LaTeX's default, which is
%     too big for 10pt type anyway. 
%
%   + Don't set \parskip=0pt in section headers and bibliography, which
%     forced columns to line up badly and occsionally split section
%     headers from following text.  Added slack in default parsep, but
%     this can easily be changed by the user.
%
%   + Typeset email addresses in normal text.  They're just like
%     phone numbers, people!
%
%   + Always put the end-of-proof symbol at the end of the line.
%
%   There are also several options to fix other bits of ugliness:
%
%   * ACM wants section headings in all caps; turn this feature off with
%     the [nocapsections] option.  All caps actually looks fine in Times,
%     but Computer Modern Bold Extended (the default LaTeX bold font) is
%     too wide to properly typeset all-caps headers more than 22 or 23
%     characters long.  (``Approximation algorithms'' is too long.)
%
%   * Alternately, use the [sfsections] option to typeset section and
%     subsection headings using the default sans-serif bold font,
%     matching the font used in the title (unless you use [obey]).
%
%   * ACM wants periods after section numbers; turn this feature off
%     with the [noperiods] option.
%
%   * To save space, the size of the bibliography text can be changed
%     with the options [smallbib], [smallerbib], [smallestbib], and
%     [tinybib].
%
%   For more minute changes, I recommend "jeffe.sty".
%
% ----------------------------------------------------------------------
%   Invoke as follows:
%	\docummentclass{sig-alternate}
%	\usepackage[OPTIONS]{fixacm}
%
%   OPTIONS:
%   [nocapsections]
%       Don't capitalize section headings
%   [noperiods]
%       No periods after section headings
%   [sfsections]
%       Use sans serif bold for section headings (to mirror the title)
%   [smallbib]
%       Set bibliography in \small type
%   [smallerbib]
%       Set bibliography in \footnotesize type
%   [smallestbib]
%       Set bibliography in \striptsize type
%   [tinybib]
%       Set bibliography in \tiny type
%   [fnord]
%       Imminentize the eschaton
%   [obey]
%       Follow ugly ACM formatting guidelines for title and author fonts,
%       but apply all other changes.
%
% ----------------------------------------------------------------------
%   UNRESOLVED BUGS:
%
%   -- \vskip inside \author results in the error "Missing } inserted".
%      (Erik Demaine, Stefan Langerman, Monique Teillaud, 20 Mar 2004)
%
%   -- \\ and \linebreak don't work inside \thanks (or \titlenote).
%      (Monique Teillaud 24 Mar 2004)
%
% ----------------------------------------------------------------------
%
%   05 May 2011:
%   -- Added reminder/warning to REMOVE “\usepackage{fixacm}” from your
%	   .tex source before submitting it to Sheridan (after compiling
%	   your final camera-ready .pdf, of course).
%
%   22 Mar 2011:
%   -- Added font size/style commands so that title/author footnote
%      markers and math inside titles are typeset (more) correctly,
%      and author affiliations are typeset with consistent line
%      spacing.  (Math inside titles is still not quite perfect,
%      mostly because 18pt Helvetica is larger than 18pt Everything
%      Else.  Small caps inside titles still requires extra work.)
%
%   03 Apr 2006:
%   -- Added [obey] option to bypass ACM/Sheridan complaints.
%      Additional HaXing is required to typeset title/author footnote
%      markers correctly, to typeset math inside titles correctly, and
%      to get consistent spacing in author affiliations.
%
%   24 Mar 2004:
%   -- Replaced \edef with \protected@edef in \@sect to remove a
%      potential infinite loop caused by font changes in section
%      headings.  Thanks to Monique Teillaud and Jose Grim for finding
%      and fixing the bug.
%
%   18 Mar 2004:
%   -- Fixed \email bug.  Documents using \email were getting the error
%      ``Missing } inserted'' when \maketitle was invoked.  Thanks to
%      Stefan Langerman for the fix.  (Update 24 Mar 2004: Any use of
%      \vskip or \vspace inside the \author command will result in the
%      same error.  Don't.)
%
%   09 Mar 2004:
%   -- Heavily edited documentation
%   -- Removed three-author limitation.  This was surprisingly easy.
%   -- Removed limitation on number of \titlenote's.  Also easy.
%   -- Removed section spacing bug
%   -- Optionally remove all caps sections
%   -- Optionally remove periods after section numbers
%   -- Optionally typeset section headings in sans-serif to match title
%
%   15 Apr 2003:
%	-- Make required metadata sections less obnoxious.
%
%   20 Mar 2002:
%	-- Removed parskip=0pt from section headers
%	-- added 1pt stretch in parsep and itemsep in bibliography
%
%   17 Feb 2002:
%	-- Removed font command \subsubsecfnt from \thesubsubsection
%	   definition.  (Bug uncovered by Lars Arge, later fixed in
%      official style file.)
%
%   20 Mar 2001:
%	-- First version, written for SOCG 2001.
%
% ----------------------------------------------------------------------
\ProvidesPackage{fixacm}
\typeout{-----}
\typeout{FixACM package by Jeff Erickson, last modified 05 May 2011}
\typeout{Latest version at http://www.cs.uiuc.edu/\string~jeffe/pubs/tex/fixacm.sty}
\typeout{-----}
\typeout{REMOVE FIXACM FROM TEX SOURCE BEFORE SUBMITTING TO SHERIDAN!}
\typeout{-----}


%----------------------------------------------------------------------
%  DON'T USE HARDWIRED FONTS, YOU IDIOTS!
%  I'll make an exception for the legal blather on page 1.
%----------------------------------------------------------------------
% Duh.
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}

\def\secfnt{\Large\bfseries}\def\secit{\itshape}		% Sections and subsections
% ...Optionally in sans serif
\DeclareOption{sfsections}{\def\secfnt{\Large\bfseries\sffamily}\def\secit{\slshape}}

\def\subsecfnt{\large\itshape} \def\subsecit{\upshape}	% Subsubsections and paragraphs

\newif\iffix@uthors
\fix@uthorstrue
\DeclareOption{obey}{\fix@uthorsfalse}

\def\eaddfnt{\affaddr}\let\email\affaddr			% Email: just another address, dammit!

% Leave the copyright notice in Times Roman.  Grumble.
%\def\confname{\footnotesize\itshape}
%\def\crnotice{\footnotesize}

% ----------------------------------------------------------------------
%  Put as many authors and titlenotes as you want on the title page.
% ----------------------------------------------------------------------
\def\numberofauthors#1{}
\let\alignauthor\and
\let\titlenote\thanks

% ----------------------------------------------------------------------
%  Make footnotetext smaller and tighter than normal text.  This could
%  probably use some tweaking.
% ----------------------------------------------------------------------
\def\footnotesize{\@setsize\footnotesize{9pt}\viiipt\@viiipt
\abovedisplayskip 6.4pt plus 2pt minus 4pt%
\belowdisplayskip \abovedisplayskip
\abovedisplayshortskip \z@ plus 1pt%
\belowdisplayshortskip 2.7pt plus 1pt minus 2pt
\def\@listi{\leftmargin\leftmargini %% Added 22 Dec 87
\topsep 3pt plus 1pt minus 1pt\parsep 2pt plus 1pt minus 1pt
\itemsep \parsep}}

% ----------------------------------------------------------------------
%  Make large text smaller.  It was already too big for 10 point text.
% ----------------------------------------------------------------------
\gdef\large{\@setsize\large{12pt}\xpt\@xpt}
\gdef\Large{\@setsize\large{14pt}\xiipt\@xiipt}
\gdef\LARGE{\@setsize\Large{18pt}\xivpt\@xivpt}
\gdef\huge{\@setsize\LARGE{22pt}\xviipt\@xviipt}
\gdef\Huge{\@setsize\huge{25pt}\xxpt\@xxpt}

% ----------------------------------------------------------------------
%  Optionally don't capitalize section titles!  (This option should
%  probably also change the appearance of subsections, but it doesn't.)
% ----------------------------------------------------------------------
\DeclareOption{nocapsections}
{\def\section{%
    \@startsection{section}{1}{\z@}%
    {-10\p@ plus -4\p@ minus -2\p@}%
    {4\p@ plus 2\p@}{\baselineskip 14pt\secfnt}}
}

%----------------------------------------------------------------------
%  Don't override \parskip in section headers.
%----------------------------------------------------------------------
\def\@startsection#1#2#3#4#5#6{%
        \if@noskipsec  %gkmt, 11 aug 99
        \global\let\@period\@empty
        \leavevmode
        \global\let\@period.%
    \fi
      \par %
    \@tempskipa #4\relax
    \@afterindenttrue
    \ifdim \@tempskipa <\z@
        \@tempskipa -\@tempskipa
        \@afterindentfalse
    \fi
    \if@nobreak
    \everypar{}%
    \else
        \addpenalty\@secpenalty
        \addvspace\@tempskipa
    \fi
    \@ifstar
        {\@ssect{#3}{#4}{#5}{#6}}
        {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}%
}

%----------------------------------------------------------------------
%  Restore latex-default section heading layout to fix spacing bugs,
%  but optionally leave in ACM's HaXing to capitalize section headings
%  and put periods after section numbers.  (Sigh.)
%----------------------------------------------------------------------
\def\ACMperiod{.}
\DeclareOption{noperiods}{\def\ACMperiod{\null}}

\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
% \begin{ACMhackery}
        \protected@edef\@svsec{% 	protection added 24 Mar 2004 <jeffe>
            \begingroup
			\ifnum#2>2 \noexpand#6 \fi
                \csname the#1\endcsname
            \endgroup
            \ifnum #2=1\relax\ACMperiod\fi
            \hskip 1em
        }%
% \end{ACMhackery}
  \fi
  \@tempskipa #5\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #6{%
        \@hangfrom{\hskip #3\relax\@svsec}%
          \interlinepenalty \@M 
% \begin{ACMhackery}
          \if@uchead\uppercase{#8}\else #8\fi
% \end{ACMhackery}
          \@@par}%
    \endgroup
    \csname #1mark\endcsname{#7}%
    \addcontentsline{toc}{#1}{%
      \ifnum #2>\c@secnumdepth \else
        \protect\numberline{\csname the#1\endcsname}%
      \fi
      #7}%
  \else
    \def\@svsechd{%
      #6{\hskip #3\relax
      \@svsec #8}%
      \csname #1mark\endcsname{#7}%
      \addcontentsline{toc}{#1}{%
        \ifnum #2>\c@secnumdepth \else
          \protect\numberline{\csname the#1\endcsname}%
        \fi
        #7}}%
  \fi
  \@xsect{#5}}


% ----------------------------------------------------------------------
%  Make required metadata sections less obnoxious.
% ----------------------------------------------------------------------
\def\keywords{\par\medskip\noindent\textbf{Keywords:~}}

\def\terms{\par\medskip\noindent\textbf{General Terms:~}}

\def\category#1#2#3{%
\ifnum\catcount=1
\par\bigskip\noindent\textbf{Categories and Subject Descriptors:~}
\advance\catcount by 1\else{\unskip; }\fi
    \@ifnextchar [{\@category{#1}{#2}{#3}}{\@category{#1}{#2}{#3}[]}%
}

\def\@category#1#2#3[#4]{%
    \begingroup
        \let\and\relax
            #1 [#2]%
            \if!#4!%
                \if!#3!\else : #3\fi
            \else
                :\space
                \if!#3!\else #3\kern\z@---\hskip\z@\fi
                \textit{#4}%
            \fi
    \endgroup
}

%----------------------------------------------------------------------
%  Restore the standard bibliography look and feel.  Make the
%  bibliography a subsection to save space, and optionally set the
%  bibliography in smaller type.  Allow 1pt stretch in itemsep and
%  parsep to help align columns.
%----------------------------------------------------------------------
\def\bibsize#1{\def\@bibsize{#1}}

\def\thebibliography#1{%
\ifnum\addauflag=0\addauthorsection\global\addauflag=1\fi
    \subsection*{References}
    \@bibsize
    \list{[\arabic{enumi}]}{%
        \settowidth\labelwidth{[#1]}%
        \leftmargin\labelwidth
        \advance\leftmargin\labelsep
        \advance\leftmargin\bibindent
        \parsep=0pt plus 1pt
	\itemsep=0pt plus 1pt
        \itemindent -\bibindent
        \listparindent \itemindent
        \usecounter{enumi}
    }%
    \let\newblock\@empty
    \sloppy
    \clubpenalty4000
    \@clubpenalty \clubpenalty
    \widowpenalty4000%
    \sfcode`\.=1000\relax
}

\DeclareOption{smallbib}{\bibsize{\small}}
\DeclareOption{smallerbib}{\bibsize{\footnotesize}}
\DeclareOption{smallestbib}{\bibsize{\scriptsize}}
\DeclareOption{tinybib}{\bibsize{\tiny}}
\bibsize{\normalsize}

% ----------------------------------------------------------------------
%  Make captions smaller than the text, make their titles bold.
%  Arguments:   #1 == figure name: "Figure 5"
%               #2 == caption: "Papers by \Erdos, 1900--2000 (projected)"
%  Less space after floats and before caption, since captions are smaller
% ----------------------------------------------------------------------
\@ifundefined{abovecaptionskip}{\newlength\abovecaptionskip}
\long\def\@makecaption#1#2{
   \vskip \abovecaptionskip
   \setbox\@tempboxa\hbox{{\sf\footnotesize \textbf{#1.} #2}}
   \ifdim \wd\@tempboxa >\hsize              % IF longer than one line:
       {\sf\footnotesize \textbf{#1.} #2\par}% THEN set as ordinary paragraph.
     \else                                   %   ELSE  center.
       \hbox to\hsize{\hfil\box\@tempboxa\hfil}
   \fi}
\dbltextfloatsep 18pt plus 2pt minus 4pt % was 20pt plus 2pt minus 4pt
\textfloatsep 18pt plus 2pt minus 4pt    % was 20pt plus 2pt minus 4pt
\abovecaptionskip 6pt                    % was 10pt

% ----------------------------------------------------------------------
%  Put the end-of-proof symbol at the end of the line.  [The \@qededtrue
%  preventsnested proofs from ending in two end-of-proof symbols, for
%  example if a \qed is added explicitly at the end of a list or equation.
% ----------------------------------------------------------------------
\def\QEDbox{\begingroup\unitlength\p@\linethickness{.4\p@}\framebox(6,6){}\endgroup}
\def\qed{\unskip\nobreak\qquad\hfill\QEDbox\global\@qededtrue}

% ----------------------------------------------------------------------
%  Fix the puncutation errors in the copyright notice:
%  - serial comma before `or' in list of three or more.
%  - no comma between subject and verb, even if subject is a phrase.
%  Reduce the copyright clearance fee.  50 cents per page is too much!
% ----------------------------------------------------------------------
\DeclareOption{fnord}
{
\permission{Permission to make digital or hard copies of all or part
of this work for personal or classroom use is granted without fee,
provided that copies are not made or distributed for profit or
commercial advantage and that copies bear this notice and the full
citation on the first page.  To copy otherwise, to republish, to post
on servers, or to redistribute to lists requires prior specific
permission and/or a fee.  So there.}
\global\copyrightetc{Copyright \the\copyrtyr\ ACM \the\acmcopyr\ \dots \$4.99}
}

\def\newprice#1
{\global\copyrightetc{Copyright \the\copyrtyr\ ACM \the\acmcopyr\ \dots \${#1}}}


% ----------------------------------------------------------------------
%  Tweak: Allow some slack between paragraphs to help balance columns
% ----------------------------------------------------------------------
\parskip 2pt plus 1pt minus 2pt

\ProcessOptions

% ----------------------------------------------------------------------
%  Use normal LaTeX fonts if [obey] option is not invoked.  But force
%  font, size, and style changes even when [obey] is invoked, so that
%  footnote markers, math, and the like are typeset (more) correctly
% ----------------------------------------------------------------------

\iffix@uthors
	\let\XXttlfnt\relax
	\let\XXttlit\relax
	\let\XXsubttlfnt\relax
	\let\XXsubttlit\relax
	\let\XXsubttlbf\relax
	\let\XXaufnt\relax
	\let\XXauit\relax
	\let\XXaffaddr\relax
	\let\XXaffaddrit\relax
\else
	\newfont{\XXttlfnt}{phvb8t at 18pt}
	\newfont{\XXttlit}{phvbo8t at 18pt}
	\newfont{\XXsubttlfnt}{phvr8t at 14pt}
	\newfont{\XXsubttlit}{phvro8t at 14pt}
	\newfont{\XXsubttlbf}{phvb8t at 14pt}
	\newfont{\XXaufnt}{phvr8t at 12pt}
	\newfont{\XXauit}{phvro8t at 12pt}
	\newfont{\XXaffaddr}{phvr8t at 10pt}
	\newfont{\XXaffaddrit}{phvro8t at 10pt}
\fi

\def\ttlfnt{\Huge\sffamily\bfseries\XXttlfnt}	% Title
\def\ttlit{\itshape\XXttlit}						% italic
\def\subttlfnt{\Large\sffamily\XXsubttlfnt}	% Subtitle
\def\subttlit{\itshape\XXsubttlit}				% italic
\def\subttlbf{\bfseries\XXsubttlbf}				% bold
\def\aufnt{\large\XXaufnt}					% Author
\def\auit{\itshape\XXauit}						% italic
\def\affaddr{\normalsize\XXaffaddr}				% Author address
\def\affaddrit{\itshape\XXaffaddrit}				% italic

%\iffix@uthors
%	\def\ttlfnt{\huge\sffamily\bfseries}	% Title
%	\def\ttlit{\itshape}						% italic
%	\def\subttlfnt{\Large\sffamily}		% Subtitle
%	\def\subttlit{\itshape}					% italic
%	\def\subttlbf{\bfseries}					% bold
%	\def\aufnt{\Large}					% Author
%	\def\auit{\itshape}						% italic
%	\def\affaddr{\large}					% Author address
%	\def\affaddrit{\itshape}					% italic
%\else
%\fi

\endinput

-- 30 --
