On Thu, Jul 31, 2025 at 06:14:58AM +0000, Werner LEMBERG wrote:
> 
> [texinfo.tex 2025-07-15.21]
> 
> 
> Consider this input file
> 
> ```
> \input texinfo
> 
> This is a text@footnote{Foo.}@footnote{Bar.}@footnote{Baz.} with some
> footnotes in succession.
> 
> @bye
> ```
> 
> As can be seen in the attached image, this results in '123' as the
> footnote numbers.  What do you think about making this '1,2,3'
> instead, similar to the 'multiple' option of LateX's 'footmisc'
> package?  While footnotes are rather rare in Texinfo documents, and
> two or more footnotes at the same spot even more rare, the result
> doesnt look ideal IMHO.
> 
> See
> 
>   
> https://tex.stackexchange.com/questions/28465/multiple-footnotes-at-one-point
> 
> for a 'footmisc' example.
> 
> I have no idea whether this is possible to implement with the current
> footnote mechanism in `texinfo.tex` :-)

It's fairly easy with the right trick ;-)  We can add a small penalty after
each footnote and then use \lastpenalty to check if we are immediately after
another footnote, and then output a comma if that is so.

I had issues with the spacing around the commas, as there was too much
space before the commas.  (In fact, the examples at that stackexchange
didn't look quite right, either.)  I got a better result by setting
\scriptsize to 0pt for the footnote marker, which eliminates 0.5 pt
of horizontal space after the superscripted text, and hence before an
immediately following footnote.  I also added 1 mu (math mode unit as
we are in a math superscript) of space after the comma, so that it would
be closer to the preceding number than the succeeding number.  Basically
trial and error to get something that looked good to me.  (If nobody notices
or thinks about the spacing of the output, then we'll have done a good
job.)

commit ea7f0150ced73bacc395c7bcac84e908b959f67a
Author: Gavin Smith <[email protected]>
Date:   2025-07-31 20:05:39 +0100

    Separate footnote markers with commas
    
    * doc/texinfo.tex (\dofootnote): Use \aftergroup to output a
    small penalty after the footnote.
    (\footnote): Check \lastpenalty and output a comma before our
    footnote marker if it appears that we are immediately after
    another footnote marker.
    * NEWS: mention
    
    Suggestion from Werner Lemberg.

diff --git a/ChangeLog b/ChangeLog
index 43f8c3303b..bab02c1461 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2025-07-31  Gavin Smith <[email protected]>
+
+       Separate footnote markers with commas
+
+       * doc/texinfo.tex (\dofootnote): Use \aftergroup to output a
+       small penalty after the footnote.
+       (\footnote): Check \lastpenalty and output a comma before our
+       footnote marker if it appears that we are immediately after
+       another footnote marker.
+       * NEWS: mention
+       
+       Suggestion from Werner Lemberg.
+
 2025-07-31  Gavin Smith <[email protected]>
 
        * util/htmlxref.d/Texinfo_GNU.cnf (ada-mode, music-glossary):
diff --git a/NEWS b/NEWS
index 5eef5e315c..60f3f09cc4 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,7 @@ See the manual for detailed information.
   . use Unicode in PDF outline for input documents encoded in UTF-8
   . '@set xrefautomaticsectiontitle on' does not affect cross-references
      to anchors, matching the HTML output
+  . separate adjacent footnote markers with commas, e.g. '1, 2' not '1 2'
 
 * info
   . info manual not found hook
diff --git a/doc/texinfo.tex b/doc/texinfo.tex
index 9a9c5485b1..c895fa243c 100644
--- a/doc/texinfo.tex
+++ b/doc/texinfo.tex
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2025-07-15.21}
+\def\texinfoversion{2025-07-31.18}
 %
 % Copyright 1985, 1986, 1988, 1990-2025 Free Software Foundation, Inc.
 %
@@ -9634,7 +9634,10 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % Auto-number footnotes.  Otherwise like plain.
 \gdef\footnote{%
   \global\advance\footnoteno by \@ne
-  \edef\thisfootno{$^{\the\footnoteno}$}%
+  %
+  % Output for the footnote marker.  If we are immediately after another
+  % footnote, output a comma and small space first.
+  \edef\thisfootno{$^{\ifnum\lastpenalty=3 ,\mskip 1mu \fi\the\footnoteno}$}%
   %
   % In case the footnote comes at the end of a sentence, preserve the
   % extra spacing after we do the footnote number.
@@ -9643,19 +9646,25 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   %
   % Remove inadvertent blank space before typesetting the footnote number.
   \unskip
-  \thisfootno\@sf
+  %
+  % \scriptspace is 0.5pt by default and gives excessive space before the
+  % comma if we have multiple footnote markers in a row.
+  \bgroup\scriptspace=0pt
+    \thisfootno\@sf
+  \egroup
   \dofootnote
 }%
 
-% Don't bother with the trickery in plain.tex to not require the
-% footnote text as a parameter.  Our footnotes don't need to be so general.
-%
-% Oh yes, they do; otherwise, @ifset (and anything else that uses
-% \parseargline) fails inside footnotes because the tokens are fixed when
-% the footnote is read.  --karl, 16nov96.
+% marker for immediately after a footnote marker
+\gdef\footnoteendmarker{\penalty3 }
+
+% Do not require the footnote text as a parameter; otherwise, @ifset
+% (and anything else that uses \parseargline) fails inside footnotes
+% because the tokens are fixed when the footnote is read.
 %
 \gdef\dofootnote{%
   \insert\footins\bgroup
+  \aftergroup\footnoteendmarker
   %
   % Nested footnotes are not supported in TeX, that would take a lot
   % more work.  (\startsavinginserts does not suffice.)
@@ -9693,7 +9702,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   % provide a place where TeX can split the footnote.
   \footstrut
   %
-  % Invoke rest of plain TeX footnote routine.
+  % Eat opening brace and invoke rest of plain TeX footnote routine.
   \futurelet\next\fo@t
 }
 }%end \catcode `\@=11



Reply via email to