%%
%% This is file `hep-paper.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hep-paper-implementation.dtx  (with options: `package')
%% This is a generated file.
%% Copyright (C) 2019-2020 by Jan Hajer
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%% http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.

\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{hep-paper}[2020/12/01 v1.6 Publications in High Energy Physics]

\RequirePackage{pdftexcmds}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
  family=hep,
  prefix=hep@
}
\DeclareStringOption[a4]{paper}
\DeclareStringOption[11pt]{font}
\DeclareStringOption[british]{lang}
\DeclareBoolOption[true]{serif}
\DeclareComplementaryOption{sansserif}{serif}
\DeclareBoolOption[true]{parindent}
\DeclareComplementaryOption{parskip}{parindent}
\DeclareStringOption[true]{symbols}
\DeclareBoolOption[false]{defaults}
\DeclareBoolOption[false]{lining}
\DeclareBoolOption[true]{title}
\DeclareBoolOption[true]{physics}
\DeclareStringOption[numeric-comp]{bibliography}
\DeclareBoolOption[true]{glossaries}
\DeclareBoolOption[true]{references}
\DeclareBoolOption[false]{beamer}
\DeclareBoolOption[false]{revtex}
\DeclareBoolOption[false]{jhep}
\DeclareBoolOption[false]{jcap}
\DeclareBoolOption[false]{pos}
\DeclareBoolOption[false]{springer}
\DeclareBoolOption[false]{eqnarray}
\DeclareBoolOption[false]{manualplacement}
\ProcessKeyvalOptions*
\def\hep@get@class#1.cls#2\relax{\def\hep@class{#1}}
\def\hep@getclass{\expandafter\hep@get@class\@filelist\relax}
\hep@getclass
\@ifclasswith{\hep@class}{10pt}{\setkeys{hep}{font=10pt}}{}
\@ifclasswith{\hep@class}{12pt}{\setkeys{hep}{font=12pt}}{}
\@ifclasswith{\hep@class}{a5paper}{\setkeys{hep}{paper=a5}}{}
\@ifclasswith{\hep@class}{b5paper}{\setkeys{hep}{paper=b5}}{}
\@ifclasswith{\hep@class}{letterpaper}{\setkeys{hep}{paper=letter}}{}
\@ifclasswith{\hep@class}{legalpaper}{\setkeys{hep}{paper=legal}}{}
\@ifclasswith{\hep@class}{executivepaper}{%
  \setkeys{hep}{paper=executive}%
}{}
\@ifclassloaded{svjour}{\setkeys{hep}{springer}}{}
\@ifclassloaded{svjour2}{\setkeys{hep}{springer}}{}
\@ifclassloaded{svjour3}{\setkeys{hep}{springer}}{}
\ifhep@springer
  \setkeys{hep}{defaults, title=false}
  \let\cl@chapter\undefined
\fi
\@ifclassloaded{PoS}{\setkeys{hep}{pos}}{}
\ifhep@pos
  \setkeys{hep}{defaults, title=false}
  \DeclareRobustCommand\boldmath{\@nomath\boldmath\mathversion{bold}}
\fi
\@ifclassloaded{beamer}{\setkeys{hep}{beamer}}{}
\ifhep@beamer
  \setkeys{hep}{defaults, title=false, references=false, sansserif}
  \@ifpackageloaded{beamerbasefont}{\usefonttheme{professionalfonts}}{}
  \setbeamertemplate{navigation symbols}{}
\fi
\@ifclassloaded{revtex4}{\setkeys{hep}{revtex}}{}
\@ifclassloaded{revtex4-1}{\setkeys{hep}{revtex}}{}
\@ifclassloaded{revtex4-2}{\setkeys{hep}{revtex}}{}
\ifhep@revtex
  \setkeys{hep}{defaults, title=false, bibliography=false, lang=american}
\fi
\@ifpackageloaded{jheppub}{\setkeys{hep}{jhep}}{}
\@ifpackageloaded{jcappub}{\setkeys{hep}{jcap}}{}
\newif\ifhep@sissa
\ifhep@jhep\hep@sissatrue
\else
  \ifhep@jcap\hep@sissatrue
  \else\hep@sissafalse
  \fi
\fi
\ifhep@sissa
  \setkeys{hep}{title=false, bibliography=false}
  \PassOptionsToPackage{
    colorlinks=true, linktocpage=true, pdfproducer=medialab, pdfa=true,
    urlcolor=blue, anchorcolor=blue, citecolor=blue, filecolor=blue,
    linkcolor=blue, menucolor=blue, pagecolor=blue
  }{hyperref}
  \PassOptionsToPackage{reset}{geometry}
  \AtBeginDocument{\renewcommand{\foreignabbrfont}{}}
\fi
\ifhep@jhep
  \voffset 0in
  \hoffset 0in
\fi

\ifhep@serif\else
  \renewcommand{\familydefault}{\sfdefault}
\fi
\RequirePackage{ifluatex}
\RequirePackage{ifxetex}
\newif\ifxetexorluatex
\ifxetex\xetexorluatextrue
\else
  \ifluatex\xetexorluatextrue
  \else\xetexorluatexfalse
  \fi
\fi
\ifxetexorluatex
  \def\hep@encoding{TU}
\else
  \def\hep@encoding{T1}
\fi
\RequirePackage[\hep@encoding]{fontenc}
\RequirePackage{fix-cm}
\RequirePackage{microtype}
\ifhep@lining
  \RequirePackage[rm={lining},sf={lining},tt={lining}]{cfr-lm}
