texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: Fix PDF page labels if pages appear between title


From: Gavin D. Smith
Subject: branch master updated: Fix PDF page labels if pages appear between title page and contents
Date: Mon, 27 Mar 2023 17:20:28 -0400

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new a0c92c22b7 Fix PDF page labels if pages appear between title page and 
contents
a0c92c22b7 is described below

commit a0c92c22b76b7f9fd988e1cc63759e60dae69933
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Mar 27 22:18:57 2023 +0100

    Fix PDF page labels if pages appear between title page and contents
    
    * doc/texinfo.texi (\contentsendroman): Record end of contents
    in new count register, \contentsendcount.  Reset \pageno to 1.
    (\pagelabels): Check \contentsendcount to support case of @contents
    appearing at end of document.
    
    Arnold Robbins reported that Roman numerals would be used for the
    PDF page labels throughout the gawk manual.  This was because the
    two dedication pages before the contents were being treated as the
    Arabic-numbered pages in the document.
---
 ChangeLog       | 14 ++++++++++++++
 doc/texinfo.tex | 50 +++++++++++++++++++++++++++-----------------------
 2 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ffd9dbec83..7332d03dfc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-03-27  Gavin Smith <gavinsmith0123@gmail.com>
+
+       Fix PDF page labels if pages appear between title page and contents
+
+       * doc/texinfo.texi (\contentsendroman): Record end of contents
+       in new count register, \contentsendcount.  Reset \pageno to 1.
+       (\pagelabels): Check \contentsendcount to support case of @contents
+       appearing at end of document.
+
+       Arnold Robbins reported that Roman numerals would be used for the
+       PDF page labels throughout the gawk manual.  This was because the
+       two dedication pages before the contents were being treated as the
+       Arabic-numbered pages in the document.
+
 2023-03-27  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_next_bracketed_or_word_agg),
diff --git a/doc/texinfo.tex b/doc/texinfo.tex
index 0b8b87c959..c0a54919a7 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{2023-03-21.06}
+\def\texinfoversion{2023-03-27.21}
 %
 % Copyright 1985, 1986, 1988, 1990-2023 Free Software Foundation, Inc.
 %
@@ -1102,27 +1102,33 @@ where each line of input produces a line of output.}
 
 % Output page labels information.
 % See PDF reference v.1.7 p.594, section 8.3.1.
+% Page label ranges must be increasing.
 \ifpdf
 \def\pagelabels{%
   \def\title{0 << /P (T-) /S /D >>}%
-  \edef\roman{\the\romancount << /S /r >>}%
-  \edef\arabic{\the\arabiccount << /S /D >>}%
   %
-  % Page label ranges must be increasing.  Remove any duplicates.
-  % (There is a slight chance of this being wrong if e.g. there is
-  % a @contents but no @titlepage, etc.)
-  %
-  \ifnum\romancount=0 \def\roman{}\fi
-  \ifnum\arabiccount=0 \def\title{}%
-  \else
-    \ifnum\romancount=\arabiccount \def\roman{}\fi
-  \fi
-  %
-  \ifnum\romancount<\arabiccount
-    \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax
+  % support @contents at very end of document
+  \ifnum\contentsendcount=\pagecount
+    \ifnum\arabiccount<\romancount
+      \pdfcatalog{/PageLabels << /Nums
+                  [\title
+                   \the\arabiccount << /S /D >>
+                   \the\romancount << /S /r >>
+                  ] >> }\relax
+    \fi
+  % no contents in document
+  \else\ifnum\contentsendcount=0
+    \pdfcatalog{/PageLabels << /Nums
+                [\title
+                 \the\arabiccount << /S /D >>
+                ] >> }\relax
   \else
-    \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax
-  \fi
+    \pdfcatalog{/PageLabels << /Nums
+                [\title
+                 \the\romancount << /S /r >>
+                 \the\contentsendcount << /S /D >>
+                ] >> }\relax
+  \fi\fi
 }
 \else
   \let\pagelabels\relax
@@ -1131,6 +1137,8 @@ where each line of input produces a line of output.}
 \newcount\pagecount \pagecount=0
 \newcount\romancount \romancount=0
 \newcount\arabiccount \arabiccount=0
+\newcount\contentsendcount \contentsendcount=0
+
 \ifpdf
   \let\ptxadvancepageno\advancepageno
   \def\advancepageno{%
@@ -6809,12 +6817,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % Get ready to use Arabic numerals again
 \def\contentsendroman{%
   \lastnegativepageno = \pageno
-  \global\pageno = \savepageno
-  %
-  % If \romancount > \arabiccount, the contents are at the end of the
-  % document.  Otherwise, advance where the Arabic numerals start for
-  % the page numbers.
-  \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi
+  \global\pageno=1
+  \contentsendcount = \pagecount
 }
 
 % Typeset the label for a chapter or appendix for the short contents.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]