% \iffalse meta-comment
%
% Copyright (C) 2019-2023 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.
%
% \fi
%
% \iffalse
%
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<package>\ProvidesPackage{hep-paper}[2023/07/01 v2.2 Publications in High Energy Physics]
%<documentation>\ProvidesFile{hep-paper-documentation.tex}[2023/07/01 v2.2 HEP-Paper documentation]
%
%<*documentation>
\RequirePackage[l2tabu, orthodox]{nag}
\documentclass{ltxdoc}

\renewcommand\theCodelineNo{\rmfamily\tstyle\footnotesize\arabic{CodelineNo}}
\AtBeginEnvironment{macrocode}{\renewcommand{\ttdefault}{clmt}}
\renewcommand{\MacroFont}{\codestyle}
\AtBeginDocument{\DeleteShortVerb{\|}}
\AtBeginDocument{\MakeShortVerb{\"}}
\EnableCrossrefs
\CodelineIndex
\RecordChanges

\usepackage{hologo}

\usepackage[parskip,oldstyle,font=10pt]{hep-paper}
\bibliography{bibliography}
\acronym{PDF}{portable document format}
\acronym{LM}{latin modern}
%</documentation>

%<*driver>
\expandafter\newif\csname ifshort\endcsname
\shortfalse
\begin{document}
\DocInput{hep-paper-implementation.dtx}
\end{document}
%</driver>
%
% \fi
%
% \changes{v1.0}{2019/01/01}{Initial version of the style file.}
% \changes{v1.1}{2020/01/01}{Transition to documented \hologo{LaTeX} source file.}
% \changes{v1.2}{2020/03/01}{Introduction of package options.}
% \changes{v1.3}{2020/05/01}{Inclusion of JHEP and JCAP package options. Fix of incompatibility with recent subcaption package version. Move of biblatex datamodel into its own file}
% \changes{v1.4}{2020/09/01}{If possible the compatibility options are selected automatically. Inclusion of PubMed IDs in bibliography.}
% \changes{v1.5}{2020/10/01}{Reduce the numer of math alphabets used in sans serif mode. Add more title options such as a subtitle. Use standard class options.}
% \changes{v1.6}{2020/12/01}{Implementation of the twocolumn mode.}
% \changes{v1.7}{2021/06/01}{Introduction of dedicated style file for the title, acronyms and bibliography macros. Extension of the title macros.}
% \changes{v1.8}{2021/08/01}{Expand thanks to allow for reference label and fine tune the title page. Reimplement the must relevant macros from the physics package. Make mathrm produce upright Greek.}
% \changes{v2.0}{2021/09/01}{Move independent logic into dedicated packages.}
% \changes{v2.1}{2023/07/01}{Bug fixes in the underlying packages.}
%
% \ifshort
%<*documentation>
% \fi
%
\GetFileInfo{hep-paper.sty}

\title{The \software{hep-paper} package\thanks{This document corresponds to \software{hep-paper}~\fileversion.}}
\subtitle{Publications in high energy physics}
\author{Jan Hajer \email{jan.hajer@tecnico.ulisboa.pt}}
\date{\filedate}

% \ifshort
\begin{document}
% \fi

\maketitle

\begin{abstract}
The \software{hep-paper} package aims to provide a single style file containing most configurations and macros necessary to write appealing publications in High Energy Physics.
Instead of reinventing the wheel by introducing newly created macros \software{hep-paper} preferably loads third party packages.
\end{abstract}

\tableofcontents\clearpage

\newgeometry{vscale=.8, vmarginratio=3:4, includeheadfoot, left=11em, marginparwidth=4.6cm, marginparsep=3mm, right=7em}

\section{Introduction}

For usual publications it is enough to load additionally to the "article" class without optional arguments only the \software{hep-paper} package \cite{hep-paper}.
\begin{verbatim}
\documentclass{article}
\usepackage{hep-paper}
\end{verbatim}
The most notable changes after loading the \software{hep-paper} package is the change of some \hologo{LaTeX} defaults.
The paper and font sizes are set to A4 and \unit[11]{pt}, respectively.
Additionally, the paper geometry is adjusted using the \software{geometry} package \cite{geometry}.
Furthermore, the font is changed to \LM using the \software{hep-font} package \cite{hep-font}.
Finally, \PDF hyperlinks are implemented with the \software{hyperref} package \cite{hyperref}.

\subsection{Options}

\DescribeMacro{paper}
The "paper="\meta{format} option loads the specified paper format.
The possible \meta{formats} are:
"a0", "a1", "a2", "a3", "a4", "a5", "a6",
"b0", "b1", "b2", "b3", "b4", "b5", "b6",
"c0", "c1", "c2", "c3", "c4", "c5", "c6",
"ansia", "ansib", "ansic", "ansid", "ansie",
"letter", "executive", "legal".
The default is "a4".

\DescribeMacro{font}
The "font="\meta{size} option loads the specified font size.
The possible \meta{sizes} are:
"8pt", "9pt", "10pt", "11pt", "12pt", "14pt", "17pt", "20pt".
The default is \unit[11]{pt}.

\DescribeMacro{lang}
The "lang"=\meta{name} option switches the document language.
The default is "british".

\DescribeMacro{sansserif}
The "sansserif" option switches the document including math to sans serif font shape.

\DescribeMacro{oldstyle}
The "oldstyle" option activates the use of oldstyle text- (\texto{123}) in favour of lining- (\textl{123}) figures in text mode.

\DescribeMacro{parskip}
The "parskip" option changes how paragraphs are separated from each other using the \software{parskip} package \cite{parskip}.
The \hologo{LaTeX} default is separation via indentation the "parskip" option switches to separation via vertical space.
\footnote{Although the "parskip" option is used for this document, it is recommended only for very few document types such as technical manuals or answers to referees.}

\DescribeMacro{symbols}
The "symbols"=\meta{family} is passed to the \software{hep-math-font} package \cite{hep-math-font} and sets the family of the symbol fonts.
"symbols=false" deactivates loading any additional symbol fonts.

\subsubsection{Deactivation}

The \software{hep-paper} package loads few bigger packages which have a large impact on the document.
The deactivation options can prevent such and other adjustments.

\DescribeMacro{defaults}
The "defaults" option prevents the adjustment of the page geometry and the font size set by the document class.

\DescribeMacro{title}
The "title=false" option deactivates the title page adjustments.

\DescribeMacro{bibliography}
The "bibliography"=\meta{key} option prevents the automatic loading of the \software{hep-bibliography} package \cite{hep-bibliography} if \meta{key}="false".

\DescribeMacro{glossaries}
The "glossaries=false" option deactivates acronyms and the use of the \software{hep-acronym} package \cite{hep-acronym}.

\DescribeMacro{references}
The "references=false" option prevents the \software{cleveref} package \cite{cleveref} from being loaded and deactivates further redefinitions of reference macros.

\subsubsection{Compatibility}

The compatibility options activate the compatibility mode for certain classes and packages used for publications in high energy physics.
They are mostly suitable combinations of options described in the previous section.
If \software{hep-paper} is able to detect the presence of such a class or package, \ie if it is loaded before the \software{hep-paper} package, the compatibility mode is activated automatically.

\DescribeMacro{beamer}
The "beamer" option activates the \software{beamer} \cite{beamer} compatibility mode.

\DescribeMacro{jhep}
The "jhep" option activates the \software{JHEP} \cite{jhep} compatibility mode.

\DescribeMacro{jcap}
The "jcap" option activates the \software{JCAP} \cite{jcap} compatibility mode.

\DescribeMacro{revtex}
The "revtex" option activates the REV\hologo{TeX} \cite{revtex} compatibility mode.

\DescribeMacro{pos}
The "pos" option activates the \software{PoS} compatibility mode.

\DescribeMacro{springer}
The "springer" option activates the compatibility mode the "svjour" class \cite{svjour}.

\subsubsection{Reactivation}

The \software{hep-paper} package deactivates unrecommended macros, which can be reactivated manually.

\DescribeMacro{manualplacement}
The "manualplacement" option reactivates manual float placement.

\DescribeMacro{eqnarray}
The "eqnarray" option reactivates the depreciated "eqnarray" environment.

\section{Macros and environments}

\DescribeMacro{twocolumn}
\DescribeMacro{abstract*}
If the global "twocolumn" option is present the page geometry is changed to cover almost the entire page.
Additionally the "abstract*" environment is defined that generates a one column abstract and takes care of placing the title information.

\subsection{Title page} \label{sec:title}

\DescribeMacro{\series}
The "\series"\marg{series} macro is defined using the \software{hep-title} package \cite{hep-title}.

\DescribeMacro{\title}
The \PDF meta information is set according to the "\title"\marg{text} and "\author"\marg{text} information.

\DescribeMacro{\subtitle}
The "\subtitle"\marg{subtitle} macro is defined.

\DescribeMacro{\editor}
\DescribeMacro{\author}
\DescribeMacro{\affiliation}
\DescribeMacro{\email}
The following lines add \eg two authors with different affiliations
\begin{verbatim}
\author[1]{Author one \email{email one}}
\affiliation[1]{Affiliation one}
\author[2]{Author two \email{email two}}
\affiliation[1,2]{Affiliation two}
\end{verbatim}

\DescribeMacro{\preprint}
The "\preprint"\marg{numer} macro places a pre-print number in the upper right corner of the title page.

\DescribeEnv{abstract}
The "abstract" environment is adjusted to not start with an indentation.

\DescribeMacro{\titlefont}
\DescribeMacro{\subtitlefont}
\DescribeMacro{\authorfont}
\DescribeMacro{\affiliationfont}
\DescribeMacro{\preprintfont}
Various title font macros are defined, allowing to change the appearance of the "\maketitle" output.

\subsection{Text}

\DescribeMacro{inlinelist}
\DescribeMacro{enumdescript}
The "inlinelist" and "enumdescript" environments are defined.

\DescribeMacro{\textsc}
A bold versions \textbf{\textsc{Small Caps}} and a sans serif version of \textsf{\textsc{Small Caps}} is provided.

\DescribeMacro{\underline}
\DescribeMacro{\overline}
The "\underline" macro is redefined to allow line-breaks.
The "\overline" macro is extended to also \overline{overline} text outside of math environments.

\DescribeMacro{\useparskip}
\DescribeMacro{\useparindent}
If the "parskip" option is activated the "\useparindent" macro switches to the usual parindent mode, while the "\useparskip" macro switches to the parskip mode.

\subsubsection{References and footnotes}

\DescribeMacro{\cref}
References are extended with the \software{cleveref} package \cite{cleveref}, which allows to \eg just type "\cref"\marg{key}  in order to write \enquote{figure 1}.
Furthermore, the \software{cleveref} package allows to reference multiple objects within one "\cref"\marg{key1,key2}.

\DescribeMacro{\cite}
Citations are adjusted to not start on a new line in order to avoid the repeated use of "~\cite"\marg{key}.

\DescribeMacro{\ref}
\DescribeMacro{\eqref}
\DescribeMacro{\subref}
References are also adjusted to not start on a new line.

\DescribeMacro{\footnote}
Footnotes are adjusted to swallow white space before the footnote mark and at the beginning of the footnote text.

\subsubsection{Acronyms} \label{sec:acronyms}

The \software{hep-acronym} package \cite{hep-acronym} is loaded.
\DescribeMacro{\acronym}
\DescribeMacro{\shortacronym}
\DescribeMacro{\longacronym}
The "\acronym"\meta{*}\oarg{typeset abbreviation} \marg{abbreviation}\meta{*}\marg{definition}\oarg{plural definition} macro generates the singular "\"\meta{abbreviation} and plural "\"\meta{abbreviation}"s" macros.
The first star prevents the addition of an \enquote{s} to the abbreviation plural.
The second star restores the \hologo{TeX} default of swallowing subsequent white space.
The long form is only shown at the first appearance of these macros, later appearances generate the abbreviation with a hyperlink to the long form.
The long form is never used in math mode.
Capitalization at the beginning of paragraphs and sentences is (mostly) ensured.
The "\shortacronym" and "\longacronym" macros are drop-in replacements of the "\acronym" macro showing only the short or long form of their acronym.

\subsection{Math}

The \software{hep-math} \cite{hep-math} and \software{hep-math-font} \cite{hep-math-font} packages are loaded.
\DescribeMacro{\mathbf}
Bold math, via "\mathbf" is improved, \ie ($ A  b  \Gamma \delta \mathbf A \mathbf b \mathbf \Gamma \mathbf \delta$).
Macros switching to "bfseries" such as "\section"\marg{text} are ensured to also typeset math in bold.
\DescribeMacro{\text}
The "\text"\marg{text} macro makes it possible to write text within math mode, \ie ($ \text A  \text b  \text \Gamma \text \delta \text{\textbf A} \text{\textbf b} \text{\textbf \Gamma} \text{\textbf \delta}$).
\DescribeMacro{\mathsf}
The math sans serif alphabet is redefined to be italic sans serif if the main text is serif and italic serif if the main text is sans serif, \ie ($\mathsf A \mathsf b \mathsf \Gamma \mathsf \delta \mathbf{\mathsf A} \mathbf{\mathsf b} \mathbf{\mathsf \Gamma} \mathbf{\mathsf \delta}$).
\DescribeMacro{\mathscr}
The "\mathcal" font \ie ($\mathcal{ABCD}$) is accompanied by the "\mathscr" font \ie ($\mathscr{ABCD}$).
\DescribeMacro{\mathbb}
The "\mathbb" font is adjusted depending on the "sansserif" option \ie ($\mathbb{Ah1}$).
\DescribeMacro{\mathfrak}
Finally, the "\mathfrak" font is also available \ie ($\mathfrak{AaBb12}$).

\DescribeMacro{\nicefrac}
\DescribeMacro{\flatfrac}
\DescribeMacro{\textfrac}
The "\frac"\marg{number}\marg{number} macro is accompanied by "\nicefrac"\linebreak[1]\marg{number}\linebreak[1]\marg{number}, "\textfrac"\marg{number}\marg{number}, and "\flatfrac"\marg{number}\marg{number} leading to $\frac12$, $\nicefrac12$, \textfrac12, and $\flatfrac12$.
\DescribeMacro{\diag}
\DescribeMacro{\sgn}
Diagonal matrix "\diag" and signum "\sgn" operators are defined.

\DescribeMacro{\mathdef}
The "\mathdef"\marg{name}\oarg{arguments}\marg{code} macro \prefix{re}{defines} macros only within math mode without changing the text mode definition.

\DescribeMacro{\i}
\DescribeMacro{\d}
The imaginary unit $\i$ and the differential $\d$ are defined using this functionality.

\DescribeMacro{\numberwithin}
For longer paper it can be useful to re-number the equation in accordance with the section numbering "\numberwithin{equation}{section}".
\DescribeMacro{subequations}
In order to further reduce the size the of equation counter it can be useful to wrap "align" environments with multiple rows in a "subequations" environment.

\DescribeMacro{\unit}
\DescribeMacro{\inv}
The correct spacing for units, \cf \cref{eq:greek}, is provided by the macro "\unit"\oarg{value} \marg{unit} which can also be used in text mode.
The macro "\inv"\oarg{power}\marg{text} allows to avoid math mode also for inverse units such as \unit[5]{\inv{fb}} typeset via "\unit[5]{\inv{fb}}".

Greek letters are adjusted to always be italic and upright in math and text mode, respectively, using the \software{hep-math-font} \cite{hep-math-font} package.
This allows differentiations like
\begin{align} \label{eq:greek}
\sigma &= \unit[5]{fb} \ , & &\mbox{at \unit[5]{\sigma} C.L.} \ , & \mu &= \unit[5]{cm} \ , & l &= \unit[5]{\mu m} \ .
\end{align}
Additionally, Greek letters can also be directly typed using Unicode.

\DescribeMacro{\ev}
\DescribeMacro{\pdv}
\DescribeMacro{\comm}
\DescribeMacro{\order}
The \software{hep-math} package \cite{hep-math} provides additional macros such as
\begin{align}
&\ev{\phi} \ ,
&&\pdv[f]{x}[y]^2 \ ,
&&\comm{A}{B} \ ,
&&\order{x^2} \ ,
&&\eval{x}_0^\infty \ ,
&&\det(M)\ .
\end{align}

\DescribeMacro{\cancel}
\DescribeMacro{\slashed}
The "\cancel"\marg{characters} macro and the "\slashed" \marg{character} macro allow to $\cancel{\text{cancel}}$ math and use the Dirac slash notation \ie $\slashed \partial$, respectively.

\DescribeMacro{\overleftright}
A better looking over left right arrow is defined \ie $\overleftright{\partial}$.

\subsection{Floats}

\DescribeEnv{figure}
\DescribeEnv{table}
Automatic float placement is adjusted to place a single float at the top of pages and to reduce the number of float pages, using the \software{hep-float} package \cite{hep-float}.
The most useful float placement is usually archived by placing the float \emph{in front} of the paragraph it is referenced in first.

\DescribeEnv{panels}
\DescribeMacro{\panel}
The "panels" environment provides sub-floats and takes as mandatory argument either the number of sub-floats (default~2) or the width of the first sub-float as fraction of the "\linewidth".
Within the "\begin{panels}"\oarg{vertical alignment}\marg{width} environment the "\panel" macro initiates a new sub-float.
In the case that the width of the first sub-float has been given as an optional argument to the "panels" environment the "\panel"\marg{width} macro takes the width of the next sub-float as mandatory argument.

\DescribeMacro{\graphic}
\DescribeMacro{\graphics}
The "\graphic"\oarg{width}\marg{figure} macro is defined, which is a wrapper for the "\includegraphics"\marg{figure} macro and takes the figure width as fraction of the "\linewidth" as optional argument (default~1).
If the graphics are located in a sub-folder its path can be indicated by "\graphics"\marg{subfolder}.

\subsection{Bibliography} \label{sec:bibliography}

\DescribeMacro{\bibliography}
\DescribeMacro{\printbibliography}
The \software{biblatex} package \cite{biblatex} is loaded for bibliography management.
The user has to add the line "\bibliography"\marg{my.bib} to the preamble of the document and "\printbibliography" at the end of the document.
The bibliography is generated by \software{Biber} \cite{biber}.
\software{biblatex} is extended by the \software{hep-bibliography} package \cite{hep-bibliography} to be able to cope with the "collaboration" and "reportNumber" fields provided by \online{https://inspirehep.net}{inspirehep.net} and a bug in the volume number is fixed.
Additionally, the PubMed IDs are recognized and \online{https://ctan.org}{ctan.org}, \online{https://github.com}{github.com}, \online{https://gitlab.com}{gitlab.com}, \online{https://bitbucket.org}{bitbucket.org}, \online{https://www.launchpad.net}{launchpad.net}, \online{https://sourceforge.net}{sourceforge.net}, and \online{https://hepforge.org}{hepforge.org} are valid "eprinttype"s.
\DescribeMacro{erratum}
Errata can be included using the "related" feature.
\begin{verbatim}
\article{key1,
  ...,
  relatedtype="erratum",
  related="key2",
}
\article{key2,
  ...,
}
\end{verbatim}

\section{Conclusion}

The \software{hep-paper} package provides a matching selection of preloaded packages and additional macros enabling the user to focus on the content instead of the layout by reducing the amount of manual tasks.
The majority of the loaded packages are fairly lightweight, the others can be deactivated with package options.

\DescribeMacro{arxiv-collector}
\nolinkurl{arxiv.org} \cite{arxiv} requires the setup dependent "bbl" files instead of the original "bib" files, which causes trouble if the local \hologo{LaTeX} version differs from the one used by arXiv.
The \software{arxiv-collector} python script \cite{arxiv-collector} alleviates this problem by collecting all files necessary for publication on arXiv (including figures).

% \ifshort
\printbibliography

\end{document}
%
%</documentation>
% \fi
%
% \StopEventually{
% \printbibliography
% \PrintChanges
% }
%
% \addtocontents{toc}{\protect\clearpage}
% \clearpage
% \appendix
%
% \section{Options}
%
%<*package>
%
% Load the \software{kvoptions} package \cite{kvoptions} and define a "hep" namespace.
%    \begin{macrocode}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
  family=hep,
  prefix=hep@
}
%    \end{macrocode}
%
% \begin{macro}{paper}
% Define a "paper="\meta{size} option.
% Make A4 paper the default.
%    \begin{macrocode}
\DeclareStringOption[a4]{paper}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{font}
% Define a "figures="\meta{size} option.
% Make \unit[11]{pt} the default font size.
%    \begin{macrocode}
\DeclareStringOption[11pt]{font}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{lang}
% Define the "lang" option, which takes the values provided by the \software{babel} package \cite{babel}.
% Make "british" the default language.
%    \begin{macrocode}
\DeclareStringOption[british]{lang}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{sansserif}
% Define the option pair "serif" and "sansserif" controling the font shape of the whole document.
%    \begin{macrocode}
\DeclareBoolOption[true]{serif}
\DeclareComplementaryOption{sansserif}{serif}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{lining}
% Define the "lining" option deactivating the use of text figures in text mode.
%    \begin{macrocode}
\DeclareBoolOption[true]{lining}
\DeclareComplementaryOption{oldstyle}{lining}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{parskip}
% Define the option pair "parindent" and "parskip" controlling the separation of paragraphs.
%    \begin{macrocode}
\DeclareBoolOption[true]{parindent}
\DeclareComplementaryOption{parskip}{parindent}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{symbols}
% Provide the "symbols" option allowing to switch the symbol font.
%    \begin{macrocode}
\DeclareStringOption[true]{symbols}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Deactivation}
%
% \begin{macro}{defaults}
% Define the "defaults" option which deactivates the "paper" and "font" options and prevents the change of the class defaults by this package.
%    \begin{macrocode}
\DeclareBoolOption[false]{defaults}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{title}
% Provide the "title" option deactivating redefinitions of title macros.
%    \begin{macrocode}
\DeclareBoolOption[true]{title}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{physics}
% Provide the "physics" option for deactivating redefinition of physics macros.
%    \begin{macrocode}
\DeclareBoolOption[true]{physics}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{bibliography}
% Provide the "bibliography" option for passing a "style" string to the \software{biblatex} package \cite{biblatex} or disabling the automatic loading of "biblatex".
%    \begin{macrocode}
\DeclareStringOption[numeric-comp]{bibliography}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{glossaries}
% Provide the "glossaries" option able to turn of the use of the \software{hep-acronym} package \cite{hep-acronym}.
%    \begin{macrocode}
\DeclareBoolOption[true]{glossaries}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{references}
% Provide the "references" option for preventing the \software{cleveref} package from being loaded redefinitions of reference macros.
%    \begin{macrocode}
\DeclareBoolOption[true]{references}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Compatibility}
%
% \begin{macro}{beamer}
% Provide the "beamer" option for \software{beamer} \cite{beamer} compatibility mode.
%    \begin{macrocode}
\DeclareBoolOption[false]{beamer}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{revtex}
% Provide the "revtex" option for REV\hologo{TeX} \cite{revtex} compatibility mode.
%    \begin{macrocode}
\DeclareBoolOption[false]{revtex}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{jhep}
% Provide the "jhep" option for JHEP \cite{jhep} compatibility mode.
%    \begin{macrocode}
\DeclareBoolOption[false]{jhep}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{jcap}
% Provide the "jcap" option for JCAP \cite{jcap} compatibility mode.
%    \begin{macrocode}
\DeclareBoolOption[false]{jcap}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{pos}
% Provide the "pos" option for PoS compatibility mode.
%    \begin{macrocode}
\DeclareBoolOption[false]{pos}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{springer}
% Provide the "springer" option for Springer compatibility mode.
%    \begin{macrocode}
\DeclareBoolOption[false]{springer}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{amsart}
% Provide the "amsart" option for AMS article compatibility mode.
%    \begin{macrocode}
\DeclareBoolOption[false]{amsart}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Reactivation}
%
% \begin{macro}{eqnarray}
% Provide the "eqnarray" option for reactivating the "eqnarray" environment.
%    \begin{macrocode}
\DeclareBoolOption[true]{eqnarray}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{manualplacement}
% Provide the "manualplacement" option for reactivating the manual placement of floats.
%    \begin{macrocode}
\DeclareBoolOption[false]{manualplacement}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Process options}
%
%    \begin{macrocode}
\ProcessKeyvalOptions*
%    \end{macrocode}
%
% Read the class options regarding font and paper size.
%    \begin{macrocode}
\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}%
}{}
%    \end{macrocode}
%
% \subsection{Set compatibility}
%
% Set the "amsart" compatibility options using the \software{xpatch} package \cite{xpatch}.
%    \begin{macrocode}
\@ifclassloaded{amsart}{\setkeys{hep}{amsart}}{}
\ifhep@amsart
  \setkeys{hep}{defaults, title=false}
  \RequirePackage{xpatch}
  \xpretocmd{\@adminfootnotes}{\let\@makefntext\BHFN@OldMakefntext}{}{}
