summaryrefslogtreecommitdiff
path: root/macros/latex/contrib
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-08-14 03:04:22 +0000
committerNorbert Preining <norbert@preining.info>2023-08-14 03:04:22 +0000
commit8360ddccbd0538a65b33a2474e0b3b79acd83dab (patch)
treee7e1f700abecf0a8c5e813512cb1ca60434a6d5a /macros/latex/contrib
parent03f1daec22e3e5e2ae8d117d503ee9648c5b3f91 (diff)
CTAN sync 202308140304
Diffstat (limited to 'macros/latex/contrib')
-rw-r--r--macros/latex/contrib/xpunctuate/README.md (renamed from macros/latex/contrib/xpunctuate/README)12
-rw-r--r--macros/latex/contrib/xpunctuate/xpunctuate-doc.pdfbin0 -> 271385 bytes
-rw-r--r--macros/latex/contrib/xpunctuate/xpunctuate.dtx474
-rw-r--r--macros/latex/contrib/xpunctuate/xpunctuate.ins61
-rw-r--r--macros/latex/contrib/xpunctuate/xpunctuate.pdfbin212109 -> 0 bytes
5 files changed, 352 insertions, 195 deletions
diff --git a/macros/latex/contrib/xpunctuate/README b/macros/latex/contrib/xpunctuate/README.md
index 56d28e886f..3b627e1ac3 100644
--- a/macros/latex/contrib/xpunctuate/README
+++ b/macros/latex/contrib/xpunctuate/README.md
@@ -3,14 +3,16 @@
| abbreviations, as and when necessary |
| (along the lines of xspace). |
| |
- | Philip G. Ratcliffe - version 1.0 (2012/05/23) |
+ | Philip G. Ratcliffe - version 2.0 (2023/08/13) |
--------------------------------------------------------
+* LaTeX xpunctuate.ins to produce xpunctuate.sty
+
* Copy xpunctuate.sty to one of your TeX input directories.
* LaTeX xpunctuate.dtx for usage instructions and documentation.
-This is the first public release of the "xpunctuate" package; it defines
+This is the first revision of the "xpunctuate" package; it defines
commands for typesetting, e.g., abbreviations where the trailing period may
clash with a sentence terminator. More precisely it avoids the natural
problem of definitions such as \def\etc{\emph{etc}.}, which may then cause
@@ -18,4 +20,8 @@ double periods if used at the end of sentences, such as ... cats, dogs \etc.
It also deals with optional commas, which again may be rendered unnecessary by
the presence of a following sentence terminator.
-Change history: v1.0 first official release. \ No newline at end of file
+Change history:
+v2.0 overhauled all user commands, introduced \NewDocumentCommand,
+ added \xspaceafter.
+v1.0 first official release.
+
diff --git a/macros/latex/contrib/xpunctuate/xpunctuate-doc.pdf b/macros/latex/contrib/xpunctuate/xpunctuate-doc.pdf
new file mode 100644
index 0000000000..32c9282723
--- /dev/null
+++ b/macros/latex/contrib/xpunctuate/xpunctuate-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/xpunctuate/xpunctuate.dtx b/macros/latex/contrib/xpunctuate/xpunctuate.dtx
index 6aaabd6138..fc16a9c8f0 100644
--- a/macros/latex/contrib/xpunctuate/xpunctuate.dtx
+++ b/macros/latex/contrib/xpunctuate/xpunctuate.dtx
@@ -1,31 +1,53 @@
% \iffalse meta-comment
%
-% Copyright (C) 2012 by Philip G. Ratcliffe <philip.ratcliffe@uninsubria.it>
+% File: xpunctuate.dtx
%
-% This file may be distributed and/or modified under the conditions of
-% the LaTeX Project Public License, either version 1.2 of this license
-% or (at your option) any later version. The latest version of this
-% license is in:
+% Copyright (C) 2023 by Philip G. Ratcliffe <philip.ratcliffe@uninsubria.it>
+%
+% It may be distributed and/or modified under the conditions of the
+% LaTeX Project Public License (LPPL), either version 1.3c of this
+% license or (at your option) any later version.
+% The latest version of this license is in the file
%
% http://www.latex-project.org/lppl.txt
%
-% and version 1.2 or later is part of all distributions of LaTeX
-% version 1999/12/01 or later.
+% This file is part of the "xpunctuate package" (the Work in LPPL)
+% and all files in that package must be distributed together.
+%
+% The released version of this package is available from CTAN.
+%
+% This package has the LPPL maintenance status "maintained".
+%
+% The current maintainer of this package is Philip G. Ratcliffe.
+%
+% This work consists of the files xpunctuate.dtx and xpunctuate.ins
+% and the derived file xpunctuate.sty.
%
% \fi
%
% \iffalse
%
-%<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01]
%<package>\ProvidesPackage{xpunctuate}
-%<package> [2012/05/21 v1.0 trailing punctuation package (PGR)]
+%<package> [2023/08/13 v2.0 punctuation after command names (PGR)]
%
%<*driver>
-\documentclass{ltxdoc}
+\documentclass[british]{ltxdoc}
\usepackage{xpunctuate}
+%
+\NewDocElement[macrolike=false]{Generic}{generic}
+\renewcommand\thefootnote{\color{red}{\emph{\alph{footnote}}}}
+\newenvironment{codelist}
+ {\begin{list}{}{\setlength\leftmargin{3em}}\item[]}{\end{list}}
+\newcommand\eg{\xperiodafter{\emph{e}.\emph{g}}}
+\newcommand\ie{\xperiodafter{\emph{i}.\emph{e}}}
+%
\CodelineIndex
\EnableCrossrefs
\RecordChanges
+\DoNotIndex{\def,\let,\futurelet}
+\DoNotIndex{\if,\else,\fi,\ifx,\fi,\iftrue,\fi,\iffalse,\fi}
+\DoNotIndex{\the,\csname,\endcsname,\expandafter,\noexpand,\protect}
%
\begin{document}
\DocInput{xpunctuate.dtx}
@@ -33,7 +55,7 @@
%</driver>
% \fi
%
-% \CheckSum{144}
+% \CheckSum{154}
%
% \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
@@ -51,157 +73,258 @@
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
-%
% \changes{v1.0}{2012/05/21}{first public release}
+% \changes{v2.0}{2023/08/13}{general upgrade}
%
% \GetFileInfo{xpunctuate.sty}
%
% \DoNotIndex{\CodelineIndex,\EnableCrossrefs,\RecordChanges}
%
-% \title{
-% The \textsf{xpunctuate}\relax
-% \thanks{
-% This file has version number \fileversion, and revision date \filedate.}
-% \space
-% package for \LaTeX2e
-% }
-% \author{
-% Philip G. Ratcliffe\thanks{E-mail: \textsf{philip.ratcliffe@uninsubria.it}}
-% \\
-% Dipartimento di Scienze e Alta Tecnologia
-% \\
-% Universit\`{a} degli Studi dell'Insubria---Como
-% }
+% \title{The \texttt{xpunctuate} package for \LaTeX2e
+% \\[1ex] \small (\fileversion, last revision \filedate)}
+%
+% \author{Philip G. Ratcliffe
+% \\[1ex] \small \textsf{philip.ratcliffe@uninsubria.it}
+% \\[2ex] \small Dipartimento di Scienza e Alta Tecnologia
+% \\ \small Universit\`a degli Studi dell'Insubria---Como
+% \\ \small and
+% \\ \small Istituto Nazionale di Fisica Nucleare
+% \\ \small Sezione di Milano Bicocca}
%
% \date{}
%
% \maketitle
%
% \begin{abstract}
-% This package affords the user or package writer post-macro punctuation
-% insertion, \emph{i.e.}, beyond (but similar to) that of the |xspace| package.
-% Three new commands are defined: |\xperiod|, |\xcomma| and |\xperiodcomma|,
-% which, following a similar procedure to the standard |\xspace| macro, are
-% designed to insert the relevant punctuation \emph{if and only if} necessary.
+% The |xpunctuate| package provides package writers and ordinary users with
+% automatic post-macro punctuation insertion, \ie beyond (but similar to) that
+% of the |xspace| package, which is required here. Three new macros are
+% defined: |\xperiod|, |\xcomma| and |\xperiodcomma|, designed to insert the
+% required punctuation marks \emph{if and only if} necessary, following a
+% similar procedure to the |xspace| package. A further four macros
+% (|\xspaceafter|, |\xperiodafter|, |\xcommaafter| and |\xperiodcommaafter|)
+% are constructed to avoid the small superfluous space after possible font
+% changes (such as |\emph|) that involve the correction |\/|, which would
+% otherwise be hidden.
% \end{abstract}
%
% \section{Introduction}
%
-% The present package is mainly intended for package writers and provides
-% additional post-macro punctuation insertion, similar to that of the |xspace|
-% package. Three new commands are defined: |\xperiod|, |\xcomma| and
-% |\xperiodcomma|, which, in an analogous fashion to the standard |\xspace|
-% macro, insert the relevant punctuation where necessary.
+% The present package is mainly intended for package writers, but may also
+% serve the ordinary user; it provides additional post-macro punctuation
+% insertion, similar to that of the |xspace| package. Three new macros are
+% defined: |\xperiod|, |\xcomma| and |\xperiodcomma|, which, in an analogous
+% fashion to the standard |\xspace| macro, insert any relevant punctuation
+% where necessary. Four additional macros, of the form |\x|\dots|after|, avoid
+% the small superfluous space due to the following period or comma being
+% isolated from a preceding~|\/|.
%
-% \section{Usage}
+% \section{Package call}
%
-% The package is loaded via a standard package call: |\usepackage{xpunctuate}|.
-% There are at present no user options.
+% \DescribeGeneric{package call}
+% The package is loaded via a standard call:
+% \begin{codelist}
+% |\usepackage{xpunctuate}|
+% \end{codelist}
%
-% \subsection{User commands}
+% \subsection{User options}
+%
+% \DescribeGeneric{user options}
+% There are at present \emph{no} user options.
+%
+% \subsection{User macros}
%
-% The package defines three user commands, each having two variants.
+% Three user macros are defined, each having a pre-punctuation space-correcting
+% variant, plus a similar extension of the |\xspace| macro.
%
% \DescribeMacro{\xperiod}
% The purpose of this macro is to insert a period if not found as the
% successive \LaTeX\ input token. Typical use will be in defining
-% abbreviations, where there may or may not be a following ``accidental''
-% sentence-terminating period. The definition of |\xperiod| is such that if it
-% is followed by a period, then this is considered as a sentence terminator and
-% the appropriate trailing space is inserted. However, when no explicit period
-% follows, the occurrence is assumed to be mid-sentence and therefore normal
-% inter-word spacing is used.
+% abbreviations, where there may or may not be a following \emph{accidental}
+% sentence-terminating full stop. If \emph{no} explicit period follows, one is
+% inserted, the occurrence is assumed to be mid-sentence and therefore normal
+% inter-word spacing is applied. However, if it \emph{is} followed by a period,
+% then this is considered to be a sentence terminator, it is left as is with no
+% further insertions and the appropriate trailing space will then naturally
+% ensue.
+%
+% After defining |\newcommand{\gb}{G.B\xperiod}|, the command |\gb| will
+% determine when to insert a period after itself and when not, with also the
+% correct mid-sentence or end-of-sentence spacing as required. Thus, the input
+% \newcommand{\gb}{G.B\@\xperiod}
+% \begin{codelist}
+% |\gb is a very nice place to live.\\|\\
+% |I live in \gb. It is a small island off the coast of France|\\
+% |\gb\footnote{The small island off the coast of France.}|\\
+% |is a very nice place to live.|
+% \end{codelist}
+% results in the output
+% \begin{codelist}
+% \gb is a very nice place to live.\\
+% I live in \gb. It is a small island off the coast of France.\\
+% \gb\footnote{The small island off the coast of France.}
+% is a very nice place to live.
+% \end{codelist}
%
% \DescribeMacro{\xcomma}
-% The purpose of this macro is to insert a comma if not found as the next
-% token. Typical use will be following an object such as ``\emph{e.g.}'', which
-% according to certain standard style manuals should be followed by a comma.
-% This command has no special spacing behaviour.
+% This macro similarly inserts a comma if not found as the next token. A
+% typical application might be following an abbreviation such as `eg' (\ie when
+% used \emph{without} periods), which according to different standard style
+% manuals should or should not be followed by a comma. It has no special
+% spacing behaviour.
%
% \DescribeMacro{\xperiodcomma}
-% The purpose of this macro is to insert a period \emph{and} comma if not found
-% as the next input tokens. Typical use will be, as above, following an object
-% such as ``\emph{e.g.}'', which, according to certain style manuals, should be
-% followed by a comma, but may also occur fortuitously immediately preceding an
-% explicit sentence-closing period, the correct trailing space of which would
-% then be inserted.
-%
+% This macro inserts a period \emph{and} a comma if not found as the next input
+% tokens. Typical use will be, as above, for abbreviations such as `e.g.'\ (\ie
+% \emph{with} periods) when they should be followed by a comma, but may also
+% occur fortuitously immediately preceding an explicit sentence-closing period
+% or indeed an explicit comma, the correct trailing space of which would then
+% ensue. Note that this action \emph{cannot} be reproduced via successive use
+% of the single macros, \ie the combination |\xperiod\xcomma|.
+%
+% \DescribeMacro{\xspaceafter}
% \DescribeMacro{\xperiodafter}
% \DescribeMacro{\xcommaafter}
% \DescribeMacro{\xperiodcommaafter}
-% These variants are similar to the above macros except that they take the word
-% or words to be punctuated as an argument; this avoids incorrect spacing
-% adjustment when the word is, for example, |\emph|'asised.
-%
-% Note that the action of |\xperiodcommaafter| may also obtained by suitably
-% nesting |\xperiodafter| and |\xcommaafter| though this has not been
-% thoroughly tested; it is thus included for safety and backward compatibility.
-%
-% The following are examples of possible usage:\\[2ex]
-% |\DeclareRobustCommand\etal{\xperiodafter{\emph{et al}}}| \\
-% |\DeclareRobustCommand\eg{e.g\xperiodcomma}| \\
-% |\DeclareRobustCommand\eg{\xcommaafter{\xperiodafter{\emph{e.g}}}}|
+% The variants |\x|\dots|after| are similar to the above except that they take
+% the object word or phrase to be spaced or punctuated as an argument; the
+% slight incorrect spacing adjustment between the word and following period or
+% comma is thus avoided when, for example, the word is |\emph|'asised. Other
+% punctuation marks do \emph{not} suffer from this problem.
+%
+% Note that although the action of |\xperiodcommaafter| may also be obtained
+% via suitable nesting of |\xperiodafter| and |\xcommaafter|, this combination
+% has not been thoroughly tested; the compound macro is thus included for both
+% safety and backwards compatibility.
+%
+% In the case of the macros that guarantee a trailing period (\emph{with} or
+% \emph{without} a comma), if the final letter of the word or phrase is a
+% capital (\eg `Ph.D.'), to guarantee the correct end-of-sentence trailing
+% spacing, it should be immediately followed by an explicit |\@|. That is, the
+% definition should be of the form
+% \begin{codelist}
+% |\newcommand\PhD{Ph.D\@\xperiod}|\\[-0.67ex]
+% \hspace*{-\leftmargin}\, or\\[-0.67ex]
+% |\newcommand\PhD{\xperiodafter{Ph.D\@}}|
+% \end{codelist}
+% N.B. If the ending capital letter or letters are \eg |\emph|'asised, the |\@|
+% should be placed \emph{inside} the |\emph|'asis:\footnote{It is for this
+% reason that it \emph{cannot} be incorporated directly into the |xpunctuate|
+% macros.}
+% \begin{codelist}
+% |\newcommand\PhD{\emph{Ph}.\emph{D\@}\xperiod}|\\[-0.67ex]
+% \hspace*{-\leftmargin}\, or\\[-0.67ex]
+% |\newcommand\PhD{\xperiodafter{\emph{Ph}.\emph{D\@}}}|
+% \end{codelist}
+%
+% The following are various other examples of possible usage:
+% \begin{codelist}
+% |\newcommand\etc{etc\xperiod}|\\
+% |\newcommand\eg{i.e\xperiodcomma}|\\
+% |\newcommand\etal{\xperiodafter{\emph{et al}}}|\\
+% |\newcommand\ie{\xperiodcommaafter{\emph{e}.\emph{g}}}|
+% \end{codelist}
+% Note how the closing period in the above is \emph{not} explicitly present,
+% being inserted by the relevant macro as and when necessary, with too the
+% correct spacing.
%
% \subsection{Caveats}
%
-% No particular care should be necessary in using the commands defined by this
-% package. However, trailing punctuation hidden inside macro definitions may
-% not be correctly interpreted.
+% \begin{generic}{caveats}
+% No specific care should be necessary when employing the macros defined here;
+% in particular, they are all \emph{robust}. However, trailing punctuation
+% hidden inside or by other macro definitions may not always be correctly
+% interpreted. Moreover, the known limitations of |\xspace| remain.
+% \end{generic}
%
% \subsection{External package requirements}
%
-% The |xspace| package is required and is loaded automatically.
+% \begin{generic}{xspace}
+% The |xspace| package is required and is loaded automatically. Note that, in
+% the \emph{absence} of |\xspace|, the necessary presence of explicit trailing
+% backslashes for correct spacing following command strings, would frustrate
+% the functionality of all the macros defined here.\footnote{Users who shun the
+% use of |xspace| will probably not appreciate the present package either.}
+% \end{generic}
%
% \subsection{Package conflicts}
%
+% \begin{generic}{conflicts}
% There are no known conflicts with any standard \LaTeX2e\ packages.
+% \end{generic}
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \section{Implementation}
%
-% \subsection{External package requirements}
-%
-% Load the |xspace| package for automatic trailing space:
+% \subsection{External packages}
+% \begin{generic}{packages}
+% First, load the |xspace| package, for automatic trailing-space insertion:
% \begin{macrocode}
\RequirePackage{xspace}
% \end{macrocode}
+% \changes{v2.0}{2023/08/13}{useful \texttt{xspace} exceptions added}
+% \begin{generic}{exceptions}
+% and add some useful extra |xspace| exceptions relevant to the present
+% package.
+% \begin{macrocode}
+\xspaceaddexceptions{\xcomma\xperiod\xperiodcomma}
+% \end{macrocode}
+% \end{generic}
+% \end{generic}
%
% \subsection{User commands}
%
+% \changes{v2.0}{2023/08/13}{revamped all macros}
+% \begin{macro}{\xspaceafter}
+% \changes{v2.0}{2023/08/13}{macro added}
+% This macro takes one argument, which it prints as is. It then inserts
+% |\xspace| immediately after, but nothing if followed by a comma or period.
+% \begin{macrocode}
+\NewDocumentCommand\xspaceafter{}{\xpnct@aux\xspace@aux}
+% \end{macrocode}
+% The correct spacing between the argument and any following comma or period is
+% thus maintained in the case of, say, an |\emph|'asised argument. The
+% necessity arises as the presence of |\xspace| `hides' any following
+% punctuation from a possible |\/| spacing-correction command.
+% \end{macro}
+%
% \begin{macro}{\xperiod}
% The following macro inserts a period if this is not found to be the next
-% character. It may thus be used to construct common abbreviations (such as
-% ``\emph{etc}.'').
+% character.
% \begin{macrocode}
-\DeclareRobustCommand\xperiod{\xprd@Set{}}
+\NewDocumentCommand\xperiod{}{\xpnct@aux\xperiod@aux{}}
% \end{macrocode}
+% It may thus be used to construct common abbreviations (such as `etc.').
% \end{macro}
%
% \begin{macro}{\xperiodafter}
-% This macro takes one argument and places a period after it if this is not
-% found to be the next character. The correct spacing between the word and
-% period is thus maintained in the case of, say, |\emph|.
+% This macro takes one argument and inserts a period after it if this is not
+% found to be the next character.
% \begin{macrocode}
-\DeclareRobustCommand\xperiodafter[1]{\xprd@Set{#1}}
+\NewDocumentCommand\xperiodafter{}{\xpnct@aux\xperiod@aux}
% \end{macrocode}
+% The correct spacing between the argument and period is again thus maintained
+% in the case of, say, |\emph|, as in often \emph{italicised} abbreviations
+% (such as `\emph{etc}.').
% \end{macro}
%
% \begin{macro}{\xcomma}
% The following macro inserts a comma if this is not found to be the next
-% character. Thus, it may be used to construct common abbreviations and
-% expressions that should normally be followed by a comma (such as
-% ``\emph{e.g.}'').
+% character.
% \begin{macrocode}
-\DeclareRobustCommand\xcomma{\xcmm@Set{}}
+\NewDocumentCommand\xcomma{}{\xpnct@aux\xcomma@aux{}}
% \end{macrocode}
+% It may thus be used to construct those common abbreviations (without periods)
+% that might normally be followed by a comma, such as `eg' or `ie' according to
+% standard American-English usage.
% \end{macro}
%
% \begin{macro}{\xcommaafter}
-% The following macro takes one argument and places a comma after it if this is
-% not found to be the next character.
+% The following macro takes one argument and inserts a comma after it if this
+% is not found to be the next character.
% \begin{macrocode}
-\DeclareRobustCommand\xcommaafter[1]{\xcmm@Set{#1}}
+\NewDocumentCommand\xcommaafter{}{\xpnct@aux\xcomma@aux}
% \end{macrocode}
% \end{macro}
%
@@ -209,114 +332,133 @@
% The following macro first adds a period and then a comma if these are not
% found to be the next characters.
% \begin{macrocode}
-\DeclareRobustCommand\xperiodcomma{\xpcm@Set{}}
+\NewDocumentCommand\xperiodcomma{}{\xpnct@aux\xperiodcomma@aux{}}
% \end{macrocode}
-% It may thus be used to construct common abbreviations that should normally be
-% followed by a comma (such as ``\emph{e.g.}''). The comma is inserted if only
-% and if the following character does not imply the end of a period. Here, of
-% course, there is no problem of spacing either preceding or following the
-% period. If only a period is found this is treated as an end-of-sentence and
-% the spacing is handled accordingly.
+% It may thus be used to construct those common abbreviations that might
+% normally be followed by a comma (such as `e.g.,'), the comma being inserted
+% \emph{if and only if} there is no following explicit sentence-ending period.
+% Here, there is of course no problem of spacing either preceding or following
+% the period. If only a period is found, it is treated as an end-of-sentence
+% and the correct spacing will ensue accordingly. A following period--comma
+% combination, if found, will be left as is.
% \end{macro}
%
% \begin{macro}{\xperiodcommaafter}
-% This macro takes one argument and places a period and a comma after it if
-% these are not found to be the next characters:
+% This macro takes one argument and inserts a period and/or a comma after it if
+% these are not found to be the next characters.
% \begin{macrocode}
-\DeclareRobustCommand\xperiodcommaafter[1]{\xpcm@Set{#1}}
+\NewDocumentCommand\xperiodcommaafter{}{\xpnct@aux\xperiodcomma@aux}
% \end{macrocode}
+% It may thus be used to construct those common \emph{italicised} abbreviations
+% that should normally be followed by a comma (such as `\eg,').
% \end{macro}
%
% \subsection{Internal macros}
%
-% \begin{macro}{\xprd@Set}
-% The setup for |\xperiod| and |\xperiodafter| is performed by the following
-% auxiliary macro:
+% \begin{macro}{\xpnct@tok}
+% A token register is defined to store a possible object word or phrase:
% \begin{macrocode}
-\newcommand\xprd@Set[1]{\def\xprd@Obj{#1}\futurelet\xprd@Nxt\xprd@Fin}
+\newtoks\xpnct@tok
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\xprd@Fin}
-% The testing and final output for |\xperiod| and |\xperiodafter| is made by
-% the following auxiliary macro:
+% \begin{macro}{\xpnct@aux}
+% The general setup and call to the final output macros for the above user
+% commands is handled by the following auxiliary macro:
% \begin{macrocode}
-\newcommand\xprd@Fin{%
- \ifx\xprd@Nxt.\relax
- \let\xprd@Out\xprd@Obj
- \else
- \def\xprd@Out{\xprd@Obj.\@\xspace}%
- \fi
- \xprd@Out
-}
+\def\xpnct@aux#1#2{%
+ \xpnct@tok{#2}%
+ \futurelet\xpnct@nxt#1}
% \end{macrocode}
-% Note the insertion of ``|\@|'' following the period when this last is not
-% found; this avoids the standard default end-of-sentence spacing, assuming the
-% occurrence in such a case to be mid-sentence.
% \end{macro}
+% Note that all the user commands defined earlier terminate by inserting an
+% |\xspace| \emph{if} and \emph{only if} the required punctuation has actually
+% been inserted by the macro.
%
-% \begin{macro}{\xcmm@Set}
-% The setup for |\xcomma| and |\xcommaafter| is performed by the following
-% auxiliary macro:
+% \begin{macro}{\xspace@aux}
+% Testing and output for |\xspaceafter| are performed by the following macro:
% \begin{macrocode}
-\newcommand\xcmm@Set[1]{\def\xcmm@Obj{#1}\futurelet\xcmm@Nxt\xcmm@Fin}
+\def\xspace@aux{%
+ \ifx\xpnct@nxt,\else
+ \ifx\xpnct@nxt.\else
+ \xpnct@tok\expandafter{\the\xpnct@tok\xspace}%
+ \fi\fi
+ \the\xpnct@tok}
% \end{macrocode}
+% Only periods and commas need be excluded, as the spacing is correct for all
+% other punctuation marks.
% \end{macro}
%
-% \begin{macro}{\xcmm@Fin}
-% The testing and final output for |\xcomma| and |\xcommaafter| is made by the
-% following auxiliary macro (shamelessly copied from an \emph{old} |xspace| and
-% hacked):
+% \begin{macro}{\xperiod@aux}
+% Testing and output for |\xperiod| and |\xperiodafter| are performed by this
+% macro:
% \begin{macrocode}
-\newcommand\xcmm@Fin{%
- \let\xcmm@Out\xcmm@Obj
- \ifx\xcmm@Nxt\bgroup\else
- \ifx\xcmm@Nxt\egroup\else
- \ifx\xcmm@Nxt\/\else
- \ifx\xcmm@Nxt~\else
- \ifx\xcmm@Nxt.\else
- \ifx\xcmm@Nxt!\else
- \ifx\xcmm@Nxt,\else
- \ifx\xcmm@Nxt:\else
- \ifx\xcmm@Nxt;\else
- \ifx\xcmm@Nxt?\else
- \ifx\xcmm@Nxt/\else
- \ifx\xcmm@Nxt'\else
- \ifx\xcmm@Nxt)\else
- \ifx\xcmm@Nxt]\else
- \ifx\xcmm@Nxt-\else
- \def\xcmm@Out{\xcmm@Obj,\xspace}%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
- \xcmm@Out
-}
+\def\xperiod@aux{%
+ \ifx\xpnct@nxt.\else
+ \xpnct@tok\expandafter{\the\xpnct@tok.\@\xspace}%
+ \fi
+ \the\xpnct@tok}
% \end{macrocode}
-% Note that there are fewer options than in the |xspace| package, for obvious
-% reasons.
+% The approach adopted is to treat an explicit following period as an
+% end-of-sentence full stop; the trailing space is then handled accordingly.
+% However, when an explicit period is \emph{not} found), the placement of |\@|
+% immediately after the inserted period thus avoids standard end-of-sentence
+% spacing, assuming such an occurrence to be mid-sentence (as for
+% abbreviations). If, in contrast, an explicit period \emph{is} found, it is
+% retained as is and will thus generate the correct end-of-sentence spacing.
% \end{macro}
%
-% \begin{macro}{\xpcm@Set}
-% The setup for |\xperiodcomma| and |\xperiodcommaafter| is performed by the
-% following auxiliary macro:
+% \begin{macro}{\xcomma@aux}
+% Testing and output for |\xcomma| and |\xcommaafter| are performed by the
+% following macro (shamelessly copied from an \emph{old} |xspace.sty| and
+% suitably hacked):
% \begin{macrocode}
-\newcommand\xpcm@Set[1]{\def\xpcm@Obj{#1}\futurelet\xpcm@Nxt\xpcm@Fin}
+\def\xcomma@aux{%
+ \ifx\xpnct@nxt.\else
+ \ifx\xpnct@nxt,\else
+ \ifx\xpnct@nxt:\else
+ \ifx\xpnct@nxt;\else
+ \ifx\xpnct@nxt!\else
+ \ifx\xpnct@nxt?\else
+ \ifx\xpnct@nxt/\else
+ \ifx\xpnct@nxt-\else
+ \ifx\xpnct@nxt'\else
+ \ifx\xpnct@nxt)\else
+ \ifx\xpnct@nxt]\else
+ \ifx\xpnct@nxt\}\else
+ \ifx\xpnct@nxt\egroup\else
+ \ifx\xpnct@nxt\/\else
+ \xpnct@tok\expandafter{\the\xpnct@tok,\xspace}%
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \the\xpnct@tok}
% \end{macrocode}
+% Note that certain of the default exceptions set by the |xspace| package are
+% missing here, for obvious reasons.
% \end{macro}
%
-% \begin{macro}{\xpcm@Fin}
-% The testing and final output for |\xperiodcomma| and |\xperiodcommaafter| is
-% made by the following auxiliary macro:
+% \begin{macro}{\xperiodcomma@aux}
+% Testing and output for |\xperiodcomma| and |\xperiodcommaafter| are performed
+% by the following:
% \begin{macrocode}
-\newcommand\xpcm@Fin{%
- \ifx\xpcm@Nxt.\relax
- \let\xpcm@Out\xpcm@Obj
- \else
- \def\xpcm@Out{\xpcm@Obj.\xcomma}%
+\def\xperiodcomma@aux{%
+ \ifx\xpnct@nxt.\else
+ \xpnct@tok\expandafter{\the\xpnct@tok.\@\xcomma}%
\fi
- \xpcm@Out
-}
+ \the\xpnct@tok}
+% \end{macrocode}
+% The presence or absence of an explicit following period is again taken to
+% imply an end-of- or mid-sentence respectively, unless followed by an explicit
+% comma, other closing punctuation or brackets say, when it will be assumed
+% mid-sentence. Note, moreover, that |\@| is \emph{still} necessary here as the
+% period may not necessarily be immediately followed by a comma, \eg if it is
+% followed by a closing bracket or quotation marks.
+% \end{macro}
+%
+% \begin{macro}{\endinput}
+% Finally, explicitly terminate the package input here.
+% \begin{macrocode}
+\endinput
% \end{macrocode}
-% The choice made is that if only a following period is found, then it is
-% treated as an end-of-sentence and the trailing space is handled accordingly.
% \end{macro}
%
% \Finale
diff --git a/macros/latex/contrib/xpunctuate/xpunctuate.ins b/macros/latex/contrib/xpunctuate/xpunctuate.ins
index 48dd28c23e..ad465692ea 100644
--- a/macros/latex/contrib/xpunctuate/xpunctuate.ins
+++ b/macros/latex/contrib/xpunctuate/xpunctuate.ins
@@ -1,51 +1,60 @@
-%%
-%% Copyright (C) 2012 by Philip G. Ratcliffe <philip.ratcliffe@uninsubria.it>
-%%
-%% This file may be distributed and/or modified under the conditions of
-%% the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX
-%% version 1999/12/01 or later.
-%%
+\iffalse meta-comment
+
+File: xpunctuate.ins
+
+Copyright (C) 2023 Philip G. Ratcliffe <philip.ratcliffe@uninsubria.it>
+
+It may be distributed and/or modified under the conditions of the
+LaTeX Project Public License (LPPL), either version 1.3c of this
+license or (at your option) any later version. The latest version
+of this license is in the file
+
+ http://www.latex-project.org/lppl.txt
+
+This file is part of the "xpunctuate package" (the Work in LPPL)
+and all files in that package must be distributed together.
+
+The released version of this package is available from CTAN.
+
+\fi
+
\input docstrip
\keepsilent
\usedir{tex/latex/xpunctuate}
\preamble
-Copyright (C) 2012 by Philip G. Ratcliffe <philip.ratcliffe@uninsubria.it>
+Copyright (C) 2023 Philip G. Ratcliffe <philip.ratcliffe@uninsubria.it>
-This file may be distributed and/or modified under the conditions of
-the LaTeX Project Public License, either version 1.2 of this license
-or (at your option) any later version. The latest version of this
-license is in:
+It may be distributed and/or modified under the conditions of the
+LaTeX Project Public License (LPPL), either version 1.3c of this
+license or (at your option) any later version. The latest version
+of this license is in the file
http://www.latex-project.org/lppl.txt
-and version 1.2 or later is part of all distributions of LaTeX
-version 1999/12/01 or later.
+This file is part of the "xpunctuate package" (the Work in LPPL)
+and all files in that package must be distributed together.
+
+The released version of this package is available from CTAN.
\endpreamble
\generateFile{xpunctuate.sty}{n}{\from{xpunctuate.dtx}{package}}
-\ifToplevel{
+\ifToplevel{%
\Msg{*************************************************************}
\Msg{*}
\Msg{* To finish the installation, move the following file into a}
\Msg{* directory searched by TeX:}
\Msg{*}
-\Msg{* \space\space xpunctuate.sty }
+\Msg{* \space\space xpunctuate.sty}
\Msg{*}
\Msg{* To produce the documentation, run xpunctuate.dtx through LaTeX.}
\Msg{* To produce a documentation index, run makeindex like this:}
-\Msg{* \space\space makeindex -s gind.ist xpunctuate}
+\Msg{* \space\space makeindex -s gind.ist xpunctuate}
\Msg{* To produce a history of changes, run makeindex like this:}
-\Msg{* \space\space makeindex -s gglo.ist -o xpunctuate.gls xpunctuate.glo}
-\Msg{* Finally, run `xpunctuate.dtx' through LaTeX again.}
+\Msg{* \space\space makeindex -s gglo.ist -o xpunctuate.gls xpunctuate.glo}
+\Msg{* Finally, run 'xpunctuate.dtx' through LaTeX again.}
\Msg{*}
\Msg{* Happy LaTeXing}
\Msg{*************************************************************}
@@ -53,4 +62,4 @@ version 1999/12/01 or later.
\endbatchfile
%%
-%% End of file `xpunctuate.ins'. \ No newline at end of file
+%% End of file 'xpunctuate.ins'. \ No newline at end of file
diff --git a/macros/latex/contrib/xpunctuate/xpunctuate.pdf b/macros/latex/contrib/xpunctuate/xpunctuate.pdf
deleted file mode 100644
index f9dde3997f..0000000000
--- a/macros/latex/contrib/xpunctuate/xpunctuate.pdf
+++ /dev/null
Binary files differ