summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorAndreas Scherer <andreas_tex@freenet.de>2020-05-06 14:04:57 +0000
committerAndreas Scherer <andreas_tex@freenet.de>2020-05-06 14:04:57 +0000
commita43ca41bdb62b2a3c407b8870718a0dda4a05363 (patch)
tree19c496f4e6d5e897ad0ff9b796f4b48fc68aaed4 /Build
parentc6ef13041a1741dbd648685b7fd0b0725ac4e051 (diff)
[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. git-svn-id: svn://tug.org/texlive/trunk@55043 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/cwebdir/ChangeLog6
-rw-r--r--Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex59
2 files changed, 65 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/cwebdir/ChangeLog b/Build/source/texk/web2c/cwebdir/ChangeLog
index 1e9f86f24e0..1a36c3bbc47 100644
--- a/Build/source/texk/web2c/cwebdir/ChangeLog
+++ b/Build/source/texk/web2c/cwebdir/ChangeLog
@@ -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.
diff --git a/Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex b/Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex
index 056bf230010..cba1c005971 100644
--- a/Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex
+++ b/Build/source/texk/web2c/cwebdir/texinputs/Xcwebmac.tex
@@ -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