\fi
%    \end{macrocode}
%
% Set the "springer" compatibility options.
%    \begin{macrocode}
\@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
%    \end{macrocode}
%
% Set the "pos" compatibility options.
%    \begin{macrocode}
\@ifclassloaded{PoS}{\setkeys{hep}{pos}}{}
\ifhep@pos
  \setkeys{hep}{defaults, title=false}
  \DeclareRobustCommand\boldmath{\@nomath\boldmath\mathversion{bold}}
\fi
%    \end{macrocode}
%
% Set the "beamer" compatibility options.
%    \begin{macrocode}
\@ifclassloaded{beamer}{\setkeys{hep}{beamer}}{}
\ifhep@beamer
  \setkeys{hep}{defaults, title=false, references=false, sansserif}
  \@ifpackageloaded{beamerbasefont}{\usefonttheme{professionalfonts}}{}
  \setbeamertemplate{navigation symbols}{}
\fi
%    \end{macrocode}
%
% Set the "revtex" compatibility options.
%    \begin{macrocode}
\@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
%    \end{macrocode}
%
% Define the SISSA conditional.
%    \begin{macrocode}
\@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
%    \end{macrocode}
%
% Set the SISSA compatibility options.
%    \begin{macrocode}
\ifhep@sissa
  \setkeys{hep}{defaults, 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}
  \AtBeginDocument{\renewcommand{\foreignabbrfont}{}}
