texlive[55043] Build/source/texk/web2c/cwebdir: [CWEB] Macros to move

commits+ascherer at tug.org commits+ascherer at tug.org
Wed May 6 16:04:57 CEST 2020


Revision: 55043
          http://tug.org/svn/texlive?view=revision&revision=55043
Author:   ascherer
Date:     2020-05-06 16:04:57 +0200 (Wed, 06 May 2020)
Log Message:
-----------
[CWEB] Macros to move TOC up front in PDF output.

Run 'cweave -lX ...' and {pdf|Xe}TeX twice to move table-of-contents up
front in the PDF output.

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/cwebdir/ChangeLog
    trunk/Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex

Modified: trunk/Build/source/texk/web2c/cwebdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/cwebdir/ChangeLog	2020-05-06 11:26:02 UTC (rev 55042)
+++ trunk/Build/source/texk/web2c/cwebdir/ChangeLog	2020-05-06 14:04:57 UTC (rev 55043)
@@ -1,3 +1,9 @@
+2020-05-07  Andreas Scherer  <https://ascherer.github.io>
+
+	* texinputs/Xcwebmac.tex: Amend macros from knuth.drv (n
+	github.com/oberdiek/latex-tds) to move table-of-contents
+	up front in PDF output (on second TeX run).
+
 2020-04-30  Andreas Scherer  <https://ascherer.github.io>
 
 	* comm-w2c.ch: Clarify §95 and fix missing type format.

Modified: trunk/Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex
===================================================================
--- trunk/Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex	2020-05-06 11:26:02 UTC (rev 55042)
+++ trunk/Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex	2020-05-06 14:04:57 UTC (rev 55043)
@@ -39,3 +39,62 @@
 \def\SHC#1{\5\5\quad$\diamond\,${\cmntfont#1}}
 
 %\let\K=\leftarrow % "honest" alternative to standard assignment operator
+
+% Move contents page to the front
+%
+% Code from knuth.drv in https://github.com/oberdiek/latex-tds
+% Works with pdftex (with active links) and xetex (with active
+% links only for '\let\pdf+').
+%
+\ifx\detokenize\undefined\endinput\fi
+\newread\testread
+\openin\testread=\contentsfile\relax
+\ifeof\testread % First run
+\else % Second run
+  \let\ORGcon\con
+  \def\con{%
+    \begingroup
+      \let\end\relax
+      \ORGcon
+    \endgroup
+    \let\con\end
+  }%
+  \expandafter\let\csname ORGN\expandafter\endcsname
+                  \csname N\endcsname
+  \expandafter\outer\expandafter\def\csname N\endcsname{%
+    \con
+    \advance\pageno by -1\relax
+    \expandafter\let\csname N\expandafter\endcsname
+                    \csname ORGN\endcsname
+    \csname N\endcsname
+  }%
+  \begingroup
+    \def\num{0}%
+    \edef\x{\jobname}%
+    \edef\y{\detokenize{tex}}%
+    \ifx\x\y
+      \def\num{1}%
+    \else
+      \edef\y{\detokenize{mf}}%
+      \ifx\x\y
+        \def\num{1}%
+      \fi
+    \fi
+  \expandafter\endgroup\ifnum\num=1 %
+    \def\contentspagenumber{2}%
+    \let\ORGpageno\pageno
+    \def\pageno{%
+      \let\pageno\ORGpageno
+      \expandafter\let\csname ORGN\expandafter\endcsname
+                      \csname N\endcsname
+      \expandafter\outer\expandafter\def\csname N\endcsname{%
+        \con
+        \advance\pageno by -1\relax
+        \expandafter\let\csname N\expandafter\endcsname
+                        \csname ORGN\endcsname
+        \csname N\endcsname
+      }%
+      \pageno
+    }%
+  \fi
+\fi



More information about the tex-live-commits mailing list.