Skip to content

Commit

Permalink
Merge branch 'master' into build/work000 r71402 #158
Browse files Browse the repository at this point in the history
  • Loading branch information
t-tk committed Jun 2, 2024
2 parents 8bb30da + 5cbf668 commit d01cd42
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 37 deletions.
20 changes: 20 additions & 0 deletions source/texk/web2c/cwebdir/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
2024-05-25 Andreas Scherer <https://ascherer.github.io>

* cwebacromac.tex: HiTeX has a three-page table-of-contents.
* texinputs/pdfwebtocfront.tex: Add \space in PDF code.

2024-05-25 Andreas Scherer <https://ascherer.github.io>

* texinputs/pdfwebtocfront.tex: More room for long ToCs.

2024-05-24 Andreas Scherer <https://ascherer.github.io>

* cwebacromac.tex,
* cwebmac.tex,
* texinputs/dcwebmac.tex,
* texinputs/fcwebmac.tex,
* texinputs/icwebmac.tex,
* texinputs/pdfctproofmac.tex,
* texinputs/pdfctwimac.tex,
* texinputs/pdfwebtocfront.tex: Extend and reshuffle \startpdf.

2024-03-13 Andreas Scherer <https://ascherer.github.io>

* ctwill-mini.ch: Fix page breaks in sections 164 and 173.
Expand Down
15 changes: 14 additions & 1 deletion source/texk/web2c/cwebdir/cwebacromac.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% hypertext macros for CWEB listings (in addition to cwebmac.tex)
% Version 1.1 --- September 2023
% Version 2.0 --- May 2024
\ifx\ifacrohint\undefined\endinput\fi % these are not standalone macros
\ifluatex % LuaTeX is almost like pdfTeX
\protected\def\pdfliteral {\pdfextension literal}
Expand All @@ -15,6 +15,19 @@
\let\pdfoutput=\outputmode
\fi % end of LuaTeX->pdfTeX redirection macros

% Used in cwebmac.tex, pdfctwimac.tex, pdfproofmac.tex
\def\tocpages{1} % Most programs have one-page Table-of-Contents
\def\startpdf{\def\pagemode{/PageMode /UseOutlines}
\ifnum\contentspagenumber=0 \advance \pageno by -\tocpages
\def\pagelabels{/PageLabels << /Nums [ 0 << /S/D/St \tocpages >>
\the\pageno << /P(Contents) >> ] >>}
\else \twodigits=\pageno \pageno=\contentspagenumber
\advance \pageno by \tocpages \advance \twodigits by -\pageno
\def\pagelabels{/PageLabels << /Nums [ 0 << /S/D/St \the\pageno >>
\the\twodigits << /S/D/St \contentspagenumber >> ] >>} \fi
\ifpdflua\pdfcatalog{\pagemode\space\pagelabels}
\else \special{pdf: docview << \pagemode\space\pagelabels >>}\fi}

\ifacro % The following are general pdf macros
\def\thewidth{\the\wd0 \space}
\def\theheight{\the\ht\strutbox\space}
Expand Down
16 changes: 7 additions & 9 deletions source/texk/web2c/cwebdir/cwebmac.tex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
% standard macros for CWEB listings (in addition to plain.tex)
% Version 4.11 --- October 2023
% Version 4.12 --- May 2024
\ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
\xdef\fmtversion{\fmtversion+CWEB4.11}
\chardef\cwebversion=4 \chardef\cwebrevision=11
\xdef\fmtversion{\fmtversion+CWEB4.12}
\chardef\cwebversion=4 \chardef\cwebrevision=12