\fi
\ifhep@jhep
    \PassOptionsToPackage{\hep@paper paper}{geometry}
    \RequirePackage{geometry}
    \geometry{
      offset=0in,textheight=.762\paperheight,textwidth=.72\paperwidth
    }
\fi
%    \end{macrocode}
%
% \section{Font} \label{sec:font}
%
% Load the \software{hep-font} package \cite{hep-font}.
%    \begin{macrocode}
\PassOptionsToPackage{
  size=\hep@font,
  sans=\ifhep@serif false\else true\fi,
  lining=\ifhep@lining true\else false\fi
}{hep-font}
\RequirePackage{hep-font}
%    \end{macrocode}
%
% \subsection{Math fonts}
%
% Load the \software{hep-math-font} package \cite{hep-math-font}.
%    \begin{macrocode}
\PassOptionsToPackage{symbols=\hep@symbols}{hep-math-font}
\RequirePackage{hep-math-font}
%    \end{macrocode}
%
% \section{Geometry}
%
% Load the \software{geometry} package \cite{geometry} and adjust the text width and height.
% This step must happen after readjusting the font size in \cref{sec:font}.
%    \begin{macrocode}
\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
%    \end{macrocode}
%
%\begin{macro}{\useparskip}
%\begin{macro}{\useparindent}
% Load the \software{parskip} package \cite{parskip} if requested and provide two commands switching between the two paragraph modes.
%    \begin{macrocode}
\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
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{Text}
%
% Load the \software{hep-text} package \cite{hep-text}.
%    \begin{macrocode}
\PassOptionsToPackage{lang=\hep@lang}{hep-text}
\RequirePackage{hep-text}
%    \end{macrocode}
%
% \section{Math}
%
% Load the \software{hep-math} package \cite{hep-math}.
%    \begin{macrocode}
\ifhep@physics\RequirePackage{hep-math}\fi
%    \end{macrocode}
%
% \section{Floats}
%
% Adjust the \hologo{LaTeX} float placement defaults using the \software{hep-float} package \cite{hep-float}.
%    \begin{macrocode}
\PassOptionsToPackage{
  manualplacement=\ifhep@manualplacement true\else false \fi
}{hep-float}
\RequirePackage{hep-float}
%    \end{macrocode}
%
% \begin{macro}{\ifhep@journal}
% Define a new journal conditional.
%    \begin{macrocode}
\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
%    \end{macrocode}
% \end{macro}
%
% Prevent the \software{caption} package \cite{caption} from complaining about the journal classes and packages.
%    \begin{macrocode}
\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
%    \end{macrocode}
%
% Readjust the document captions to look like the original revtex captions using the \software{ragged2e} package \cite{ragged2e}.
%    \begin{macrocode}
\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
%    \end{macrocode}
%
% \section{Title page}
%
% Adjust the title page using the \software{hep-title} package \cite{hep-title}.
%    \begin{macrocode}
\ifhep@title\RequirePackage{hep-title}\fi
%    \end{macrocode}
%
% \section{Bibliography}
%
% Check if bibliography management is requested using the \software{pdftexcmds} package \cite{pdftexcmds}.
% And load the \software{hep-bibliography} package \cite{hep-bibliography}
%    \begin{macrocode}
\RequirePackage{pdftexcmds}
\ifnum\pdf@strcmp{\hep@bibliography}{false}=0\else
  \PassOptionsToPackage{style=\hep@bibliography}{hep-bibliography}
  \RequirePackage{hep-bibliography}