\else
  \RequirePackage{cfr-lm}
\fi
\RequirePackage{etoolbox}
\RequirePackage{textcomp}
\newcommand{\hep@sf@fontshape}[3]{%
  \DeclareFontShape{\hep@encoding}{\sfdefault}{#1}{#2}{#3}{}%
}
\newcommand{\hep@rm@fontshape}[3]{%
  \DeclareFontShape{\hep@encoding}{\rmdefault}{#1}{#2}{#3}{}%
}
\ifxetexorluatex
  \RequirePackage{fontspec}
  \setmainfont{Latin Modern Roman}[
    UprightFeatures={SmallCapsFont={[lmromancaps10-regular.otf]}},
    BoldFeatures={
      SmallCapsFeatures={Letters=SmallCaps},
      SmallCapsFont={[cmunbx.otf]}
    }
  ]
  \hep@sf@fontshape{bx}{sc}{<->cmssbxcsc10}{}
  \hep@sf@fontshape{b}{sc}{<->cmssbxcsc10}{}
  \hep@sf@fontshape{m}{scit}{<->cmsscsci10}{}
  \hep@sf@fontshape{m}{sc}{%
    <-9>cmsscsc8<9-10>cmsscsc9<10->cmsscsc10%
  }{}
\else
  \rmfamily
  \hep@rm@fontshape{b}{sc}{<->ssub*cmr/bx/sc}{}
  \hep@rm@fontshape{bx}{sc}{<->ssub*cmr/bx/sc}{}
  \sffamily
  \hep@sf@fontshape{m}{sc}{<->ssub*xcmss/m/sc}{}
  \hep@sf@fontshape{b}{sc}{<->ssub*xcmss/bx/sc}{}
  \hep@sf@fontshape{bx}{sc}{<->ssub*xcmss/bx/sc}{}
  \hep@sf@fontshape{m}{scit}{<->ssub*xcmss/m/scit}{}
  \hep@sf@fontshape{b}{scit}{<->ssub*xcmss/bx/scit}{}
  \hep@sf@fontshape{bx}{scit}{<->ssub*xcmss/bx/scit}{}
\fi
\ifxetexorluatex\else
  \RequirePackage[utf8]{inputenc}
\fi
\RequirePackage[\hep@lang]{babel}
\RequirePackage[autostyle]{csquotes}
\RequirePackage[normalem]{ulem}
\let\underline\uline
\ifhep@defaults\else
  \def\hep@remove@pt#1pt{#1}
  \edef\hep@pt@size{\expandafter\hep@remove@pt\hep@font}
  \let\small\relax
  \let\footnotesize\relax
  \let\scriptsize\relax
  \let\tiny\relax
  \let\large\relax
  \let\Large\relax
  \let\LARGE\relax
  \let\huge\relax
  \let\Huge\relax
  \input{size\hep@pt@size.clo}
\fi

\ifnum\pdf@strcmp{\hep@lang}{american}=0
  \newcommand{\hep@lang@foreign}{USenglish}
\else
  \ifnum\pdf@strcmp{\hep@lang}{USenglish}=0
    \newcommand{\hep@lang@foreign}{USenglish}
  \else
    \newcommand{\hep@lang@foreign}{british}
  \fi
\fi
\RequirePackage[all, \hep@lang@foreign]{foreign}
\DeclareRobustCommand\vs{\xperiodafter{{\foreignabbrfont{vs}}}}
\xspaceaddexceptions{\csq@qclose@i}
\newcommand{\no}[1]{\textnumero~#1}
\RequirePackage{relsize}
\newcommand{\software}[2][\hspace{-\fontdimen2\font}]{%
  {\smaller[.5]\textsc{#2}~#1}%
}
\newcommand{\online}[2]{\href{#1}{\nolinkurl{#2}}}
\providecommand{\email}[1]{\online{mailto:#1}{#1}}
\newcommand{\prefix}[2]{(#1\mbox{-)}\allowbreak #2}

\RequirePackage[inline]{enumitem}
\newlist{inlinelist}{enumerate*}{1}
\setlist*[inlinelist,1]{%
  label=\roman*), itemjoin={,\ }, itemjoin*={, and\ }, after=.%
}
\newlist{enum@descript}{enumerate}{2}
\setlist[enum@descript]{label=\arabic*.}
\newenvironment{enumdescript}[1][]{
\begin{enum@descript}[#1]
  \let\hep@item\item
  \renewcommand{\item}[2][]{
    \ifx&##1&\hep@item\else\hep@item[##1]\fi
    \textbf{##2}\ifx##2\empty\else~\fi\@ifnextchar\par\@gobble\relax
  }
}{\end{enum@descript}}

\ifhep@defaults\else
  \RequirePackage{geometry}
  \geometry{\hep@paper paper, includeheadfoot}
  \if@twocolumn
    \geometry{hscale=.85, vscale=.925, vmarginratio=1:1}
    \geometry{headsep=2ex, footskip=6ex}
    \setlength{\columnsep}{1.1em}
  \else
    \geometry{hscale=.75, vscale=.8, vmarginratio=3:4}
  \fi
\fi
\ifhep@parindent\else
\RequirePackage{parskip}
\newcommand{\useparskip}{%
  \setlength{\parskip}{.5\baselineskip plus 2pt}%
  \setlength{\parindent}{0pt}%
}
\newcommand{\useparindent}{%
  \setlength{\parskip}{0pt}%
  \setlength{\parindent}{15pt}%
  \if@twocolumn\setlength\parindent{1em}
  \else\setlength\parindent{1.5em}
  \fi
}
\fi

\RequirePackage{mathtools}
\allowdisplaybreaks[1]
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\sgn}{sgn}
\RequirePackage{xparse}
\DeclareDocumentCommand{\mathdef}{mO{0}m}{%
  \expandafter\let\csname text\string#1\endcsname=#1
  \expandafter\newcommand\csname math\string#1\endcsname[#2]{#3}
  \DeclareRobustCommand#1{%
    \ifmmode
      \expandafter\let\expandafter\next\csname math\string#1\endcsname
    \else
      \expandafter\let\expandafter\next\csname text\string#1\endcsname
    \fi
    \next
  }%
}
\AtBeginDocument{\mathdef{\i}{\operatorname{i}}}
\def\overline#1{{\renewcommand{\ULdepth}{-1.9ex}{}\uline{#1}}}
\DeclareRobustCommand{\over@line}[1]{\@@overline{#1}}
\mathdef{\overline}{\over@line}
\RequirePackage{mleftright}
\mleftright
\ifhep@eqnarray\else
  \let\eqnarray\@undefined
  \let\endeqnarray\@undefined
\fi
\newif\ifhep@symbols
\ifnum\pdf@strcmp{\hep@symbols}{false}=0\else\hep@symbolstrue\fi
\newif\ifhep@ams
\ifnum\pdf@strcmp{\hep@symbols}{ams}=0 \hep@amstrue\fi
\newif\ifhep@minion
\ifnum\pdf@strcmp{\hep@symbols}{minion}=0 \hep@miniontrue\fi
\ifhep@symbols
  \RequirePackage{fixmath}
  \RequirePackage{alphabeta}
  \RequirePackage{substitutefont}
  \substitutefont{LGR}{\rmdefault}{lmr}
  \DeclareFontFamily{LGR}{\rmdefault}{}
  \DeclareFontShape{LGR}{\rmdefault}{b}{n}{<->ssub*lmr/bx/n}{}
  \DeclareFontShape{LGR}{\rmdefault}{b}{sc}{<->ssub*lmr/bx/sc}{}
  \substitutefont{LGR}{\ttdefault}{lmtt}
  \DeclareFontFamily{LGR}{\ttdefault}{}
  \DeclareFontShape{LGR}{\ttdefault}{b}{n}{<->ssub*cmtt/bx/n}{}
  \substitutefont{LGR}{\sfdefault}{lmss}
  \DeclareFontFamily{LGR}{\sfdefault}{}
  \DeclareFontShape{LGR}{\sfdefault}{b}{n}{<->ssub*lmss/bx/n}{}
  \DeclareFontShape{LGR}{\sfdefault}{b}{sc}{<->ssub*lmss/bx/sc}{}
  \ifhep@minion
    \RequirePackage{MnSymbol}
  \else
    \RequirePackage{exscale}
    \RequirePackage{amssymb}
  \fi
\fi
\ifhep@serif
  \newcommand\hep@font@sf{cmbrm}
  \DeclareMathAlphabet{\mathsf}{OML}{\hep@font@sf}{m}{it}
  \SetMathAlphabet{\mathsf}{bold}{OML}{\hep@font@sf}{b}{it}
\else
  \newcommand\hep@font@sf{lmr}
  \newcommand\hep@font@text{lmss}
  \newcommand\hep@font@math{cmbrm}
  \newcommand\hep@font@symbol{cmsssy}
  \newcommand\hep@font@extra{cmssex}
  \newcommand\hep@font@amsa{ssmsa}
  \newcommand\hep@font@amsb{ssmsb}
  \DeclareFontSubstitution{OML}{\hep@font@math}{m}{it}
  \ifhep@symbols\ifhep@minion\else
    \DeclareFontSubstitution{OMS}{\hep@font@symbol}{m}{n}
    \DeclareFontSubstitution{OMX}{\hep@font@extra}{m}{n}
  \fi\fi
  \DeclareSymbolFont{operators}{OT1}{\hep@font@text}{m}{n}
  \DeclareSymbolFont{letters}{OML}{\hep@font@math}{m}{it}
  \ifhep@symbols\ifhep@minion\else
    \DeclareSymbolFont{symbols}{OMS}{\hep@font@symbol}{m}{n}
    \DeclareSymbolFont{largesymbols}{OMX}{\hep@font@extra}{m}{n}
  \fi\fi
  \SetSymbolFont{operators}{bold}{OT1}{\hep@font@text}{b}{n}
  \SetSymbolFont{letters}{bold}{OML}{\hep@font@math}{b}{it}
  \ifhep@symbols\ifhep@minion\else
    \SetSymbolFont{symbols}{bold}{OMS}{\hep@font@symbol}{b}{n}
  \fi\fi
  \ifhep@symbols\ifhep@minion\else
    \DeclareSymbolFont{AMSa}{U}{\hep@font@amsa}{m}{n}
    \DeclareSymbolFont{AMSb}{U}{\hep@font@amsb}{m}{n}
  \fi\fi
  \AtBeginDocument{%
    \@ifpackageloaded{esint}{%
      \DeclareSymbolFont{largesymbolsA}{U}{ssesint}{m}{n}
    }{}
  }
  \DeclareSymbolFontAlphabet{\mathrm}{operators}
  \DeclareSymbolFontAlphabet{\mathnormal}{letters}
  \ifhep@minion\else
    \DeclareSymbolFontAlphabet{\mathcal}{symbols}
  \fi
  \DeclareMathAlphabet{\mathit}{OML}{\hep@font@text}{m}{it}
  \SetMathAlphabet\mathit{bold}{OML}{\hep@font@text}{bx}{it}
  \DeclareMathAlphabet{\mathtt}{OT1}{cmtl}{m}{n}
  \DeclareMathAlphabet{\mathsf}{OML}{\hep@font@sf}{m}{it}
  \SetMathAlphabet{\mathsf}{bold}{OML}{\hep@font@sf}{bx}{it}
\fi
\ifhep@symbols
  \RequirePackage{bm}
  \AtBeginDocument{\let\mathbf\bm}
  \g@addto@macro\bfseries{\boldmath}
  \DeclareMathAlphabet{\mathscr}{U}{rsfs}{m}{n}
  \ifhep@minion
    \DeclareMathAlphabet{\mathbb}{U}{%
      \ifhep@serif dsrom\else dsss\fi%
    }{m}{n}
  \else
    \ifhep@ams\else
      \SetMathAlphabet{\mathbb}{normal}{U}{%
        \ifhep@serif dsrom\else dsss\fi%
      }{m}{n}
    \fi
  \fi
\fi

\ifhep@physics
\RequirePackage{physics}
\RequirePackage{cancel}
\RequirePackage{slashed}
\RequirePackage{units}
\newcommand{\textfrac}[2]{\ensuremath{\nicefrac{\text{#1}}{\text{#2}}}}
\newcommand{\inv}[2][1]{#2\ensuremath{^{-#1}}}
\AtBeginDocument{\mathdef{\d}{\dd}}
\newcommand{\oset}[3][-1pt]{%
  \text{\raisebox{.2ex}{$\mathop{#3}\limits^{%
    \vbox to#1{\kern-2\ex@\hbox{$\scriptscriptstyle#2$}\vss}%
  }$}}%
}
\newcommand{\overleftright}[1]{\oset{\leftrightarrow}{#1}}
\fi

\setcounter{bottomnumber}{0} % 1
\setcounter{topnumber}{1} % 2
\setcounter{dbltopnumber}{1} % 2
\renewcommand{\topfraction}{.9} % .7
\renewcommand{\dbltopfraction}{.9} % .7
\renewcommand{\textfraction}{.1} % .2
\renewcommand{\floatpagefraction}{.8} % .5
\let\@figure@\figure%
\let\@end@figure@\endfigure%
\let\@table@\table%
\let\@end@table@\endtable%
\ifhep@manualplacement%
  \renewenvironment{figure}[1][tbp]{%
    \@figure@[#1]\centering%
    }{\@end@figure@}%
  \renewenvironment{table}[1][tbp]{%
    \@table@[#1]\centering%
  }{\@end@table@}%
\else%
  \renewenvironment{figure}[1][]{%
    \@figure@\centering%
  }{\@end@figure@}%
  \renewenvironment{table}[1][]{%
    \@table@\centering%
  }{\@end@table@}
\fi%

\newif\ifhep@journal
\ifhep@sissa\hep@journaltrue
\else
  \ifhep@revtex\hep@journaltrue
  \else
    \ifhep@pos\hep@journaltrue
    \else
      \ifhep@springer\hep@journaltrue
      \else\hep@journalfalse
      \fi
    \fi
  \fi
\fi
\ifhep@journal
  \setlength\abovecaptionskip{\f@size\p@}
  \setlength\belowcaptionskip{0\p@}
  \long\def\@makecaption#1#2{%
    \vskip\abovecaptionskip
    \sbox\@tempboxa{#1: #2}%
    \ifdim \wd\@tempboxa >\hsize
      #1: #2\par
    \else
      \global \@minipagefalse
      \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
    \fi
    \vskip\belowcaptionskip%
  }
\fi
\RequirePackage[subrefformat=parens]{subcaption}
\captionsetup{font=small}
\captionsetup[sub]{font=small}
\providecommand*\subcaption@minipage[2]{%
  \minipage#1{#2}\setcaptionsubtype\relax%
}
\newenvironment{panels}[2][b]{%
  \newcommand{\begin@subcaption@minipage}[2][b]{%
    \caption@withoptargs\subcaption@minipage[##1]{##2}%
    \centering\vskip 0pt%
  }
  \ifdim#2pt>1pt%
    \newcommand{\panel}[1][b]{%
      \endminipage\hfill\begin@subcaption@minipage[#1]{\linewidth/#2}%
    }%
    \begin@subcaption@minipage[#1]{\linewidth/#2}%
  \else%
    \newcommand{\panel}[2][b]{%
      \endminipage\hfill\begin@subcaption@minipage[#1]{##2\linewidth}%
    }%
    \begin@subcaption@minipage[#1]{#2\linewidth}%
  \fi%
}{\endminipage}
\ifhep@revtex
  \RequirePackage{ragged2e}
  \DeclareCaptionFormat{revtex}{#1#2\justifying{#3}}
  \captionsetup{font=small, format=revtex}
  \captionsetup[sub]{font=footnotesize, format=plain}
  \renewcommand{\figurename}{Figure}
  \renewcommand{\tablename}{Table}
\fi

\RequirePackage{booktabs}
\RequirePackage{multirow}

\RequirePackage{graphicx}
\providecommand{\tikzsetnextfilename}[1]{}
\newcommand{\graphic}[2][1]{\tikzsetnextfilename{#2}{%
  \centering\includegraphics[width=#1\linewidth]{#2}\par%
}}
\newcommand{\graphics}[1]{\graphicspath{{./#1/}}}

\ifhep@title
\date{}
\RequirePackage{titling}
\let\hep@preprint@font\relax
\newcommand{\preprintfont}[1]{\def\hep@preprint@font{#1}}
\let\hep@title@font\relax
\newcommand{\titlefont}[1]{\def\hep@title@font{#1}}
\let\hep@subtitle@font\relax
\newcommand{\subtitlefont}[1]{\def\hep@subtitle@font{#1}}
\let\hep@author@font\relax
\newcommand{\authorfont}[1]{\def\hep@author@font{#1}}
\let\hep@affiliation@font\relax
\newcommand{\affiliationfont}[1]{\def\hep@affiliation@font{#1}}
\let\hep@date@font\relax
\newcommand{\datefont}[1]{\def\hep@date@font{#1}}
\newcommand{\presubtitle}[1]{\def\hep@pre@sub@title{#1}}
\newcommand{\subtitle}[1]{\def\sub@title{#1}}
\newcommand{\postsubtitle}[1]{\def\hep@post@sub@title{#1}}
\renewcommand{\maketitlehookb}{%
  \@ifundefined{sub@title}{}{%
    \hep@pre@sub@title\sub@title\hep@post@sub@title%
  }%
}
\titlefont{\ifhep@serif\tistyle\else\qtstyle\fi}
\pretitle{\begin{center}\LARGE\hep@title@font}
\posttitle{\par\end{center}}
\subtitlefont{\ifhep@serif\tistyle\else\qtstyle\fi}
\presubtitle{\begin{center}\Large\hep@subtitle@font}
\postsubtitle{\par\end{center}}
\preauthor{%
  \begin{center}\large\hep@author@font\lineskip.5em\begin{tabular}[t]{c}%
}
\postauthor{\end{tabular}\par\end{center}}
\predate{\begin{center}\hep@date@font}
\postdate{\par\end{center}}
\author{}
\RequirePackage{authblk}
\renewcommand{\Affilfont}{\small\hep@affiliation@font}
\renewcommand\Authfont{\hep@author@font}
\let\hep@author\author
\def\author{%
  \renewcommand{\email}[1]{\unskip\thanks{\online{mailto:##1}{##1}}}%
  \hep@author
}
\newcommand\hep@penalty{\if@twocolumn85\else50\fi}
\newcommand\hep@active@comma{,\penalty-\hep@penalty\relax}
\newcommand\hep@cat@comma@active{\catcode`\,\active}
{\hep@cat@comma@active\gdef,{\hep@active@comma}}
\newcommand\hep@affil[1]{%
  \endgroup\@flushglue=0pt plus .5\linewidth\affil{#1}%
}
\def\hep@affil@opt[#1]#2{%
  \endgroup\@flushglue=0pt plus .5\linewidth\affil[#1]{#2}%
}
\DeclareRobustCommand\hep@affiliation{%
  \@ifnextchar[{\hep@affil@opt}{\hep@affil}%
}
\newcommand{\affiliation}{%
  \begingroup\hep@cat@comma@active\hep@affiliation%
}

\let\hep@preprint\relax
\newcommand\preprint[1]{\def\hep@preprint{#1}}
\RequirePackage{varwidth}
\newcommand{\hep@preprint@box}{%
  \begin{varwidth}{\textwidth}%
    \smaller[.5]\hep@preprint@font\hep@preprint%
  \end{varwidth}%
}
\preprintfont{\scshape}
\RequirePackage{atbegshi}
\RequirePackage{picture}
\newcommand{\placepreprint}{%
  \AtBeginShipoutFirst{%
    \put(
      \textwidth+\oddsidemargin-\widthof{\hep@preprint@box},
      -2pt-\topmargin-\heightof{\hep@preprint@box}
    ){\normalfont\hep@preprint@box}
  }
}
\renewcommand{\maketitlehooka}{\placepreprint\vspace{-\bigskipamount}}

\@ifundefined{abstract}{}{%
  \let\hep@abstract\abstract%
  \renewcommand\abstract{\hep@abstract\noindent\ignorespaces}%
}
\if@twocolumn
  \RequirePackage{environ}
  \RequirePackage{abstract}
  \renewcommand{\abstitleskip}{-3ex}
  \NewEnviron{abstract*}{%
    \twocolumn[\maketitle\vspace{-1.5cm}%
    \begin{onecolabstract}\noindent\BODY\end{onecolabstract}%
    \vspace{.5cm}]\saythanks%
  }
\else
  \newenvironment{abstract*}{\maketitle\begin{abstract}}{\end{abstract}}
\fi
\fi

\ifnum\pdf@strcmp{\hep@bibliography}{false}=0\else
\RequirePackage[style=\hep@bibliography, datamodel=hep-paper]{biblatex}
\providecommand{\DeclareSortingTemplate}{\DeclareSortingScheme}
\DeclareSortingTemplate{hep-paper}{
  \sort{\citeorder}
  \sort[final]{\field{sortkey}}
  \sort{\field{sortyear} \field{year} \literal{9999}}
  \sort{\field{month}}
  \sort{\field{eprint} \field{doi}}
  \sort{\field{sorttitle} \field{title}}
  \sort{\field{subtitle} \field{volume}}
}
\ExecuteBibliographyOptions{
  sorting=hep-paper,
  safeinputenc,
  giveninits=true
}
\ifhep@journal\else
  \if@twocolumn
    \AtBeginBibliography{\small}
    \setlength\biblabelsep{\labelsep}
  \fi
\fi
\NewBibliographyString{erratum,erratums}
\DefineBibliographyStrings{english}{erratum={Erratum},erratums={Errata}}
\providecommand{\relateddelimerratum}{\addsemicolon\space}
\let\hep@printbibliography\printbibliography
\renewcommand{\printbibliography}{\sloppy\hep@printbibliography}

\newcommand{\reg@exp@one}{\regexp{\A(\p{L}+)?\d+(\p{L}+)?\Z}}
\newcommand{\reg@exp@two}{\regexp{\A(\p{L}+)?(\d+)(\p{L}+)?\Z}}
\newcommand{\reg@exp@url}{\regexp{\A(ht|f)tp(s)?:\/\/}}
\newcommand{\reg@exp@pmc}{\regexp{\A(PMC)?}}
\DeclareSourcemap{%
  \maps[datatype=bibtex, overwrite=true]{%
    \map{%
      \step[fieldsource=Collaboration, final=true]%
      \step[fieldset=collaboration, origfieldval, final=true]
    }%
    \map{%
      \step[fieldsource=reportNumber, final=true]%
      \step[fieldset=reportnumber, origfieldval, final=true]
    }%
    \map[overwrite]{
      \step[fieldsource=volume, match=\reg@exp@one, final]
      \step[fieldsource=volume, match=\reg@exp@two, replace={$2}]
      \step[fieldsource=journal, fieldtarget=journaltitle]
      \step[fieldset=journaltitle, fieldvalue={\space$1$2}, append=true]
    }
    \map{
      \step[fieldsource=url, final=true]
      \step[fieldset=protocollessurl, origfieldval, final=true]
      \step[fieldsource=protocollessurl, match=\reg@exp@url, replace={}]
    }
    \map{
      \step[fieldsource=pmcid, final=true]
      \step[fieldset=pmc, origfieldval, final=true]
      \step[fieldsource=pmc, match=\reg@exp@pmc, replace={}]
    }
  }%
}
\providecommand{\letbibmacro}[2]{\csletcs{abx@macro@#1}{abx@macro@#2}}
\renewbibmacro*{author/translator+others}{%
  \ifboolexpr{
    test \ifuseauthor and (
      not test {\ifnameundef{author}} or
      not test {\iffieldundef{collaboration}}
    )
  }
  {\usebibmacro{author}}
  {\usebibmacro{translator+others}}
}
\letbibmacro{hep@bib@author}{author}
\renewbibmacro*{author}{%
  \iffieldundef{collaboration}{%
    \usebibmacro{hep@bib@author}}{\textit{\printfield{collaboration}}%
  }%
}
\renewbibmacro*{in:}{%
  \iffieldundef{journaltitle}{}{\printtext{\bibstring{in}\intitlepunct}}%
}
\DeclareFieldFormat{url}{%
  \mkbibacro{URL}\addcolon\space\online{#1}{\thefield{protocollessurl}}%
}
\newcommand{\bib@online}[2]{%
  \ifhyperref{\online{#1}{#2}}{\nolinkurl{#2}}%
}
\DeclareFieldFormat{pmid}{%
  \mkbibacro{PM}\addcolon\space%
  \bib@online{https://www.ncbi.nlm.nih.gov/pubmed/#1}{#1}%
}
\DeclareFieldFormat{pmc}{%
  \mkbibacro{PMC}\addcolon\space%
  \bib@online{https://www.ncbi.nlm.nih.gov/pmc/articles/PMC#1}{#1}%
}
\letbibmacro{hep-doi+eprint+url}{doi+eprint+url}
\renewbibmacro*{doi+eprint+url}{%
  \usebibmacro{hep-doi+eprint+url}
  \iffieldundef{pmc}{%
    \iffieldundef{pmid}{}{\printfield{pmid}\newunit}%
  }{\printfield{pmc}\newunit}
  \iffieldundef{reportnumber}{}{%
    \newunitpunct\textnumero\intitlepunct%
    \textsc{\smaller[.5]\printfield{reportnumber}}%
    \newunit%
  }%
}

\NewDocumentCommand{\new@eprint}{smm}{
  \DeclareFieldFormat{eprint:#2}{%
    \newcommand{\@path}{\IfBooleanT{#1}{\thefield{eprintclass}/}##1}%
    #2\addcolon\space\bib@online{#3/\@path}{\@path}%
  }%
}
\new@eprint{CTAN}{https://ctan.org/pkg}
\DeclareFieldAlias{eprint:ctan}{eprint:CTAN}
\new@eprint*{GitHub}{https://github.com}
\DeclareFieldAlias{eprint:github}{eprint:GitHub}
\new@eprint*{GitLab}{https://gitlab.com}
\DeclareFieldAlias{eprint:gitlab}{eprint:GitLab}
\new@eprint*{Bitbucket}{https://bitbucket.org}
\DeclareFieldAlias{eprint:bitbucket}{eprint:Bitbucket}
\new@eprint{Launchpad}{https://launchpad.net}
\DeclareFieldAlias{eprint:launchpad}{eprint:Launchpad}
\new@eprint{SourceForge}{https://sourceforge.net/projects}
\DeclareFieldAlias{eprint:launchpad}{eprint:SourceForge}
\DeclareFieldFormat{eprint:hepforge}{%
  HEPForge\addcolon\space\bib@online{https://#1/hepforge.org}{#1}%
}
\DeclareFieldAlias{eprint:HEPForge}{eprint:hepforge}
\fi

\RequirePackage{hyperref}
\hypersetup{
  pdfencoding=auto, psdextra,
  hidelinks, linktoc=all, breaklinks=true,
  pdfcreator={}, pdfproducer={}
}
\pdfstringdefDisableCommands{\def\varepsilon{\textepsilon}}
\AtBeginDocument{
  \pdfstringdefDisableCommands{\let\ensuremath\@gobble}
  \pdfstringdefDisableCommands{\let\mathsurround\@gobble}
  \pdfstringdefDisableCommands{\let\unskip\@gobble}
  \pdfstringdefDisableCommands{\let\thanks\@gobble}
  \pdfstringdefDisableCommands{\let\footnote\@gobble}
  \pdfstringdefDisableCommands{\let\\\@gobble}
}
\ifhep@revtex
  \AtBeginShipout{\hypersetup{pdftitle={\@title}}}
\else
  \ifhep@beamer\else
    \AtBeginDocument{\hypersetup{pdftitle={\@title}}}
  \fi
\fi
\ifhep@title
  \AtBeginDocument{\hypersetup{pdfauthor=\AB@authlist}}
\else
  \ifhep@beamer\else
    \AtBeginDocument{\hypersetup{pdfauthor={\@author}}}
  \fi
\fi

\def\BackrefFootnoteTag{}
\RequirePackage{footnotebackref}
\let\@foot@note\footnote
\renewcommand{\footnote}[1]{\unskip\@foot@note{\ignorespaces#1}}

\ifhep@references
\RequirePackage[noabbrev, nameinlink]{cleveref}
\newcommand{\creflastconjunction}{, and\nobreakspace}
\crefname{enumi}{point}{points}
\crefname{inlinelisti}{point}{points}
\newcommand\no@break@before{%
  \relax\ifvmode\else%
    \ifhmode%
      \ifdim\lastskip > 0pt%
        \relax\unskip\nobreakspace%
      \fi%
    \fi%
  \fi%
}
\let\hep@ref\ref
\AtBeginDocument{\renewcommand\ref{\no@break@before\hep@ref}}
\renewcommand\eqref{\no@break@before\labelcref}
\let\hep@subref\subref
\renewcommand\subref{\no@break@before\hep@subref}
\renewcommand*\subcaption@ref[2]{\begingroup%
  \caption@setoptions{sub}%
  \subcaption@reffmt\p@subref{\hep@ref#1{sub@#2}}%
\endgroup}
\newcommand{\subcref}[1]{\cref{sub@#1}}
\NewDocumentCommand{\eqcrefname}{mmo}{
  \crefname{#1}{#2}{\IfValueTF{#3}{#3}{#2s}}
  \creflabelformat{#1}{(##2##1##3)}
}
\DeclareRobustCommand{\labelcrefrange}[2]{%
  \@crefrangenostar{labelcref}{#1}{#2}%
}
\fi

\let\hep@cite\cite
\renewcommand\cite{\no@break@before\hep@cite}
\ifnum\pdf@strcmp{\hep@bibliography}{false}=0\else
\NewBibliographyString{refname}
\NewBibliographyString{refsname}
\DefineBibliographyStrings{english}{%
  refname = {reference},
  refsname = {references}
}
\DeclareCiteCommand{\ccite}{%
  \ifnum\thecitetotal=1
    \bibstring{refname}%
  \else%
    \bibstring{refsname}%
  \fi%
  \addnbspace\bibopenbracket%
  \usebibmacro{cite:init}\usebibmacro{prenote}%
}{\usebibmacro{citeindex}\usebibmacro{cite:comp}}{}{%
  \usebibmacro{cite:dump}\usebibmacro{postnote}%
  \bibclosebracket%
}

\newrobustcmd*{\Ccite}{\bibsentence\ccite}
\fi

\ifhep@glossaries
\RequirePackage[nostyles]{glossaries-extra}
\glsenableentrycount
\glssetcategoryattribute{abbreviation}{entrycount}{1}
\providecommand{\glsxtrusefield}[2]{\@gls@entry@field{#1}{#2}}
\providecommand{\glsxtrsetfieldifexists}[3]{\glsdoifexists{#1}{#3}}
\providecommand{\gGlsXtrSetField}[3]{%
  \glsxtrsetfieldifexists{#1}{#2}{%
    \csgdef{glo@\glsdetoklabel{#1}@#2}{#3}%
  }%
}
\glssetcategoryattribute{abbreviation}{nohyperfirst}{true}
\renewcommand*{\glsdonohyperlink}[2]{{%
  \glsxtrprotectlinks\edef\fieldvalue{%
    \glsxtrusefield{\glslabel}{hastarget}%
  }%
  \ifdefstring\fieldvalue{true}{#2}{%
    \gGlsXtrSetField{\glslabel}{hastarget}{true}%
    \glsdohypertarget{#1}{#2}%
  }%
}}
\RequirePackage[excludeor]{everyhook}
\newcommand{\begin@sentence}{1001}
\PushPostHook{par}{{\spacefactor=\begin@sentence}}
\def\frenchspacing{%
  \sfcode`\.\begin@sentence \sfcode`\?\begin@sentence
  \sfcode`\!\begin@sentence \sfcode`\:\begin@sentence
  \sfcode`\;\@m \sfcode`\,\@m
}
\newcommand{\if@begin@of@sentence}[2]{\leavevmode\protecting{%
  \ifboolexpr{ test {\ifnumcomp{\spacefactor}{=}{3000}} or%
               test {\ifnumcomp{\spacefactor}{=}{2000}} or%
               test {\ifnumcomp{\spacefactor}{=}{\begin@sentence}}%
  }{#1}{#2}%
}}
\NewDocumentCommand{\acronym}{somsmo}{
  \newabbreviation[
    type=\acronymtype,
    sort=#3,
    \glsshortpluralkey=\IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}},
    longplural=\IfNoValueTF{#6}{#5s}{#6}
  ]{#3}{\IfNoValueTF{#2}{#3}{#2}}{#5}
  \expandafter\newcommand\csname#3\endcsname{%
    \if@begin@of@sentence{%
      \ifglsused{#3}{\cgls{#3}}{\cGls{#3}}%
    }{\cgls{#3}}%
    \ifnum\glsentrycurrcount{#3}>1\relax
      \IfBooleanTF{#4}{}{\@\xspace}%
    \else\@\xspace\fi
  }
  \pdfstringdefDisableCommands{\expandafter\def\csname#3\endcsname{%
    \IfNoValueTF{#2}{#3}{#2} }%
  }
  \expandafter\mathdef\csname#3\endcsname{%
    \text{\glsxtrshort{#3}}\@gls@increment@currcount{#3}%
  }
  \expandafter\newcommand\csname#3s\endcsname{%
    \if@begin@of@sentence{\cGlspl{#3}}{\cglspl{#3}}%
    \IfBooleanTF{#4}{}{\@\xspace}%
  }
  \pdfstringdefDisableCommands{\expandafter\def\csname#3s\endcsname{%
    \IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}} }%
  }
  \expandafter\mathdef\csname#3s\endcsname{%
    \text{\glsxtrshortpl{#3}}\@gls@increment@currcount{#3}%
  }
}
\NewDocumentCommand{\shortacronym}{somsmo}{
  \expandafter\newcommand\csname#3\endcsname{%
    \IfNoValueTF{#2}{#3}{#2}\IfBooleanTF{#4}{}{\@\xspace}%
  }
  \pdfstringdefDisableCommands{\expandafter\def\csname#3\endcsname{%
    \IfNoValueTF{#2}{#3}{#2} }%
  }
  \expandafter\mathdef\csname#3\endcsname{%
    \text{\IfNoValueTF{#2}{#3}{#2}}%
  }
  \expandafter\newcommand\csname#3s\endcsname{%
    \IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}}%
    \IfBooleanTF{#4}{}{\@\xspace}%
  }
  \pdfstringdefDisableCommands{\expandafter\def\csname#3s\endcsname{%
    \IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}} }%
  }
  \expandafter\mathdef\csname#3s\endcsname{%
    \text{\IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}}}%
  }%
}
\NewDocumentCommand{\longacronym}{somsmo}{
  \expandafter\newcommand\csname#3\endcsname{%
    \if@begin@of@sentence{\MakeUppercase#5}{#5}%
    \IfBooleanTF{#4}{}{\@\xspace}%
  }
  \pdfstringdefDisableCommands{\expandafter\def\csname#3\endcsname{#5 }}
  \expandafter\newcommand\csname#3s\endcsname{%
    \if@begin@of@sentence{%
      \IfNoValueTF{#6}{\MakeUppercase#5s}{\MakeUppercase#6}%
    }{%
      \IfNoValueTF{#6}{#5s}{#6}}\IfBooleanTF{#4}{}{\@\xspace}%
  }
  \pdfstringdefDisableCommands{\expandafter\def\csname#3s\endcsname{%
    \IfNoValueTF{#6}{#5s}{#6} }%
  }
}
\renewcommand*{\@gls@write@entrycounts}{%
  \immediate\write\@auxout{%
    \string\providecommand*{\string\@gls@entry@count}[2]{}
  }%
  \count@=0\relax
  \forallglsentries{\@glsentry}{%
    \glshasattribute{\@glsentry}{entrycount}{%
      \ifglsused{\@glsentry}{%
        \immediate\write\@auxout{%
          \string\@gls@entry@count{\@glsentry}{%
            \glsentrycurrcount{\@glsentry}%
          }
        }%
      }{}\advance\count@ by \@ne
    }{}%
  }%
}
\newcommand{\resetacronym}[1]{\protect\glsreset{#1}}
\newcommand{\dummyacronym}[1]{\protect\glsunset{#1}}
\@ifundefined{endabstract}{}{%
  \let\end@hep@abstract\endabstract%
  \renewcommand\endabstract{\glsresetall\end@hep@abstract}%
}
\let\hep@table@of@contents\tableofcontents
\renewcommand\tableofcontents{%
  \glsunsetall\hep@table@of@contents\glsresetall%
}
\let\hep@list@of@figures\listoffigures
\renewcommand\listoffigures{%
  \glsunsetall\hep@list@of@figures\glsresetall%
}
\let\hep@list@of@tables\listoftables
\renewcommand\listoftables{%
  \glsunsetall\hep@list@of@tables\glsresetall%
}
\NewDocumentCommand{\acronyms}{om}{%
  \IfNoValueTF{#1}{
    \newglossary{#2}{#2.in}{#2.out}{#2}%
    \renewcommand{\acronymtype}{#2}%
  }{
    \newglossary{#1}{#1.in}{#1.out}{#2}%
    \renewcommand{\acronymtype}{#1}%
  }
}
\fi

\endinput
%%
%% End of file `hep-paper.sty'.
