| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2019-2023 by Jan Hajer |
| 4 |
% ----------------------------------- |
| 5 |
% |
| 6 |
% This file may be distributed and/or modified under the |
| 7 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 8 |
% of this license or (at your option) any later version. |
| 9 |
% The latest version of this license is in: |
| 10 |
% |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% |
| 13 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 14 |
% version 2005/12/01 or later. |
| 15 |
% |
| 16 |
% \fi |
| 17 |
% |
| 18 |
% \iffalse |
| 19 |
% |
| 20 |
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01] |
| 21 |
%<package>\ProvidesPackage{hep-reference}[2025/09/01 v1.4 Convenience macros for references] |
| 22 |
%<documentation>\ProvidesFile{hep-reference-documentation.tex}[2025/09/01 v1.4 HEP-reference documentation] |
| 23 |
% |
| 24 |
%<*documentation> |
| 25 |
\documentclass{ltxdoc} |
| 26 |
|
| 27 |
\renewcommand*\theCodelineNo{\rmfamily\tstyle\footnotesize\arabic{CodelineNo}} |
| 28 |
\AtBeginEnvironment{macrocode}{\renewcommand*{\ttdefault}{clmt}} |
| 29 |
\renewcommand*{\MacroFont}{\codestyle} |
| 30 |
\AtBeginDocument{\DeleteShortVerb{\|}} |
| 31 |
\AtBeginDocument{\MakeShortVerb{\"}} |
| 32 |
\EnableCrossrefs |
| 33 |
\CodelineIndex |
| 34 |
\RecordChanges |
| 35 |
|
| 36 |
\usepackage{hologo} |
| 37 |
|
| 38 |
\usepackage[parskip,oldstyle,font=10pt]{hep-paper} |
| 39 |
\bibliography{bibliography} |
| 40 |
\shortacronym{PDF}{portable document format} |
| 41 |
%</documentation> |
| 42 |
|
| 43 |
%<*driver> |
| 44 |
\expandafter\newif\csname ifshort\endcsname |
| 45 |
\shortfalse |
| 46 |
\begin{document} |
| 47 |
\DocInput{hep-reference-implementation.dtx} |
| 48 |
\end{document} |
| 49 |
%</driver> |
| 50 |
% |
| 51 |
% \fi |
| 52 |
% |
| 53 |
% \CheckSum{181} |
| 54 |
% |
| 55 |
% \CharacterTable |
| 56 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 57 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 58 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 59 |
% Exclamation \! Double quote \" Hash (number) \# |
| 60 |
% Dollar \$ Percent \% Ampersand \& |
| 61 |
% Acute accent \' Left paren \( Right paren \) |
| 62 |
% Asterisk \* Plus \+ Comma \, |
| 63 |
% Minus \- Point \. Solidus \/ |
| 64 |
% Colon \: Semicolon \; Less than \< |
| 65 |
% Equals \= Greater than \> Question mark \? |
| 66 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 67 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 68 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 69 |
% Right brace \} Tilde \~} |
| 70 |
% |
| 71 |
% \changes{v1.0}{2011/08/01}{Initial version of the style file.} |
| 72 |
% \changes{v1.1}{2022/11/01}{Bug fixes.} |
| 73 |
% \changes{v1.2}{2023/07/01}{Bug fixes.} |
| 74 |
% \changes{v1.3}{2024/11/01}{Bug fixes.} |
| 75 |
% \changes{v1.4}{2025/09/01}{Bug fixes.} |
| 76 |
% |
| 77 |
% \ifshort |
| 78 |
%<*documentation> |
| 79 |
% \fi |
| 80 |
% |
| 81 |
\GetFileInfo{hep-reference.sty} |
| 82 |
|
| 83 |
\title{The \software{hep-reference} package\thanks{This document corresponds to \software{hep-reference}~\fileversion.}} |
| 84 |
\subtitle{Adjustments of standard references, footnote, and citations} |
| 85 |
\author{Jan Hajer \email{[email protected]}} |
| 86 |
\date{\filedate} |
| 87 |
|
| 88 |
% \ifshort |
| 89 |
\begin{document} |
| 90 |
% \fi |
| 91 |
|
| 92 |
\newgeometry{vscale=.8, vmarginratio=3:4, includeheadfoot, left=11em, marginparwidth=4.6cm, marginparsep=3mm, right=7em} |
| 93 |
|
| 94 |
\maketitle |
| 95 |
|
| 96 |
\begin{abstract} |
| 97 |
The \software{hep-reference} package applies some light convenience modifications to the reference, citation and footnote macros after loading standard classes improving on the default \hologo{LaTeX} behaviour. |
| 98 |
\end{abstract} |
| 99 |
|
| 100 |
\section{Introduction} |
| 101 |
|
| 102 |
The \software{hyperref} package is loaded and the links are hidden. |
| 103 |
|
| 104 |
\DescribeMacro{\cref} |
| 105 |
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}. |
| 106 |
Furthermore, the \software{cleveref} package allows to reference multiple objects within one "\cref"\marg{key1,key2}. |
| 107 |
|
| 108 |
\DescribeMacro{\cite} |
| 109 |
Citations are adjusted to not start on a new line in order to avoid the repeated use of "~\cite"\marg{key}. |
| 110 |
|
| 111 |
\DescribeMacro{\ref} |
| 112 |
\DescribeMacro{\eqref} |
| 113 |
\DescribeMacro{\subref} |
| 114 |
References are also adjusted to not start on a new line. |
| 115 |
|
| 116 |
\DescribeMacro{\footnote} |
| 117 |
Footnotes are adjusted to swallow white space before the footnote mark and at the beginning of the footnote text. |
| 118 |
Additionally the reference back to the text where they are called from. |
| 119 |
|
| 120 |
% \ifshort |
| 121 |
\printbibliography |
| 122 |
|
| 123 |
\end{document} |
| 124 |
% |
| 125 |
%</documentation> |
| 126 |
% \fi |
| 127 |
% |
| 128 |
% \StopEventually{ |
| 129 |
% \printbibliography |
| 130 |
% \PrintChanges |
| 131 |
% } |
| 132 |
% |
| 133 |
% \appendix |
| 134 |
% |
| 135 |
%<*package> |
| 136 |
% |
| 137 |
% \section{Implementation} |
| 138 |
% |
| 139 |
% Load the \software{hyperref} package \cite{hyperref} enable Unicode encoding and hide links. |
| 140 |
% \begin{macrocode} |
| 141 |
\RequirePackage{hyperref} |
| 142 |
\hypersetup{ |
| 143 |
pdfencoding=auto, psdextra, |
| 144 |
linktoc=all, hidelinks, breaklinks=true, |
| 145 |
pdfcreator={}, pdfproducer={} |
| 146 |
} |
| 147 |
\AtBeginDocument{\@ifpackageloaded{doc}{\hypersetup{hidelinks}}{}} |
| 148 |
% \end{macrocode} |
| 149 |
% |
| 150 |
% Ensure that unnecessary information is suppressed. |
| 151 |
% \begin{macrocode} |
| 152 |
\pdfstringdefDisableCommands{\def\varepsilon{\textepsilon}} |
| 153 |
\pdfstringdefDisableCommands{\def\to{\textrightarrow}} |
| 154 |
\AtBeginDocument{ |
| 155 |
\pdfstringdefDisableCommands{\let\ensuremath\@gobble} |
| 156 |
\pdfstringdefDisableCommands{\let\mathsurround\@gobble} |
| 157 |
\pdfstringdefDisableCommands{\let\unskip\@gobble} |
| 158 |
\pdfstringdefDisableCommands{\let\thanks\@gobble} |
| 159 |
\pdfstringdefDisableCommands{\let\footnote\@gobble} |
| 160 |
\pdfstringdefDisableCommands{\let\\\@gobble} |
| 161 |
} |
| 162 |
% \end{macrocode} |
| 163 |
% |
| 164 |
% Set the \PDF meta data according to the paper information |
| 165 |
% |
| 166 |
% \begin{macrocode} |
| 167 |
\AtBeginDocument{ |
| 168 |
\@ifundefined{@title}{}{ |
| 169 |
\@ifundefined{hep@sub@title}{ |
| 170 |
\hypersetup{pdftitle={\@title}} |
| 171 |
}{ |
| 172 |
\hypersetup{pdftitle={\@title: \hep@sub@title}} |
| 173 |
} |
| 174 |
} |
| 175 |
% \hypersetup{pdfauthor={\@author}} |
| 176 |
\@ifundefined{hep@key@words}{}{% |
| 177 |
\hypersetup{pdfkeywords={\hep@key@words}}% |
| 178 |
} |
| 179 |
} |
| 180 |
% \end{macrocode} |
| 181 |
|
| 182 |
% \subsection{Footnotes} |
| 183 |
% |
| 184 |
% Place a hyperlink from the footnote back to its referencing label using the \software{footnotebackref} package \cite{footnotebackref}. |
| 185 |
% \begin{macrocode} |
| 186 |
\def\BackrefFootnoteTag{} |
| 187 |
\RequirePackage{footnotebackref} |
| 188 |
% \end{macrocode} |
| 189 |
% |
| 190 |
% \begin{macro}{\footnote} |
| 191 |
% Ensure that no spaces appear before the footmark or at the beginning of the footnote. |
| 192 |
% \begin{macrocode} |
| 193 |
\let\@foot@note\footnote |
| 194 |
\renewcommand*{\footnote}[1]{\unskip\@foot@note{\ignorespaces#1}} |
| 195 |
% \end{macrocode} |
| 196 |
% \end{macro} |
| 197 |
|
| 198 |
% \subsection{References} |
| 199 |
% |
| 200 |
% \begin{macro}{\ref} |
| 201 |
% Adjust "\ref"\marg{key} in order to prevent preceding line breaks. |
| 202 |
% \begin{macrocode} |
| 203 |
\AtBeginDocument{ |
| 204 |
\let\hep@ref\ref |
| 205 |
\renewcommand*\ref{\no@break@before\hep@ref} |
| 206 |
} |
| 207 |
% \end{macrocode} |
| 208 |
% \end{macro} |
| 209 |
% |
| 210 |
% \begin{macro}{\eqref} |
| 211 |
% Adjust "\eqref"\marg{key} from the \software{amsmath} package in order to prevent preceding line breaks. |
| 212 |
% \begin{macrocode} |
| 213 |
\AtBeginDocument{\@ifpackageloaded{amsmath}{% |
| 214 |
\renewcommand*\eqref{\no@break@before\labelcref}% |
| 215 |
}{}} |
| 216 |
% \end{macrocode} |
| 217 |
% \end{macro} |
| 218 |
% |
| 219 |
% \begin{macro}{\usecommand} |
| 220 |
% Define the "\usecommand" macro providing an anonymous function. |
| 221 |
% \begin{macrocode} |
| 222 |
\providecommand*\hep@use@command{} |
| 223 |
\newcommand*\usecommand[2][1]{% |
| 224 |
\renewcommand*\hep@use@command[#1]{#2}\hep@use@command% |
| 225 |
} |
| 226 |
% \end{macrocode} |
| 227 |
% \end{macro} |
| 228 |
% |
| 229 |
% \begin{macro}{\textlabel} |
| 230 |
% Define the "\textlabel" macro allowing to link to a piece of text using the \software{etoolbox} pcakage \cite{etoolbox}. |
| 231 |
% \begin{macrocode} |
| 232 |
\RequirePackage{etoolbox} |
| 233 |
\NewDocumentCommand\textlabel{O{}mO{}m}{% |
| 234 |
\protected@write\@auxout{}{% |
| 235 |
\string\newlabel{#2}{% |
| 236 |
{\hspace{-4pt}\protecting{#1{#4}}}{\thepage}{#4}{#2}{}% |
| 237 |
}% |
| 238 |
}% |
| 239 |
\hypertarget{#2}{}% |
| 240 |
{#3{#4}}% |
| 241 |
} |
| 242 |
% \end{macrocode} |
| 243 |
% \end{macro} |
| 244 |
% |
| 245 |
% \begin{macro}{\cref} |
| 246 |
% Improve reference using the \software{cleveref} package \cite{cleveref}. |
| 247 |
% \begin{macrocode} |
| 248 |
\PassOptionsToPackage{noabbrev, nameinlink}{cleveref} |
| 249 |
\RequirePackage{cleveref} |
| 250 |
\newcommand*{\creflastconjunction}{, and\nobreakspace} |
| 251 |
\crefname{enumi}{point}{points} |
| 252 |
\crefname{inlinelisti}{point}{points} |
| 253 |
% \end{macrocode} |
| 254 |
% \end{macro} |
| 255 |
% |
| 256 |
%\begin{macro}{\no@break@before} |
| 257 |
% Define a macro able to prevent line breaks. |
| 258 |
% \begin{macrocode} |
| 259 |
\newcommand*\no@break@before{% |
| 260 |
\relax\ifvmode\else% |
| 261 |
\ifhmode% |
| 262 |
\ifdim\lastskip > 0pt% |
| 263 |
\relax\unskip\nobreakspace% |
| 264 |
\fi% |
| 265 |
\fi% |
| 266 |
\fi% |
| 267 |
} |
| 268 |
% \end{macrocode} |
| 269 |
% \end{macro} |
| 270 |
% |
| 271 |
% \begin{macro}{\subref} |
| 272 |
% Adjust "\subref"\marg{key} from the \software{subcaption} package in order to prevent preceding line breaks. |
| 273 |
% \begin{macrocode} |
| 274 |
\AtBeginDocument{\@ifpackageloaded{subcaption}{% |
| 275 |
\let\hep@subref\subref |
| 276 |
\renewcommand*\subref{\no@break@before\hep@subref} |
| 277 |
\renewcommand*\subcaption@ref[2]{\begingroup% |
| 278 |
\caption@setoptions{sub}% |
| 279 |
\subcaption@reffmt\p@subref{\hep@ref#1{sub@#2}}% |
| 280 |
\endgroup} |
| 281 |
% \end{macrocode} |
| 282 |
% \end{macro} |
| 283 |
% |
| 284 |
% \begin{macro}{\subcref} |
| 285 |
% Provide the "\subcref" macro. |
| 286 |
% \begin{macrocode} |
| 287 |
\newcommand*{\subcref}[1]{\cref{sub@#1}} |
| 288 |
}{}} |
| 289 |
% \end{macrocode} |
| 290 |
% \end{macro} |
| 291 |
% |
| 292 |
% \begin{macro}{\eqcrefname} |
| 293 |
% Define the "\eqcrefname" macro for named equation types. |
| 294 |
% \begin{macrocode} |
| 295 |
\NewDocumentCommand{\eqcrefname}{mmo}{ |
| 296 |
\crefname{#1}{#2}{\IfValueTF{#3}{#3}{#2s}} |
| 297 |
\creflabelformat{#1}{(##2##1##3)} |
| 298 |
} |
| 299 |
% \end{macrocode} |
| 300 |
% \end{macro} |
| 301 |
% |
| 302 |
% \begin{macro}{\labelcrefrange} |
| 303 |
% Define the missing "\labelcrefrange"\marg{key1}\marg{key2} macro. |
| 304 |
% \begin{macrocode} |
| 305 |
\DeclareRobustCommand{\labelcrefrange}[2]{% |
| 306 |
\@crefrangenostar{labelcref}{#1}{#2}% |
| 307 |
} |
| 308 |
% \end{macrocode} |
| 309 |
% \end{macro} |
| 310 |
% |
| 311 |
% Adjust the title page |
| 312 |
% \begin{macrocode} |
| 313 |
\AtBeginDocument{\@ifpackageloaded{hep-title}{% |
| 314 |
\labelcrefmultiformat{affiliation}{#2#1#3}{% |
| 315 |
\textsuperscript,#2#1#3}{\textsuperscript,#2#1#3% |
| 316 |
}{% |
| 317 |
\textsuperscript,#2#1#3% |
| 318 |
} |
| 319 |
\labelcrefrangeformat{affiliation}{#3#1#4\textsuperscript{--}#5#2#6} |
| 320 |
}{}} |
| 321 |
% \end{macrocode} |
| 322 |
|
| 323 |
% \subsection{Citations} |
| 324 |
% |
| 325 |
% \begin{macro}{\cite} |
| 326 |
% Adjust "\cite"\marg{key} in order to prevent preceding line breaks. |
| 327 |
% \begin{macrocode} |
| 328 |
\let\hep@cite\cite |
| 329 |
\renewcommand*\cite{\no@break@before\hep@cite} |
| 330 |
% \end{macrocode} |
| 331 |
% \end{macro} |
| 332 |
% |
| 333 |
%</package> |
| 334 |
% |
| 335 |
% \section{Tests} |
| 336 |
% |
| 337 |
%<*test> |
| 338 |
% |
| 339 |
% \begin{macrocode} |
| 340 |
\documentclass{article} |
| 341 |
|
| 342 |
\usepackage{amsmath} |
| 343 |
\usepackage{hep-reference} |
| 344 |
\usepackage{parskip} |
| 345 |
\providecommand*{\cref}{section \ref} |
| 346 |
|
| 347 |
\begin{document} |
| 348 |
|
| 349 |
\section{Section} \label{sec:Section} |
| 350 |
|
| 351 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
| 352 |
Etiam lobortis section \ref{sec:Section} |
| 353 |
|
| 354 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
| 355 |
Etiam lobortis \cref{sec:Section} |
| 356 |
|
| 357 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
| 358 |
Etiam loborti equation \eqref{eq:Equation} |
| 359 |
|
| 360 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
| 361 |
Etiam loborti reference \cite{cite} |
| 362 |
|
| 363 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
| 364 |
\footnote{ |
| 365 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
| 366 |
} |
| 367 |
|
| 368 |
\begin{equation} \label{eq:Equation} |
| 369 |
E=mc^2 |
| 370 |
\end{equation} |
| 371 |
|
| 372 |
|
| 373 |
\begin{thebibliography}{1} |
| 374 |
\bibitem{cite} reference |
| 375 |
\end{thebibliography} |
| 376 |
|
| 377 |
\end{document} |
| 378 |
% \end{macrocode} |
| 379 |
% |
| 380 |
%</test> |
| 381 |
% |
| 382 |
% \section{Readme} |
| 383 |
% |
| 384 |
%<*readme> |
| 385 |
% |
| 386 |
% \begin{macrocode} |
| 387 |
# The `hep-reference` package |
| 388 |
|
| 389 |
A `LaTeX` package for publications in High Energy Physics. |
| 390 |
|
| 391 |
## Introduction |
| 392 |
|
| 393 |
The `hep-reference` package applies some light convenience modifications |
| 394 |
to the reference, citation and footnote macros after loading standard |
| 395 |
classes improving on the default LaTeX behaviour. |
| 396 |
|
| 397 |
## Author |
| 398 |
|
| 399 |
Jan Hajer |
| 400 |
|
| 401 |
## License |
| 402 |
|
| 403 |
This file may be distributed and/or modified under the conditions of the |
| 404 |
`LaTeX` Project Public License, either version 1.3c of this license or |
| 405 |
(at your option) any later version. The latest version of this license is |
| 406 |
in `http://www.latex-project.org/lppl.txt` and version 1.3c or later is |
| 407 |
part of all distributions of LaTeX version 2005/12/01 or later. |
| 408 |
% \end{macrocode} |
| 409 |
% |
| 410 |
%</readme> |
| 411 |
% |
| 412 |
% \Finale |
| 413 |
|
| 414 |
\endinput |
| 415 |
|
| 416 |
% \PrintIndex |
| 417 |
% makeindex -s gglo.ist -o hep-reference-implementation.gls hep-reference-implementation.glo |
| 418 |
% makeindex -s gglo.ist -o hep-reference-implementation.ind hep-reference-implementation.idx |