\fi
%    \end{macrocode}

% \section{Hyperlinks, Footnotes and References} \label{sec:hyperlinks}
%
% Load the \software{hep-reference} package \cite{hep-reference}.
%
%    \begin{macrocode}
\ifhep@references
\RequirePackage{hep-reference}
%    \end{macrocode}
%
% Set the \PDF meta data according to the paper information and ensure that unnecessary information is suppressed.
%    \begin{macrocode}
\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
    \ifhep@pos\else\AtBeginDocument{\hypersetup{pdfauthor={\@author}}}\fi
  \fi
\fi
%    \end{macrocode}
%
% End of "references" conditional
%    \begin{macrocode}
\fi
%    \end{macrocode}

% \section{Acronyms}
%
% Define acronyms if not deactivated.
% Acronyms are implemented in the \software{hep-acronym} package \cite{hep-acronym} and must be loaded after the \software{hyperref} package in \cref{sec:hyperlinks}.
% Set the abbreviation style.
%    \begin{macrocode}
\ifhep@glossaries\RequirePackage{hep-acronym}\fi
%    \end{macrocode}
%
%</package>
%
% \section{Tests}
%
% \subsection{JHEP}
%
%<*testJHEP>
%
%    \begin{macrocode}
\documentclass[a4paper, 11pt]{article}

