Skip to content

Commit

Permalink
Merge pull request #59 from threema-theo/error-option
Browse files Browse the repository at this point in the history
Add option 'error' for undefined acronym handling
  • Loading branch information
oetiker authored Jan 17, 2025
2 parents 64627d4 + 066a6a8 commit 1b22bc6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 19 deletions.
24 changes: 14 additions & 10 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 1.49 (Sep 2024)
- Adds error option
-- Theo von Arx

Version 1.48 (Mar 2024)

- Adds noforwardlinks option
Expand All @@ -24,7 +28,7 @@ Version 1.45 (Mar 2020)

- Fixed hyperref regression and the longstanding "missing aux" bug.
-- Marcus Meeßen

Version 1.44 (Feb 2020)

- added the |printonlyreused| option, which allows to automatically exclude acronyms from the list of acronyms if they are used only once
Expand Down Expand Up @@ -54,7 +58,7 @@ two features were added -- Oz Davidi
* Now it is possible to forbid a line break between the full name and the short name (when they are printed together). It is possible to control it individually (for each command), and also globally (with the |nolinebreak| option).
* Added the \Ac{p,f,fp,l,lp,lu} commands. They work exactly the same way as the \ac commands, but prints the full name, starting with an upper case letter (in case it was defined with a lower case letter).

correting issue with long lines due to carriage return misplaced -- Philippe Chauvat
correting issue with long lines due to carriage return misplaced -- Philippe Chauvat

Version 1.41 (Mar 2015)

Expand All @@ -76,7 +80,7 @@ has its optional argument provided
Version 1.38 (Oct 2012)

add support for dynamic indefinite articles depending on the acronym form used
-- Ash Hughes
-- Ash Hughes

fix for non hyphenation of first word in long form
-- Martin Rüßler
Expand Down Expand Up @@ -133,14 +137,14 @@ Version 1.26 (June 2006) supress lone item when nolist is in effect
Version 1.25 (November 2005) properly handle acronyms in pdfbookmarks
-- Heiko Oberdiek <oberdiek there uni-freiburg.de>

Version 1.24 (October 2005) ac* commands are now not fragile anymore ...
Version 1.24 (October 2005) ac* commands are now not fragile anymore ...
-- José Emilio Vila Forcén jose.vila there cui.unige.ch

Version 1.23 (October 2005) fixed typo in nolist option. added comment about fragility of ac commands.
-- Tobias Oetiker (tobi with oetiker.ch)

Version 1.22 (October 2005) added starred versions of ac(p), acf(p), acs(p),
acl(p), acfi, acsu & aclu
acl(p), acfi, acsu & aclu
-- Stefan Pinnow (Mo-Gul here gmx.net)

Version 1.21 (September 2005): fixed the \acused command again ... broke it
Expand Down Expand Up @@ -207,8 +211,8 @@ acronym. Add footnote optional out for \cmd{\acs}. Fix for list of acronyms
in front matter and addition of \cmd{\acroextra} command.
-- Danie Els <dnjels there sun.ac.za>

Version 1.9 (October 2003): Fix hyperref processing to work regardles
of calling order. 'printused' now prints every acronym used not only
Version 1.9 (October 2003): Fix hyperref processing to work regardles
of calling order. 'printused' now prints every acronym used not only
the ones called through \ac.
-- Danie Els <dnjels there sun.ac.za> and Tobi Oetiker

Expand All @@ -218,12 +222,12 @@ definition.
-- Martin Salois <Martin.Salois there drdc-rddc.gc.ca>

Version 1.7 (September 2003): Added \acresetall for resetting the 'used'-tag
of \ac. With the new option 'printonlyused', the acronym-list will consist of
the used acronyms only and not of all defined acronyms; Optional in a special
of \ac. With the new option 'printonlyused', the acronym-list will consist of
the used acronyms only and not of all defined acronyms; Optional in a special
deflist - environment.
-- Sebastian Max <smx there comnets.rwth-aachen.de>

Version 1.6 (May 2000): Added the smaller option and the macros \acsfont,
Version 1.6 (May 2000): Added the smaller option and the macros \acsfont,
\acffont, and \acfsfont used to control the appearance of \acs and \acf.
-- Ingo Lepper <lepper there math.uni-muenster.de>

