%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                              %
%  CERN common style components                                %
%                                                              %
%  1.0  (12/05/2005)  MG                                       %
%    - Base on standard LaTeX2e report (11pt) class            %
%    - Automate smallcaps to section titles                    %
%  1.01 (22/05/2005)  MG                                       %
%    - Introduce commands for structural elements              %
%      (\Figure, \Eq, etc.)                                    %
%    - Introduce commands for abbreviations \eg, \ie, \etc     %
%    - Load a whole bunch of packages                          %
%  1.02 (21/06/2005)  MG                                       %
%    - Require textcomp, and multirow packages                 %
%  1.03 (04/07/2005)  MG                                       %
%    - \title   --> 14 pt lowercase bold (Large)               %
%    - \section --> 12 pt lowercase bold (large)               %
%    - \section and \subsection have \boldmath automated       %
%    - \partopskip in list = 3pt                               %
%    - \tableofcontents --> title in 14pt bold                 %
%    - Preface and Foreword environments: title in 14pt bold   %
%    - Include slashed package for generating slashed commands %
%  1.04 (10/07/2005)  MG                                       %
%    - \subsubsection bold itshape (+ boldmath)                % 
%    - \paragraph     itshape                                  %
%    - Add some utility commands, e.g., \Unit, \UGeV, \UGeVcc  %
%  1.05 (20/07/2005)  MG                                       %
%    - Add commands \rmd, \rme, \rmi                           % 
%  1.06 (24/07/2005)  MG                                       %
%    - Add commands \Eref, \Fref, \Sref, \Tref                 % 
%  1.07 (25/07/2005)  MG                                       %
%    - Add commands \Ref, \Refs, \Bref                         % 
%  1.08 (28/07/2005)  MG                                       %
%    - Add working lengths \Mylena, \Mylenb, \Mylenc           % 
%  1.09 (30/07/2005)  MG                                       %
%    - Add momentum unit \UeVc, \UkeVc, \UMeVc, \UGeVc,        %
%                        \UTeVc, \UPeVc                        %
%  1.10 (31/07/2005)  MG                                       %
%    - Add description environment with adjustable item width  %
%         write \begin{description}[width]                     %
%  1.11 (02/08/2005)  MG                                       %
%    - Add toc layout parameters (make indent larger)          %
%    - Add verbatim environments (in small type)               %
%  1.12 (03/08/2005)  MG                                       %
%    - Add whole bunch of units                                %
%    - include packages heppennamescern and isotope            %
%  1.13 (04/08/2005)  MG                                       %
%    - Add variants of units (trailing 'z') without seperating %
%      space in front (in case no value is needed)             %
%  1.14 (05/08/2005)  MG                                       %
%    - Add many more units (from SI manual)                    %
%    - Add variant for basic unit with optional parameter      %
%      to construct any multiple, e.g. \Um --> \Um[k] = \Ukm   %
%  1.15 (08/08/2005)  MG                                       %
%    - \U commands without preceding space now end in Z        %
%  1.16 (10/08/2005)  MG                                       %
%    - Add command \@makeschapterhead to typeset chapter*      %
%  1.17 (11/08/2005)  MG                                       %
%    - Mod in l@chapter (wider width for \numberline           %
%  1.18 (23/08/2005)  MG                                       %
%    - Typeset figure and table captions identifying part in   %
%      bold, i.e., "Fig. 1:" and "Table 1.:" (1 is an example) %
%  1.19 (13/09/2005)  MG                                       %
%    - Put units section into separate file (cernunits.sty)    %
%    - Replace reference to heppenamescern with heppennames2   %
%    - Simplifications in \maketitle (footnote, add page nb.)  %
%  1.20 (11/10/2005)  MG                                       %
%    - Add \SPp command: space before punctuation in math      %
%    - \appendix writes "Appendices"                           %
%    - \section inside appendices typesets, e.g.,              %
%      "A" instead of "Appendix A:"                            %
%  1.21 (19/10/2005)  MG                                       %
%    - Change loading of isotope package by cernchemsym        %
%    - Load dcolumn package                                    %
%    - Put \floatpagefraction to 0.8                           %
%  1.22 (27/10/2005)  MG                                       %
%    - Introduce mtpro option dependencies (\CERNMTPRO switch) %
%  1.23 (31/10/2005)  MG                                       %
%    - Add degree command (prints $\cicr$)                     %
%  1.24 (04/11/2005)  MG                                       %
%    - Remove upshape from definition of \section commands     %
%  1.25 (10/11/2005)  MG                                       %
%    - Make thereferences environment depend on \bibname       %
%      default: ``References''                                 %
%  1.26 (11/11/2005)  MG                                       %
%    - Load package arydshln (dashed lines)                    %
%  1.27 (17/11/2005)  MG                                       %
%    - Corrected bug (default \bibname was Bibliography        %
%      instead of References (see 1.25 above)                  %
%    - Define \appendix command with optional argument         %
%      whose default value is relax, but i can contain any     %
%      command that is executed first when \appendix is seen   %
%      i.e., \appendix --> \relax\section*{Appendices}         %
%            \appendix[newpage] --> \newpage\section*{...}     %
%  1.28 (18/12/2005)  MG                                       %
%    - Load package cernunits.sty (was in cernyrep before)     %
%    - Load package longtable.sty                              %
%  1.29 (13/01/2006)  MG                                       %
%    - set \appendixname --> Appendices                        %
%    - Introduce \appendixname into definition of \appendix    %
%  1.30 (14/02/2006)  MG                                       %
%    - correct bug in \section command (\boldmath not set)     %
%  1.31 (12/06/2006)  MG                                       %
%    - \listoftables  -->  "Tables"                            %
%    - \listoffigures -->  "Figures"                           %
%  1.32 (20/06/2006)  MG                                       %
%    - Introduce \minisanatize command (%$^~_&# normal)        %
%    - \Lit command like \texttt but with minisanatize         %
%  1.33 (23/06/2006)  MG                                       %
%    - Introduce Author list and Institute list commands       %
%    - \Instfoot to define institutes                          %
%      \Iref, IIref, IIIref to reference one, two or three     %
%    - \Anotfoot to define annotations                         %
%      \Aref, \AAref, \IAref, \IIAref for referencing          %
%      one or two annotation, or one or two institutes with    %
%      an annotation                                           %
%  1.34 (27/06/2006)  MG                                       %
%    - Eliminate comma at end of names in authorlist           %
%  1.35 (03/07/2006)  MG                                       %
%    - Eliminate cite from packages to be loaded               %
%      It is now loaded in cernmono.cls or cernyrep.cls        %
%  1.36 (19/05/2008)  MG                                       %
%    - Introduce command \Brefs (\Refs~\cite{...})             %
%  1.37 (06/01/2009)  MG                                       %
%    - Introduce command \Brefs, \Erefs, \Frefs, \Trefs        %
%                                                              %
%  Last Mod.: 06 Jan 2009 (MG)                                 %
%                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\fileversion{1.37}
\def\filedate{2009/01/06}
\def\docdate {2009/01/06}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cernall}%
    [\filedate\space CERN common LaTeX style components
                            (version\space\fileversion)]

\RequirePackage{longtable}
\RequirePackage{array,tabularx,dcolumn}%,arydshln}
\RequirePackage{textcomp,multirow}

%% If MathTime not loaded, get amssymb font definitions
\ifthenelse{\equal{\CERNMTPRO}{y}}
  {\RequirePackage{graphicx,url,amsmath}}
  {\RequirePackage{graphicx,url,bm,amsmath,amssymb}}

%\RequirePackage[sectionbib]{chapterbib}
\RequirePackage{slashed}
%\usepackage[notcite,color]{showkeys}
% Page Headings
\pagestyle{plain}

%%% Text font : Times Roman
\renewcommand{\rmdefault}{ptm}
 
%it uses the following info
%   \typist{..}  (may be filename) printed at top left of title page
%   \title{..}   
%   \author{..}
%   \date{..}  optional
%   \documentlabel{..}  printed at top right of title page
 
%%% Customization of visible document elements

\renewcommand\thesection      {\@arabic\c@section}
\renewcommand\thesubsection   {\thesection.\@arabic\c@subsection}
\renewcommand\thesubsubsection{\thesubsection.\@arabic\c@subsubsection}
\renewcommand\theparagraph{\thesubsubsection.\@arabic\c@paragraph}

\renewcommand\baselinestretch{1.}

\renewcommand{\contentsname}{Contents}
\renewcommand{\listfigurename}{Figures}
\renewcommand{\listtablename}{Tables}
\renewcommand{\bibname}{References}
\renewcommand{\indexname}{Index}
\renewcommand{\figurename}{Fig.}
\renewcommand{\tablename}{Table}
\renewcommand{\partname}{Part}
\renewcommand{\appendixname}{Appendices}
\renewcommand{\abstractname}{Abstract}

% 
%  **************************
%  *   List environements   *
%  **************************
%
 
% Prevent infinite loops
\let\Otemize =\itemize  
\let\Onumerate =\enumerate
\let\Oescription =\description
% Zero the vertical spacing parameters
\def\Nospacing{\itemsep=2pt\topsep=1pt\partopsep=1pt\parskip=0pt\parsep=2pt}
%\def\Nospacing{itemsep=2pt\topsep=0pt\partopsep=0pt\parskip=0pt\parsep=2pt}
% Redefine the environments in terms of the original values
\renewenvironment{itemize}{\vspace*{-1pt}\Otemize\Nospacing}
                          {\endlist\vspace*{-1pt}}
\renewenvironment{enumerate}{\vspace*{-1pt}\Onumerate\Nospacing}
                            {\endlist\vspace*{-1pt}}
%\renewenvironment{description}{\vspace*{-3mm}\Oescription\Nospacing}
%                              {\endlist\vspace*{-3mm}}
\renewcommand\labelitemi{\normalfont\textendash}
\renewcommand\labelitemii{\normalfont\textendash}
\renewcommand\labelitemiii{\textasteriskcentered}
\renewcommand\labelitemiv{\textperiodcentered}

%%% variable item width for description environment

\renewcommand\descriptionlabel[1]{\hspace\labelsep\descriptionfont #1\hfil}
\newcommand\descriptionfont{\bfseries}
\newcommand\descriptionmargin{}
\renewenvironment{description}[1][\kern\leftmargin]
     {\renewcommand\descriptionmargin{#1}%
      \xdescription
     }
     {\endlist}
\newcommand\xdescription[1][normal]
   {\list{}{\settowidth\leftmargin{\descriptionmargin}%
            \itemindent\z@
            \labelwidth\leftmargin
            \let\makelabel\descriptionlabel
            \itemsep=2pt\topsep=1pt\partopsep=1pt\parskip=0pt\parsep=2pt%
            }}

%
%  ****************************************
%  *       Appendix bookkeeping           *
%  ****************************************
%
 
\renewcommand\appendix[1][relax]{\csname #1\endcsname
  \section*{\appendixname}
  \setcounter{section}{0}%
  \setcounter{subsection}{0}%
  \setcounter{figure}{0}%
  \setcounter{table}{0}%
  \setcounter{equation}{0}%
%  \gdef\thesection{Appendix~\@Alph\c@section:}%
  \gdef\thesection{\@Alph\c@section}%
  \gdef\thesubsection{\@Alph\c@section.\@arabic\c@subsection}
  \gdef\theequation{\@Alph\c@section.\@arabic\c@equation}
  \@addtoreset {equation}{section}%
  \gdef\thetable{\@Alph\c@section.\@arabic\c@table}%
  \@addtoreset {table}{section}%
  \gdef\thefigure{\@Alph\c@section.\@arabic\c@figure}%
  \@addtoreset {figure}{section}%
}

% 
%  ************************************
%  *   thebibliography environement   *
%  ************************************
%

\setlength\bibindent{1.5em}
\def\BNospacing{\itemsep=2pt\topsep=1pt\partopsep=1pt\parskip=0pt\parsep=2pt}
\renewenvironment{thebibliography}[1]
     {\section*{\bibname}%
%      \addcontentsline{toc}{section}{\bibname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \BNospacing
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
\renewcommand\newblock{\hskip .11em\@plus.33em\@minus.07em}
\let\@openbib@code\@empty

% 
%  *******************
%  *   Frontmatter   *
%  *******************
%

\renewcommand\tableofcontents{\newpage
\begin{center}
  \Large\bfseries\contentsname\\[3mm]
\end{center}
\@starttoc{toc}%
}

\newenvironment{Abstract}
     {\newpage
      \begin{center}
        \large\bfseries\textsc{\abstractname}\\[3mm]
      \end{center}
      \begin{abstract}}
     {\end{abstract}}

\newenvironment{Foreword}
     {\newpage
      \begin{center}
        \Large\bfseries Foreword\\[3mm]
      \end{center}
      \par}
     {\par}

\newenvironment{Preface}
     {\newpage
      \begin{center}
        \Large\bfseries Preface\\[3mm]
      \end{center}
      \par}
     {\par}


%  ****************************************
%  *            PAGE LAYOUT               *
%  ****************************************
%
 
\textheight 24cm       % Height of text (including footnotes and figures,
                       % excluding running head and foot).
\textwidth 16cm        % Width of text line.
\topmargin -28pt       % offset of top header from voffset (1 inch)
\headheight 14pt     % offset of top header from voffset (1 inch)
%\topmargin -48pt       % offset of top header from voffset (1 inch)

%%%                     1in = 25.4 mm
%%%                     1pt = 0.376mm

%%% pagewidth           = 210 mm = 596 pt
%%% hoffset :           =   1 in =  72 pt
%%% textwidth           = 160 mm = 454 pt

% SIDE MARGINS:  %%%% A4 : pagewidth=160mm 
\if@twoside   % Values for two-sided printing:
      %%% margins : inner     =  30 mm =  79.78 pt
      %%%           outer     =  20 mm =  53.19 pt
      %%%           difference   10 mm =  26.59 pt 
      %%%           half difference    =  13.30 pt     
      %%% \odd/evensidemargin are with respect to hoffset -->
   \oddsidemargin   13.3pt  %   Left margin on odd-numbered pages.
   \evensidemargin -13.3pt  %   Left margin on even-numbered pages.
\else         % Values for one-sided printing:
   \oddsidemargin    0pt    %   Note that \oddsidemargin = \evensidemargin
   \evensidemargin   0pt
\fi

% PARAGRAPH INDENTATION
\setlength{\parindent}{1cm}
\setlength{\parskip}{3pt}
 
%    ****************************************
%    *             SECTIONS                 *
%    ****************************************
%
 
% \@startsection {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}
%            optional * [ALTHEADING]{HEADING}
%    Generic command to start a section.
%    NAME       : e.g., 'subsection'
%    LEVEL      : a number, denoting depth of section -- e.g., section=1,
%                 subsection = 2, etc.  A section number will be printed if
%                 and only if LEVEL < or = the value of the secnumdepth
%                 counter.
%    INDENT     : Indentation of heading from left margin
%    BEFORESKIP : Absolute value = skip to leave above the heading.
%                 If negative, then paragraph indent of text following
%                 heading is suppressed.
%    AFTERSKIP  : if positive, then skip to leave below heading,
%                       else - skip to leave to right of run-in heading.
%    STYLE      : commands to set style
%  If '*' missing, then increments the counter.  If it is present, then
%  there should be no [ALTHEADING] argument.  A sectioning command
%  is normally defined to \@startsection + its first six arguments.
 
%%% make footnote robust (if it appears in argument of, e.g., \section)
\let\oldfootnote\footnote
\def\footnote{\protect\oldfootnote}

%%% Level 1
\newcommand{\savesection}{\@startsection {section}{1}{\z@}%
                                   {-0.5cm \@plus -1ex \@minus -.2ex}%
                                   {0.3ex \@plus.2ex}%
                                   {\reset@font\normalsize\bfseries}}
\newcommand{\sectionstar}[1]{%\typeout{ **** #1 *****}%
                             \savesection*{\large\boldmath #1\unboldmath}}
\newcommand{\sectionnormal}[2][!?!]{\ifthenelse
                 {\equal{#1}{!?!}}{%\typeout{ @@@@@@ section #2 @@@@@@@}%
                                   \savesection[{#2}]%
                              {\large\boldmath #2\unboldmath}}
                                  {%\typeout{ @@@@@@ section [#1]#2 @@@@@@@}%
                                   \savesection[{#1}]%
                              {\large\boldmath #2\unboldmath}}}
\def\section{\@ifstar{\sectionstar}{\sectionnormal}}

%%% Level 2
\newcommand{\savesubsection}{\@startsection{subsection}{2}{\z@}%
                                     {-0.5cm \@plus -1ex \@minus -.2ex}%
                                     {0.1ex \@plus .2ex}%
                                     {\reset@font\normalsize\bfseries}}
\newcommand{\subsectionstar}[1]{%\typeout{ **** #1 *****}%
                             \savesubsection*{\boldmath #1\unboldmath}}
\newcommand{\subsectionnormal}[2][!?!]{\ifthenelse
                 {\equal{#1}{!?!}}{%\typeout{ @@@@@@ section #2 @@@@@@@}%
                                   \savesubsection[#2]%
                              {\boldmath #2\unboldmath}}
                                  {%\typeout{ @@@@@@ section [#1]#2 @@@@@@@}%
                                   \savesubsection[#1]%
                              {\boldmath #2\unboldmath}}}
\def\subsection{\@ifstar{\subsectionstar}{\subsectionnormal}}

%%% Level 3
\newcommand{\savesubsubsection}{\@startsection{subsubsection}{3}{\z@}%
                                     {-0.5cm \@plus -1ex \@minus -.2ex}%
                                     {0.1ex \@plus .2ex}%
                                     {\reset@font\normalsize\bfseries\itshape}}
\newcommand{\subsubsectionstar}[1]{%\typeout{ **** #1 *****}%
                             \savesubsubsection*{\boldmath #1\unboldmath}}
\newcommand{\subsubsectionnormal}[2][!?!]{\ifthenelse
                 {\equal{#1}{!?!}}{%\typeout{ @@@@@@ section #2 @@@@@@@}%
                                   \savesubsubsection[#2]%
                              {\boldmath #2\unboldmath}}
                                  {%\typeout{ @@@@@@ section [#1]#2 @@@@@@@}%
                                   \savesubsubsection[#1]%
                              {\boldmath #2\unboldmath}}}
\def\subsubsection{\@ifstar{\subsubsectionstar}{\subsubsectionnormal}}

%%% Level 4
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
                                     {-0.5cm \@plus -.2ex \@minus -.2ex}%
                                     {0.1ex \@plus .2ex}%
                                     {\reset@font\normalsize\itshape}}
\let\subsubsubsection\paragraph

%%% Level 5
% Fifth level generates run-in title
\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
                                       {3.25ex \@plus1ex \@minus .2ex}%
                                       {-1em}%
                                      {\reset@font\normalsize\bfseries}}


% The value of the counter secnumdepth gives the depth of the
% highest-level sectioning command that is to produce section numbers.
\setcounter{secnumdepth}{4}
 
\def\institute#1{\gdef\@institute{#1}}          % see \@maketitle
\gdef\@institute{\hbox{}}
% Redefine title block
\def\maketitle{\par
 \begingroup
%   \def\thefootnote{\arabic{footnote}}
   \def\thefootnote{\fnsymbol{footnote}}
%   \def\@makefnmark{\hbox
%       to 0pt{$^{\@thefnmark}$\hss}}
%   \if@twocolumn
%     \twocolumn[\@maketitle]
%     \else \newpage
     \global\@topnum\z@        % Prevents figures from going at top of page.
     \@maketitle \@thanks
 \endgroup
 \setcounter{footnote}{0}
 \let\maketitle\relax
 \let\@maketitle\relax
 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax}
\def\@maketitle{\begin{flushleft}
                    \baselineskip1.2\baselineskip\Large\bfseries \@title\par
                \end{flushleft}
                \mbox{}\\[-11mm]
                \begin{flushleft}
                    {\normalsize\itshape\@author}\\ 
                    {\normalsize\rmfamily\@institute}
                \end{flushleft}
                \thispagestyle{empty}
               }
%-----------------------------------------------------------------------
% The abstract Environment is modelled on the quotation environment
 
\def\abstract{\list{}{\listparindent 0pt
    \setlength{\leftmargin}{2cm}
%   \setlength{\topsep}{1pt}                              %EJNW 12/5/92
%   \setlength{\parsep}{1pt}                              %EJNW 12/5/92
%   \setlength{\partopsep}{1pt}                           %EJNW 12/5/92
    \itemindent\listparindent
    \rightmargin\leftmargin }\item[]{\bfseries Abstract}\\}
\let\endabstract=\endlist
%-----------------------------------------------------------------------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Floats                                                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Define caption layout %%%%%

\setlength\abovecaptionskip{2mm}
\setlength\belowcaptionskip{2mm}
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{{\small\textbf{#1:} #2}}%
  \ifdim \wd\@tempboxa >\hsize
    {\small\textbf{#1:} #2}\par
  \else
    \global \@minipagefalse
    \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}

\renewcommand{\bottomfraction}{0.3}
\renewcommand{\topfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.8}
\setcounter{topnumber}{5}
\setcounter{totalnumber}{6}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Table of contents layout                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.8em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.7em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.6em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{10em}{5.5em}}
\renewcommand*\l@subparagraph{\@dottedtocline{5}{12em}{6.5em}}
\renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{2.3em}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Verbatim environments (uses fancyvrb.sty)                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{fancyvrb}
%%%%%%%%%%%%%%%% User level commands and environments%%%%%%%%%%%%%%%%%%%%

\providecommand\verbfile[1]%
  {\VerbatimInput[fontsize=\small,xleftmargin=0pt]{#1}}

\DefineVerbatimEnvironment{verbatim}{Verbatim}
                          {fontsize=\small,xleftmargin=0pt}
% numbered
\DefineVerbatimEnvironment{nverbatim}{Verbatim}
  {fontsize=\small,numbers=left,xleftmargin=0pt}
\DefineVerbatimEnvironment{cverbatim}{Verbatim}{fontsize=\small,%
  firstnumber=continue,numbers=left,xleftmargin=0pt}
\DefineVerbatimEnvironment{nssverbatim}{Verbatim}
  {fontsize=\scriptsize,numbers=left,xleftmargin=0pt}
\DefineVerbatimEnvironment{nsscverbatim}{Verbatim}{fontsize=\scriptsize,%
  firstnumber=continue,numbers=left,xleftmargin=0pt}


%
\DefineVerbatimEnvironment{ssverbatim}{Verbatim}{fontsize=\scriptsize}
\DefineVerbatimEnvironment{fverbatim}{Verbatim}{fontsize=\footnotesize}
\DefineVerbatimEnvironment{tverbatim}{Verbatim}{fontsize=\tiny}
\DefineVerbatimEnvironment{sverbatim}{Verbatim}
                          {fontsize=\small}

% with commands recognized (\ { } have their usual TeX meaning)

\DefineVerbatimEnvironment{verbatimcmd}{Verbatim}
        {commandchars=\\\{\},fontsize=\small,xleftmargin=0pt}

\DefineVerbatimEnvironment{fverbatimcmd}{Verbatim}%
        {fontsize=\footnotesize,commandchars=\\\{\},xleftmargin=0pt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Equations                                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\allowdisplaybreaks

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                         %
%                          UTILITY COMMANDS                               %
%                                                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Roman letters for math formulae (diff. equations, constants i and e)   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\providecommand{\rmd}{\ensuremath{\mathrm{d}}}
\providecommand{\rme}{\ensuremath{\mathrm{e}}}
\providecommand{\rmi}{\ensuremath{\mathrm{i}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Transverse momentum and energy                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\providecommand{\pT}{\ensuremath{p\sb{\scriptstyle\mathrm{T}}}}
\providecommand{\ET}{\ensuremath{E\sb{\scriptstyle\mathrm{T}}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Names for structural elements and references to them                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% At beginning of sentence Figure, Equation, Reference should be spelled out
\providecommand*{\Eq}[1][s]{\ifthenelse{\equal{#1}{b}}{Equation}{Eq.}}
\providecommand*{\Eqs}[1][s]{\ifthenelse{\equal{#1}{b}}{Equations}{Eqs.}}
\providecommand*{\Figure}[1][s]{\ifthenelse
                                      {\equal{#1}{b}}{Figure}{Fig.}}
\providecommand*{\Figures}[1][s]{\ifthenelse
                                      {\equal{#1}{b}}{Figures}{Figs.}}
\providecommand*{\Ref}[1][s]{\ifthenelse{\equal{#1}{b}}{Reference}{Ref.}}
\providecommand*{\Refs}[1][s]{\ifthenelse{\equal{#1}{b}}{References}{Refs.}}
\providecommand\Table{Table}
\providecommand\Tables{Tables}
\providecommand\Chapter{Chapter}
\providecommand\Chapters{Chapters}
\providecommand\Section{Section}
\providecommand\Sections{Sections}
\providecommand*\Bref[2][s]{\Ref[#1]~\cite{#2}}
\providecommand*\Brefs[2][s]{\Refs[#1]~\cite{#2}}
\providecommand*\Eref[2][s]{\Eq[#1]~(\ref{#2})}
\providecommand*\Erefs[2][s]{\Eqs[#1]~(\ref{#2})}
\providecommand*\Fref[2][s]{\Figure[#1]~\ref{#2}}
\providecommand*\Frefs[2][s]{\Figures[#1]~\ref{#2}}
\providecommand*\Sref[1]{\Section~\ref{#1}}
\providecommand*\Srefs[1]{\Sections~\ref{#1}}
\providecommand*\Tref[1]{\Table~\ref{#1}}
\providecommand*\Trefs[1]{\Tables~\ref{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Abbreviations and math space and characters                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{xspace}
\providecommand*\eg{e.g.,\xspace}
\providecommand*\ie{i.e.,\xspace}
\providecommand*\etc{etc.\@\xspace}
\providecommand*\etal{\emph{et al.}}
\providecommand*\cf{\emph{cf.\xspace}}

\providecommand*\SPp{~}%% space before punctuation in math
\providecommand*\degree{\ensuremath{\circ}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  load heppennames, cernchemsym and cernunits packages            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{heppennames2}
\providecommand{\EPEM}{\Pep\Pem}
\RequirePackage{cernchemsym}
\renewcommand{\Isotopestyle}{\mathrm}
\RequirePackage{cernunits}

%% If MathTime not loaded, load mathrsfs package
\ifthenelse{\equal{\CERNMTPRO}{n}}
  {\RequirePackage{mathrsfs}}{}

\providecommand{\OfOrd}[1]{\ensuremath{\mathcal{O}(#1)}}
\providecommand{\Lumi}[1]
    {\ensuremath{\mathscr{L}\,#1\,\text{cm}^{-2}\,\text{s}^{-1}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   List of authors and institutes                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Define counter
\@ifundefined{c@instfoot}{\newcounter{instfoot}}{}
% Define reference to institute (one, two or three)
\def\Iref#1{\textsuperscript{\Inst{#1}}}               \let\Instref=\Iref
\def\IIref#1#2{\textsuperscript{\Inst{#1},\Inst{#2}}}  \let\InstInstref=\IIref
\def\IIIref#1#2#3{\textsuperscript{\Inst{#1},\Inst{#2},\Inst{#3}}}
% Worker macro (references institute counter)
\def\Inst#1{\@ifundefined{r@#1}{{\bf ??}}%
{\edef\@tempa{\@nameuse{r@#1}}\expandafter\@car\@tempa \@nil\null}}

%%%%%%%%%%%% Institute definitions  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% List of institutes
%   arg 1: used for sorting in file, not used by macro
%   arg 2: key for counter (used in \Inst, \IInst, etc.)
%   arg 3: Text to be printed about institute
\def\Instfoot#1#2#3{\refstepcounter{instfoot}\label{#2}%
    \noindent\parbox{\linewidth}{\footnotesize
            \makebox[1.2em][r]{\textsuperscript{\arabic{instfoot}}} #3}\newline}
%
%%%%%%%%%%%% Annotation definitions  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define annotation
%   arg 1: used for sorting in file, not used by macro
%   arg 2: annotation symbol to be shown (used in \Anot, etc.)
%   arg 3: Text to be printed about institute
\def\Anotfoot#1#2#3{\noindent
    \parbox{\linewidth}{\footnotesize
            \makebox[1.2em][r]{\textsuperscript{#2}} #3}\newline}
%
%%%%%%%%%%%% Anotation references   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\Aref#1{\textsuperscript{#1}}               \let\Anotref=\AAref
\def\AAref#1#2{\textsuperscript{#1,#2}}         \let\AnotAnotref=\AAref
\def\IAref#1#2{\textsuperscript{\Inst{#1},#2}} \let\InstAnotref=\IAref
\def\IIAref#1#2#3{\textsuperscript{\Inst{#1},\Inst{#2},#3}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Maintenance commands                                            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% The command \@minisanitize changes the catcode of $ & # ^ _ % ~ % to other
% except for braces to 'other'.  It it used by many commands in cernman.sty
% this command should only be executed within a group, or chaos will ensue.
 
\def\@minisanitize{\@makeother\$\@makeother\&%$
\@makeother\#\@makeother\^\@makeother\_\@makeother\%\@makeother\~}
\def\Lit{\begingroup\@minisanitize\@Lit}
\def\@Lit#1{\tt#1\endgroup}%  Literal string

% For sourcing examples of commands and environments
\DeclareRobustCommand\idxtt{\ttfamily\@noligs}
\DeclareRobustCommand\bs{{\normalfont\ttfamily\textbackslash}}
\DeclareRobustCommand\Lcs[1]{\mbox{\normalfont\idxtt\bs#1}}
\DeclareRobustCommand\Lenv[1]{\mbox{\normalfont\idxtt#1}}
% Short and long pages
\newcommand{\longpage}[1][1]{\enlargethispage{#1\baselineskip}}
\newcommand{\shortpage}[1][1]{\enlargethispage{-#1\baselineskip}}
% Working lenghts
\newlength{\Mylena}
\newlength{\Mylenb}
\newlength{\Mylenc}
\endinput