\usepackage{jheppub}
\usepackage[lang=english]{hep-paper}
\usepackage[math]{blindtext}

\begin{document}

\title{Title}

\emailAdd{first@email.com}
\author[a]{First author}
\emailAdd{second@email.com}
\author[b]{Second author}
\affiliation[a]{First affiliation}
\affiliation[b]{Second affiliation}

\abstract{\blindtext}

\maketitle

\Blinddocument

\end{document}
%    \end{macrocode}
%
%</testJHEP>
%
% \subsection{JCAP}
%
%<*testJCAP>
%
%    \begin{macrocode}
\documentclass[a4paper, 11pt]{article}

\usepackage{jcappub}
\usepackage[lang=english]{hep-paper}
\usepackage[math]{blindtext}

\begin{document}

\title{Title}

\emailAdd{first@email.com}
\author[a]{First author}
\emailAdd{second@email.com}
\author[b]{Second author}
\affiliation[a]{First affiliation}
\affiliation[b]{Second affiliation}

\abstract{\blindtext}

\maketitle

\Blinddocument

\end{document}
%    \end{macrocode}
%
%</testJCAP>
%
% \subsection{AMSArt}
%
%<*testAMSArt>
%
%    \begin{macrocode}
\documentclass{amsart}

\usepackage[lang=english]{hep-paper}
\usepackage[math]{blindtext}