Expand Down
48 changes: 39 additions & 9 deletions acronym.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%</driver>
% \fi
%
% \CheckSum{1640}
% \CheckSum{1664}
%
%% \CharacterTable
%% {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
Expand Down Expand Up @@ -73,7 +73,7 @@
% \DoNotIndex{\makelabel, \mathrm}
% \DoNotIndex{\NeedsTeXFormat, \newcommand, \newenvironment,
% \newif, \newtoks, \noexpand, \nolinebreak, \null}
% \DoNotIndex{\PackageWarning, \ProcessOptions, \protect,
% \DoNotIndex{\PackageWarning, \PackageError, \ProcessOptions, \protect,
% \protected@write, \providecommand, \ProvidesPackage}
% \DoNotIndex{\raggedright, \ref, \relax, \renewcommand,
% \RequirePackage}
Expand All @@ -82,7 +82,7 @@
% \DoNotIndex{\textbf, \textsf, \textsmaller, \textsuperscript, \the}
% \DoNotIndex{\usepackage}
%
% \changes{v1.50}{2025/01/16}{Fix for github issue\#60, issues with ltx and amsmath}
% \changes{v1.50}{2025/01/16}{Theo von Arx adds the option 'error' to throw errors upon undefined acronyms, Tobi integrates patches for issue/60 ltx and amsmath}
% \changes{v1.49}{2024/03/30}{Chris Landis adds noforwardlinks option and fixes targets for forward links to acs/acl/etc.-only use}
% \changes{v1.48}{2021/10/09}{Bruno Le Floch corrected capitalization of acronyms with a custom plural form.}
% \changes{v1.47}{2020/04/10}{Tobi Oetiker and Marcus Meeßen \cmd{hskip} Fixed several bugs in macros that use capitalisation, a bug were the output depends on the position of the list of acronyms, and a bug were nested hyperlinks could cause errors.}
Expand Down Expand Up @@ -695,8 +695,8 @@ blocks to be tested separately. The latter are commonly indicated as
% First we test that we got the right format and name the package.
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{acronym}[2024/03/30
v1.49
\ProvidesPackage{acronym}[2025/01/17
v1.50
Support for acronyms (Tobias Oetiker)]
\RequirePackage{suffix,xstring}
% \end{macrocode}
Expand All @@ -705,6 +705,17 @@ blocks to be tested separately. The latter are commonly indicated as
%
% \subsection{Options}
%
% \begin{macro}{\ifAC@error}
% The option |error| lets this package throw compile errors instead of warnings in case of undefined acronyms.
% \begin{macrocode}
\newif\ifAC@error
\AC@errorfalse
% \end{macrocode}
% \begin{macrocode}
\DeclareOption{error}{\AC@errortrue}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifAC@footnote}
% The option |footnote| leads to a redefinition of \cmd{\acf},
% \cmd{\Acf}, \cmd{\acfp}, and \cmd{\Acfp}, making the full name appear
Expand Down Expand Up @@ -1512,18 +1523,37 @@ blocks to be tested separately. The latter are commonly indicated as
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\AC@get}
% If the acronym is undefined, the internal macro \cmd{\AC@get}
% warns the user by printing the name in bold with an exclamation
% \begin{macro}{\AC@logundefined}
% The internal macro \cmd{\AC@logundefined} either throws a warning or an error
% (if option |error| is set) and prints the name of the acronym in bold with an exclamation
% mark at the end.
% \begin{macrocode}
\newcommand\AC@logundefined[1]{%
\ifAC@error%
\ifx\AC@populated\AC@used%
\PackageError{acronym}{#1}{You should define the acronym with
\protect\acrodef, \protect\newacro, or \protect\acro.}
\else%
\PackageWarning{acronym}{#1}%
\fi%
\else%
\PackageWarning{acronym}{#1}%
\fi%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\AC@get}
% If the acronym is undefined, call the internal macro \cmd{\AC@undefined}
% for error handling.
% If defined, \cmd{\AC@get} uses the same mechanism used by the LaTeX
% kernel commands \cmd{\ref} and \cmd{\pageref} to return the short
% \cmd{\AC@acs} and long forms \cmd{\AC@acl} of the acronym
% saved in \fnacro.
% \begin{macrocode}
\newcommand*\AC@get[3]{%
\ifx#1\relax
\PackageWarning{acronym}{Acronym `#3' is not defined}%
\AC@logundefined{Acronym #3 is not defined}%
\textbf{#3!}%
\else
\@firstupper@maybe{\expandafter#2#1}%
Expand Down

0 comments on commit 1b22bc6

Please sign in to comment.