%% %% This is file `hep-acronym.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% hep-acronym-implementation.dtx (with options: `package') %% This is a generated file. %% 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. \NeedsTeXFormat{LaTeX2e}[2005/12/01] \ProvidesPackage{hep-acronym}[2023/07/01 v1.2 Acronyms using glossaries] \RequirePackage{kvoptions} \SetupKeyvalOptions{ family=hepacronym, prefix=hepacronym@ } \DeclareBoolOption[true]{hyper} \ProcessKeyvalOptions* \PassOptionsToPackage{nostyles}{glossaries-extra} \RequirePackage{glossaries-extra} \glsenableentrycount \glssetcategoryattribute{abbreviation}{entrycount}{1} \AtBeginDocument{ \@ifpackageloaded{hyperref}{ \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}% }% }} }{} } \newcommand{\hep@disable}[1]{% \@ifpackageloaded{hyperref}{\pdfstringdefDisableCommands{#1}}{}% } \ifhepacronym@hyper\else \glsdisablehyper \fi \PassOptionsToPackage{excludeor}{everyhook} \RequirePackage{everyhook} \newcommand{\begin@sentence}{1001} \newcommand{\sentence}{\spacefactor=\begin@sentence} \hep@disable{\renewcommand\sentence{}} \PushPostHook{par}{{\sentence}} \gdef\ttl@case{\leavevmode\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}% }} \RequirePackage{xparse} \ProvideDocumentCommand{\mathdef}{mO{0}m}{% \expandafter\let\csname hep@text\string#1\endcsname=#1 \expandafter\newcommand\csname hep@math\string#1\endcsname[#2]{#3} \DeclareRobustCommand#1{% \ifmmode \expandafter\let\expandafter\next\csname% hep@math\string#1\endcsname% \else \expandafter\let\expandafter\next\csname% hep@text\string#1\endcsname% \fi \next }% } \RequirePackage{xspace} \RequirePackage{amstext} \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[1][]{% \if@begin@of@sentence{% \ifglsused{#3}{\cgls{#3}[##1]}{\cGls{#3}[##1]}% }{\cgls{#3}[##1]}% \ifnum\glsentrycurrcount{#3}>1\relax \IfBooleanTF{#4}{}{\@\xspace}% \else\@\xspace\fi } \hep@disable{\expandafter\def\csname#3\endcsname{% \IfNoValueTF{#2}{#3}{#2} }% } \expandafter\mathdef\csname#3\endcsname{% \mathinner{\text{\glsxtrshort{#3}}}\@gls@increment@currcount{#3}% } \expandafter\newcommand\csname#3s\endcsname[1][]{% \if@begin@of@sentence{\cGlspl{#3}[##1]}{\cglspl{#3}[##1]}% \IfBooleanTF{#4}{}{\@\xspace}% } \hep@disable{\expandafter\def\csname#3s\endcsname{% \IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}} }% } \expandafter\mathdef\csname#3s\endcsname{% \mathinner{\text{\glsxtrshortpl{#3}}}\@gls@increment@currcount{#3}% } \expandafter\newcommand\csname#3long\endcsname[1][]{% \if@begin@of@sentence{\Glsdesc*{#3}[##1]}{\glsdesc*{#3}[##1]}% \IfBooleanTF{#4}{}{\@\xspace}% } \hep@disable{\expandafter\def\csname#3long\endcsname{#5 }} \expandafter\newcommand\csname#3slong\endcsname[1][]{% \if@begin@of@sentence{% \Glsxtrlongpl*{#3}[##1]}{\glsxtrlongpl*{#3}[##1]% }% \IfBooleanTF{#4}{}{\@\xspace}% } \hep@disable{\expandafter\def\csname#3slong\endcsname{% \IfNoValueTF{#6}{#5s}{#6} }% } } \NewDocumentCommand{\shortacronym}{somsmo}{ \expandafter\newcommand\csname#3\endcsname[1][]{% \IfNoValueTF{#2}{#3}{#2}\IfBooleanTF{#4}{}{\@\xspace}##1% } \hep@disable{\expandafter\def\csname#3\endcsname{% \IfNoValueTF{#2}{#3}{#2} }% } \expandafter\mathdef\csname#3\endcsname{% \mathinner{\text{\IfNoValueTF{#2}{#3}{#2}}}% } \expandafter\newcommand\csname#3s\endcsname[1][]{% \IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}}% \IfBooleanTF{#4}{}{\@\xspace}##1% } \hep@disable{\expandafter\def\csname#3s\endcsname{% \IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}} }% } \expandafter\mathdef\csname#3s\endcsname{% \mathinner{\text{\IfBooleanTF{#1}{#3}{\IfNoValueTF{#2}{#3s}{#2s}}}}% }% \expandafter\let\csname#3long\expandafter\endcsname\csname#3\endcsname \expandafter\let\csname#3slong\expandafter\endcsname\csname#3s\endcsname } \NewDocumentCommand{\longacronym}{somsmo}{ \expandafter\newcommand\csname#3\endcsname[1][]{% \if@begin@of@sentence{\MakeUppercase#5}{#5}% \IfBooleanTF{#4}{}{\@\xspace}##1% } \hep@disable{\expandafter\def\csname#3\endcsname{#5 }} \expandafter\newcommand\csname#3s\endcsname[1][]{% \if@begin@of@sentence{% \IfNoValueTF{#6}{\MakeUppercase#5s}{\MakeUppercase#6}% }{% \IfNoValueTF{#6}{#5s}{#6}}\IfBooleanTF{#4}{}{\@\xspace}##1% } \hep@disable{\expandafter\def\csname#3s\endcsname{% \IfNoValueTF{#6}{#5s}{#6} }% } \expandafter\let\csname#3long\expandafter\endcsname\csname#3\endcsname \expandafter\let\csname#3slong\expandafter\endcsname\csname#3s\endcsname } \NewDocumentCommand{\acronymalternative}{mmsm}{% \GlsXtrSetField{#1}{useri}{#4}% \expandafter\newcommand\csname#2\endcsname[1][]{% \let\hep@glsaccesslong\glsaccesslong% \let\hep@Glsaccesslong\Glsaccesslong% \let\glsaccesslong\glsuseri% \let\Glsaccesslong\Glsuseri% \if@begin@of@sentence{% \ifglsused{#1}{\cgls{#1}[##1]}{\cGls{#1}[##1]}% }{\cgls{#1}[##1]}% \let\glsaccesslong\hep@glsaccesslong% \let\Glsaccesslong\hep@Glsaccesslong% \ifnum\glsentrycurrcount{#1}>1\relax% \IfBooleanTF{#3}{}{\@\xspace}% \else\@\xspace\fi% } \hep@disable{\expandafter\def\csname#2\endcsname{% \csname#1\endcsname }% } \expandafter\mathdef\csname#2\endcsname{% \mathinner{\text{\glsxtrshort{#1}}}\@gls@increment@currcount{#1}% } \expandafter\newcommand\csname#2long\endcsname[1][]{% \let\hep@glsentrydesc\glsentrydesc% \let\hep@Glsentrydesc\Glsentrydesc% \renewrobustcmd*{\glsentrydesc}[1]{\@gls@entry@field{#1}{useri}}% \renewrobustcmd*{\Glsentrydesc}[1]{\@Gls@entry@field{#1}{useri}}% \if@begin@of@sentence{\Glsdesc*{#1}[##1]}{\glsdesc*{#1}[##1]}% \IfBooleanTF{#3}{}{\@\xspace}% \let\glsentrydesc\hep@glsentrydesc% \let\Glsentrydesc\hep@Glsentrydesc% } \hep@disable{% \expandafter\def\csname#2long\endcsname{% \@Gls@entry@field{#1}{useri} % }% }% } \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}% } } \endinput %% %% End of file `hep-acronym.sty'.