\title{title}

\author{Author}
\address{Address 1}
\email{first@email.com}
\author{Author 2}
\email{second@email.com}
\address{Address 2}

\date{date}

\begin{document}

\begin{abstract}
\blindtext
\end{abstract}

\maketitle

\Blinddocument

\end{document}
%    \end{macrocode}
%
%</testAMSArt>
%
% \subsection{Beamer}
%
%<*testBeamer>
%
%    \begin{macrocode}
\documentclass{beamer}

\usepackage[lang=english]{hep-paper}
\usepackage[math]{blindtext}

\title{Title}
\subtitle{Subtitle}
\author{Author}
\institute{Institute}
\date{Event}

\begin{document}

\frame{\titlepage}

\begin{frame}{Frame title}
\blindtext
\end{frame}

\end{document}
%    \end{macrocode}
%
%</testBeamer>
%
% \subsection{PoS}
%
%<*testPoS>
%
%    \begin{macrocode}
\documentclass{PoS}

\usepackage[lang=english,title=false]{hep-paper}
\usepackage[math]{blindtext}

\title{Title}

\author{First author \thanks{first@email.com}}
\author{
\speaker{Second author is speaker}\\
First affiliation\\
E-mail: \email{second@email.com}
}
\author{Third author \thanks{\email{third@email.com}}\\
Second affiliation}
\author{Fourth author\\Third affiliation}
\FullConference{Full conference}
\ShortTitle{Short title}