\let\:=\. % preserve a way to get the dot accent
% (all other accents will still work as usual)
Expand Down Expand Up @@ -215,8 +215,8 @@
\def\T#1{\leavevmode % octal, hex or decimal constant
\hbox{$\def\?{\kern.2em}%$%
\let\ \, % C++ digit separator becomes a little white space
% \def\$##1{\egroup_{\,\rm##1}\bgroup}% suffix to constant % versions < 3.67
\def\$##1{\egroup_{\rm##1}\bgroup}% suffix to constant % in version 3.67
% \def\$##1{\egroup_{\,\rm##1}\bgroup}% suffix to constant %$% versions < 3.67
\def\$##1{\egroup_{\rm##1}\bgroup}% suffix to constant %$% in version 3.67
\def\_{\cdot 10^{\aftergroup}}% power of ten (via dirty trick)
\let\~=\oct \let\^=\hex \let\\=\bin {#1}$}}%$%
\def\U{\note{This code is used in section}} % xref for use of a section
Expand Down Expand Up @@ -276,8 +276,6 @@
\def\title{\expandafter\uppercase\expandafter{\jobname}}
\def\topofcontents{\centerline{\titlefont\title}\vskip.7in
\vfill} % this material will start the table of contents page
\def\startpdf{\ifpdf \ifpdflua\pdfcatalog{/PageMode /UseOutlines}
\else {\special{pdf: docview << /PageMode /UseOutlines >>}}\fi\fi}
\def\botofcontents{\vfill
\centerline{\covernote}} % this material will end the table of contents page
\def\covernote{}
Expand Down Expand Up @@ -383,12 +381,12 @@
% \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
\rightskip 0pt \hyphenpenalty 50 \tolerance 200
\setpage \output={\normaloutput\page\lheader\rheader}
\titletrue % prepare to output the table of contents
\ifpdf\startpdf\fi \titletrue % prepare to output the table of contents
\pageno=\contentspagenumber
\def\grouptitle{TABLE OF CONTENTS}
\message{Table of contents:}
\ifhint\HINThome\fi% Mark the Table of contents as home page
\topofcontents \startpdf
\topofcontents
\line{\hfil Section\ifhint\else\hbox to3em{\hss Page}\fi}% No Page in HINT
\let\ZZ=\contentsline
\readcontents\relax % read the contents info
Expand Down
5 changes: 3 additions & 2 deletions source/texk/web2c/cwebdir/texinputs/dcwebmac.tex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
% Version 3.64 [p21] --- Andreas Scherer, Octobre 2005
% Version 3.64 [p22] --- Andreas Scherer, March 2016
% Version 4.9 --- Andreas Scherer, June 2022
% Version 4.12 --- Andreas Scherer, May 2024

\ifx\undefined\botofcontents\input cwebmac.tex\fi

Expand Down Expand Up @@ -81,11 +82,11 @@
% \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
\rightskip 0pt \hyphenpenalty 50 \tolerance 200
\setpage \output={\normaloutput\page\lheader\rheader}
\titletrue % prepare to output the table of contents
\ifpdf\startpdf\fi \titletrue % prepare to output the table of contents
\pageno=\contentspagenumber
\redefcon
\ifhint\HINThome\fi% Mark the Table of contents as home page
\topofcontents \startpdf
\topofcontents
\line{\headerline}
\let\ZZ=\contentsline
\readcontents\relax % read the contents info
Expand Down
5 changes: 3 additions & 2 deletions source/texk/web2c/cwebdir/texinputs/fcwebmac.tex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
% Version 3.64 [p21] --- Andreas Scherer, October 2005
% Version 3.64 [p22] --- Andreas Scherer, March 2016
% Version 4.9 --- Andreas Scherer, June 2022
% Version 4.12 --- Andreas Scherer, May 2024

% french translations --- Denis Roegel, 18 September 1994

Expand Down Expand Up @@ -107,12 +108,12 @@
% \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
\rightskip 0pt \hyphenpenalty 50 \tolerance 200
\setpage \output={\normaloutput\page\lheader\rheader}
\titletrue % prepare to output the table of contents
\ifpdf\startpdf\fi \titletrue % prepare to output the table of contents
\pageno=\contentspagenumber
\def\grouptitle{SOMMAIRE:}
\message{Sommaire:}
\ifhint\HINThome\fi% Mark the Table of contents as home page
\topofcontents \startpdf
\topofcontents
\line{\hfil Section\ifhint\else\hbox to3em{\hss Page}\fi}% No Page in HINT
\let\ZZ=\contentsline
\readcontents\relax % read the contents info
Expand Down
5 changes: 3 additions & 2 deletions source/texk/web2c/cwebdir/texinputs/icwebmac.tex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
% Version 3.64 [p21] --- Andreas Scherer, October 2005
% Version 3.64 [p22] --- Andreas Scherer, March 2016
% Version 4.9 --- Andreas Scherer, June 2022
% Version 4.12 --- Andreas Scherer, May 2024

\ifx\undefined\botofcontents\input cwebmac.tex\fi

Expand Down Expand Up @@ -133,12 +134,12 @@
% \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
\rightskip 0pt \hyphenpenalty 50 \tolerance 200
\setpage \output={\normaloutput\page\lheader\rheader}
\titletrue % prepare to output the table of contents
\ifpdf\startpdf\fi \titletrue % prepare to output the table of contents
\pageno=\contentspagenumber
\def\grouptitle{INDICE}
\message{Indice:}
\ifhint\HINThome\fi% Mark the Table of contents as home page
\topofcontents \startpdf
\topofcontents
\line{\hfil Sezione\ifhint\else\hbox to3em{\hss Pag.}\fi}% No Page in HINT
\let\ZZ=\contentsline
\readcontents\relax % read the contents info
Expand Down
12 changes: 5 additions & 7 deletions source/texk/web2c/cwebdir/texinputs/pdfctproofmac.tex
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
% standard macros for CWEB listings (in addition to plain.tex)
% Version 4.11 --- October 2023
% Version 4.12 --- May 2024
% modified for proofs in CTWILL
% modified for PDF/HINT output with 'tex "\let\pdf+' or '{hi|lua|pdf|xe}tex'
% This file is not copyrighted and can be used freely.
\ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
\xdef\fmtversion{\fmtversion+CTWILL4.11+PROOFS+PDF}
\xdef\fmtversion{\fmtversion+CTWILL4.12+PROOFS+PDF}

\let\:=\. % preserve a way to get the dot accent
% (all other accents will still work as usual)
Expand Down Expand Up @@ -216,7 +216,7 @@
\def\T#1{\leavevmode % octal, hex or decimal constant
\hbox{$\def\?{\kern.2em}%$%
\let\ \, % C++ digit separator becomes a little white space
\def\$##1{\egroup_{\rm##1}\bgroup}% suffix to constant
\def\$##1{\egroup_{\rm##1}\bgroup}%$% suffix to constant
\def\_{\cdot 10^{\aftergroup}}% power of ten (via dirty trick)
\let\~=\oct \let\^=\hex \let\\=\bin {#1}$}}%$%
\def\U{\note{This code is used in section}} % xref for use of a section
Expand Down Expand Up @@ -274,8 +274,6 @@
\def\title{\expandafter\uppercase\expandafter{\jobname}}
\def\topofcontents{\centerline{\titlefont\title}\vskip.7in
\vfill} % this material will start the table of contents page
\def\startpdf{\ifpdf \ifpdflua\pdfcatalog{/PageMode /UseOutlines}
\else {\special{pdf: docview << /PageMode /UseOutlines >>}}\fi\fi}
\def\botofcontents{\vfill
\centerline{\covernote}} % this material will end the table of contents page
\def\covernote{}
Expand Down Expand Up @@ -400,12 +398,12 @@
% \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
\rightskip 0pt \hyphenpenalty 50 \tolerance 200
\setpage \output={\normaloutput\page\lheader\rheader}
\titletrue % prepare to output the table of contents
\ifpdf\startpdf\fi \titletrue % prepare to output the table of contents
\pageno=\contentspagenumber
\def\grouptitle{TABLE OF CONTENTS}
\message{Table of contents:}
\ifhint\HINThome\fi% Mark the Table of contents as home page
\topofcontents \startpdf
\topofcontents
\line{\hfil Section\ifhint\else\hbox to3em{\hss Page}\fi}% No Page in HINT
\let\ZZ=\contentsline
\readcontents\relax % read the contents info
Expand Down
10 changes: 4 additions & 6 deletions source/texk/web2c/cwebdir/texinputs/pdfctwimac.tex
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
% standard macros for CWEB listings (in addition to plain.tex)
% Version 4.11 --- October 2023
% Version 4.12 --- May 2024
% modified for pages produced by CTWILL
% further modified for page size of the MMIXware book
% modified for PDF output with 'tex "\let\pdf+' or '{lua|pdf|xe}tex'
% This file is not copyrighted and can be used freely.
\ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
\xdef\fmtversion{\fmtversion+CTWILL4.11+LNCS+PDF}
\xdef\fmtversion{\fmtversion+CTWILL4.12+LNCS+PDF}

\let\:=\. % preserve a way to get the dot accent
% (all other accents will still work as usual)
Expand Down Expand Up @@ -515,8 +515,6 @@
%\global\advance\pageno by1}
%\def\topofcontents{\centerline{\titlefont\title}\vskip.7in
%\vfill} % this material will start the table of contents page
%\def\startpdf{\ifpdf \ifpdflua\pdfcatalog{/PageMode /UseOutlines}
%\else {\special{pdf: docview << /PageMode /UseOutlines >>}}\fi\fi}
%\def\botofcontents{\vfill
%\centerline{\covernote}} % this material will end the table of contents page
%\def\covernote{}
Expand Down Expand Up @@ -569,11 +567,11 @@
% \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
%\rightskip 0pt \hyphenpenalty 50 \tolerance 200
%\setpage \output={\normaloutput\page\lheader\rheader}
%\titletrue % prepare to output the table of contents
%\ifpdf\startpdf\fi \titletrue % prepare to output the table of contents
%\pageno=\contentspagenumber
%\def\grouptitle{TABLE OF CONTENTS}
%\message{Table of contents:}
%\topofcontents \startpdf
%\topofcontents
%\line{\hfil Section\hbox to3em{\hss Page}}
%\let\ZZ=\contentsline
%\readcontents\relax % read the contents info
Expand Down
37 changes: 29 additions & 8 deletions source/texk/web2c/cwebdir/texinputs/pdfwebtocfront.tex
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
% pdfwebtofront.tex
% pdfwebtocfront.tex
% Code from knuth.drv in https://github.com/oberdiek/latex-tds
% 2020/06/20 v2.0 by Andreas Scherer.
% 2024/05/25 v3.1 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.
% Works with pdftex/xetex/luatex and plain tex/dvipdf in connection
% with either 'pwebmac.tex' for Pascal/WEB programs or 'cwebmac.tex'
% for C/CWEB programs.
%
\ifx\detokenize\undefined\endinput\fi
\ifx\twodigits\undefined\endinput\fi
\def\contentsfile{\jobname.toc} % file that gets table of contents info
\newif\iftexmf\texmffalse % special toc treatment for TeX, Metafont, etc.
\newread\testread
\openin\testread=\contentsfile\relax
\ifeof\testread % First run
\else % Second run
% Fix page numbers in the PDF bootmarks with 'Page Labels'
\def\tocpages{1} % Most programs have one-page Table-of-Contents
\def\tocstart{2} % so we start with (fake) page 2 for the rest
\def\pagemode{/PageMode /UseOutlines}
\def\pagelabels{/PageLabels << /Nums [
\ifnum\contentspagenumber=0 0 << /P(Contents) >> \tocpages << /S/D/St 1 >>
\else 0 << /S/D/St \contentspagenumber >> \fi ] >> }
\def\startpdf{\ifpdflua\pdfcatalog{\pagemode\space\pagelabels}
\else {\special{pdf: docview << \pagemode\space\pagelabels >>}}\fi}
% Redefine '\con' to be invoked before the first '\N' (starred section).
\let\ORGcon\con
\def\con{%
% reduce size of PDF pages for more screen space
\pdfpagewidth=\pagewidth \advance\pdfpagewidth by 1in
\pdfpageheight=\fullpageheight \advance\pdfpageheight by 1in
\iftexmf \advance\pdfpageheight by 0.5in
\gtitle={Table of Contents} % overwrite default 'WEB output'
\mark{\noexpand\nullsec{\the\gtitle}} \fi
\ifpdflua \pdfhorigin=0.5in \pdfvorigin=0.5in
\else \global\pageshift=-0.5in
\global\hoffset=-0.5in \global\voffset=-0.5in \fi
Expand All @@ -34,27 +48,34 @@
}%
% Special variant for 'mf.web' and 'tex.web' (et al.).
% They all define a peculiar version of '\N' in their preamble.
% And they put their tables-of-contents on a sparse 'page 2' and
% start the main body on page '3'.
% And they put their tables-of-contents on sparse 'Contents' page(s)
% and start the main body on page '3'.
\edef\x{\jobname}%
\edef\y{\detokenize{tex}}%
\ifx\x\y \texmftrue\else
\edef\y{\detokenize{mf}}%
\ifx\x\y \texmftrue\else
\edef\y{\detokenize{pdftex}}%
\ifx\x\y \texmftrue\else
\ifx\x\y \texmftrue \def\tocpages{2}\else
\edef\y{\detokenize{xetex}}%
\ifx\x\y \texmftrue\fi\fi\fi\fi
\iftexmf
% These main programs start on page '3' (after any number of ToC pages)
\def\pagelabels{/PageLabels << /Nums [
0 << /P(Contents) >> \tocpages << /S/D/St 3 >> ] >> }
\expandafter\let\csname ORGN\expandafter\endcsname
\csname N\endcsname
\expandafter\outer\expandafter\def\csname N\endcsname{%
\titletrue \con \pageno=2
\titletrue \con \pageno=\tocstart
\expandafter\let\csname N\expandafter\endcsname
\csname ORGN\endcsname
\csname N\endcsname
}%
\else % Much more general approach for WEB and CWEB programs.
\edef\y{\detokenize{mp}}%
% This main program starts on page '3' (after any number of ToC pages)
\ifx\x\y \def\pagelabels{/PageLabels << /Nums [
0 << /P(Contents) >> \tocpages << /S/D/St 3 >> ] >> } \fi
% In fact, '\con' will be invoked _inside_ the first '\N' right _after_
% '\MN', but _before_ '\eject'. And '\topofcontents' gets in the twist
% as well.
Expand Down

0 comments on commit d01cd42

Please sign in to comment.