diff options
Diffstat (limited to 'Master/texmf-dist/tex/plain/cweb/cwebbin/pdfwebtocfront.tex')
-rw-r--r-- | Master/texmf-dist/tex/plain/cweb/cwebbin/pdfwebtocfront.tex | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/plain/cweb/cwebbin/pdfwebtocfront.tex b/Master/texmf-dist/tex/plain/cweb/cwebbin/pdfwebtocfront.tex new file mode 100644 index 00000000000..49e5f5b288a --- /dev/null +++ b/Master/texmf-dist/tex/plain/cweb/cwebbin/pdfwebtocfront.tex @@ -0,0 +1,79 @@ +% pdfwebtofront.tex +% Code from knuth.drv in https://github.com/oberdiek/latex-tds +% 2020/05/21 v1.0 by Andreas Scherer. +% +% This file is part of project https://github.com/ascherer/cwebbin +% and may be distributed under the MIT License or the LaTeX Project +% Public License. +% +% Move table-of-contents page to the front in PDF output. +% Works with pdftex and xetex in connection with either 'webmac.tex' +% for Pascal/WEB programs or 'cwebmac.tex' for C/CWEB programs. +% +\ifx\detokenize\undefined\endinput\fi +\def\contentsfile{\jobname.toc} % file that gets table of contents info +\def\readcontents{\input \contentsfile} +\newread\testread +\openin\testread=\contentsfile\relax +\ifeof\testread % First run +\else % Second run + % Redefine '\con' to be invoked before the first '\N' (starred section). + \let\ORGcon\con + \def\con{% + \def\:{\par\hangindent 2em} % Fix for 'bibtex.web'. + % reduce size of PDF pages for more screen space + \pdfpagewidth=\pagewidth \advance\pdfpagewidth by 2cm + \pdfpageheight=\pageheight \advance\pdfpageheight by 3cm + \ifpdftex \pdfhorigin=1cm \pdfvorigin=1cm + \else \advance\pdfpageheight by 1cm \global\pageshift=-1.54cm + \global\hoffset=-1.54cm \global\voffset=-1.54cm \fi + \begingroup + \let\end\relax + \ORGcon + % let's start with section '1', the 'Introduction'. + \ifx\undefined\grouptitle \mark{1} % WEB + \else \mark{{{\tensy x}1}0{Introduction}}\fi % CWEB + \eject % set '\botmark' on TOC, hence '\topmark' on next page. + \endgroup + \let\con\end + }% + % Redefine '\N’ to invoke redefined '\con' before switching back + % to original '\N'. + \expandafter\let\csname ORGN\expandafter\endcsname + \csname N\endcsname + \expandafter\outer\expandafter\def\csname N\endcsname{% + \con + \expandafter\let\csname N\expandafter\endcsname + \csname ORGN\endcsname + \csname N\endcsname + }% + % Special variant of the above for 'mf.web' and 'tex.web'. They put + % their tables-of-contents on a sparce 'page 2' and start on page '3'. + \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}\else + \edef\y{\detokenize{pdftex}}% + \ifx\x\y \def\num{1}\else + \edef\y{\detokenize{xetex}}% + \ifx\x\y \def\num{1}\fi\fi\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 + \expandafter\let\csname N\expandafter\endcsname + \csname ORGN\endcsname + \csname N\endcsname + }% + \pageno + }% + \fi +\fi |