\begin{abstract}
\blindtext
\end{abstract}

\begin{document}

\Blinddocument

\end{document}
%    \end{macrocode}
%
%</testPoS>
%
% \subsection{RevTeX}
%
%<*testRevTeX>
%
%    \begin{macrocode}
\documentclass[
 aps,
 prl,
 reprint,
 nofootinbib,
 nobibnotes,
 superscriptaddress,
 preprintnumbers,
]{revtex4-2}

\usepackage{hep-paper}
\usepackage[math]{blindtext}

\begin{document}

\title{Title}

\author{First author}
\email[E-mail me at: ]{first@email.com}
\affiliation{First affiliation}
\author{Second author}
\email{second@email.com}
\affiliation{Second affiliation}
\affiliation{Third affiliation}
\author{Third author}
\affiliation{Fourth affiliation}

\begin{abstract}
\blindtext
\end{abstract}

\maketitle

\Blinddocument

\end{document}
%    \end{macrocode}
%
%</testRevTeX>
%
% \subsection{Springer}
%
%<*testSpringer>
%
%    \begin{macrocode}
\documentclass[twocolumn,epjc3]{svjour3}

\usepackage[lang=english]{hep-paper}
\usepackage[math]{blindtext}

\journalname{Journal name}

\title{Title\thanksref{title}}

\titlerunning{Short title}

\subtitle{Subtitle}

\thankstext{title}{Title thanks}

\authorrunning{Short form of author list}

\thankstext{email1}{e-mail: first@email.com}
\thankstext{email2}{e-mail: second@email.com}

\institute{
  First address \label{address1} \and
  Second address \label{address2} \and
  \emph{Present Address:} if needed\label{address3}
}

\date{Received: date / Accepted: date}

\begin{document}

\author{
  First Author\thanksref{email1,address1} \and
  Second Author\thanksref{email2,address2,address3}
}

\maketitle

\begin{abstract}
\blindtext
\end{abstract}

\Blinddocument

\end{document}
%    \end{macrocode}
%
%</testSpringer>
%
% \section{Readme}
%
%<*readme>
%
%    \begin{macrocode}
# The `hep-paper` package

A `LaTeX` package for publications in High Energy Physics.

## Introduction

The `hep-paper` package aims to provide a single style file containing
most configurations and macros necessary to write appealing publications
in High Energy Physics. Instead of reinventing the wheel by introducing
newly created macros `hep-paper` preferably loads third party packages as
long as they are lightweight enough.

For usual publications it is enough to load additionally to the `article`
class without optional arguments only the `hep-paper` package.

    \documentclass{article}
    \usepackage{hep-paper}

## Author

Jan Hajer

## License

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.
%    \end{macrocode}
%
%</readme>
%
% \Finale

\endinput

% \PrintIndex
% makeindex -s gglo.ist -o hep-paper-implementation.gls hep-paper-implementation.glo
% makeindex -s gglo.ist -o hep-paper-implementation.ind hep-paper-implementation.idx

% \begin{macro}{\refstepcounter@...}
% Adjust the "cleveref" "\refstepcounter@noarg" and "\refstepcounter@optarg" to use the "\@currentlabel" in order to fix problems with "\subref".
%    \begin{macrocode}
% \def\refstepcounter@noarg#1{%
%   \cref@old@refstepcounter{#1}%
%   \cref@constructprefix{#1}{\cref@result}%
%   \@ifundefined{cref@#1@alias}%
%     {\def\@tempa{#1}}%
%     {\def\@tempa{\csname cref@#1@alias\endcsname}}%
%   \protected@edef\cref@currentlabel{%
%     [\@tempa][\arabic{#1}][\cref@result]%
%     \noexpand\@currentlabel%
%   }% changed
% }
%
% \def\refstepcounter@optarg[#1]#2{%
%   \cref@old@refstepcounter{#2}%
%   \cref@constructprefix{#2}{\cref@result}%
%   \@ifundefined{cref@#1@alias}%
%     {\def\@tempa{#1}}%
%     {\def\@tempa{\csname cref@#1@alias\endcsname}}%
%   \protected@edef\cref@currentlabel{%
%     [\@tempa][\arabic{#2}][\cref@result]%
%     \noexpand\@currentlabel% changed
%   }%
% }
% %    \end{macrocode}
% % \end{macro}
%
%
% \RequirePackage{contour}
% \renewcommand{\ULdepth}{1.8pt}
% \contourlength{0.8pt}
% \newcommand{\myuline}[1]{%
%   \uline{\phantom{#1}}\llap{\contour{white}{#1}}%
% }

% \begin{macro}{\mathpzc}
% Define the "\mathpzc" math script font based on the Zapf Chancery PostScript font.
%    \begin{macrocode}
% \DeclareFontFamily{OT1}{pzc}{}
% \DeclareFontShape{OT1}{pzc}{m}{it}{<-> s * [1.15] pzcmi7t}{}
% \DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}
%    \end{macrocode}
% \end{macro}
