From f689c91581665257602a841d03f73078c3495e14 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 7 Feb 2022 03:03:44 +0000 Subject: CTAN sync 202202070303 --- web/pwebmac/pwebmac.tex | 117 +++++++++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 42 deletions(-) (limited to 'web/pwebmac/pwebmac.tex') diff --git a/web/pwebmac/pwebmac.tex b/web/pwebmac/pwebmac.tex index 3dac11f4bc..3f4bd335e6 100644 --- a/web/pwebmac/pwebmac.tex +++ b/web/pwebmac/pwebmac.tex @@ -1,10 +1,11 @@ % standard macros for WEB listings (in addition to PLAIN.TEX) % pdfTeX adjustments provided by Han The Thanh . % XeTeX adjustments provided by Khaled Hosny . +% HiTeX adjustments provided by Martin Ruckert . % macro integration \`a la CWEB by Andreas Scherer . % This file is not copyrighted and can be used freely. \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros -\xdef\fmtversion{\fmtversion+WEBMAC4.6} +\xdef\fmtversion{\fmtversion+WEBMAC4.7} \newif\ifpdf \ifx\pdf+\pdftrue\fi % Uncomment the following line if you want PDF goodies to be the default @@ -17,7 +18,10 @@ \def\Black{\pdfliteral{0 g 0 G}} % use rgb colors for direct PDF output too \def\PDFlinkcolor{\pdfliteral{\pdflinkcolor\space rg \pdflinkcolor\space RG}} \fi\fi +\newif\ifHINT +\ifx\HINTversion\undefined \HINTfalse \else \HINTtrue \fi \newif\ifacro \ifpdf\acrotrue\fi \ifpdftex\acrotrue\fi +\newif\ifacroHINT \ifacro\acroHINTtrue\fi \ifHINT\acroHINTtrue\fi \parskip 0pt % no stretch between paragraphs \parindent 1em % for paragraphs and for the first line of Pascal text @@ -81,7 +85,7 @@ \let\yskip=\smallskip \def\to{\mathrel{.\,.}} % double dot, used only in math mode \def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt% - \eightrm#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}} + \eightrm#1~\ifacroHINT{\pdfnote#2.}\else#2\fi.\par}} \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD \newtoks\toksE \newtoks\toksF \newtoks\usersanitizer @@ -102,43 +106,9 @@ \special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight depth \thedepth << /Type /Annot /Subtype /Link /Border [0 0 0] /A << /S /GoTo /D (#2) >> >>}\box0\relax}\fi -\def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA} -\def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}% - \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\toksD={} - \toksC={}\let\space\empty}\makenote}\maketoks}} -\def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} -\def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}% - \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi\toksA={#2}} -\def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|% - \ifnum\countB>`9 \countB=0 \fi - \ifnum\countB<`0 - \ifnum0=\countC\else\makenote\fi - \ifx\first.\let\next=\maketoksdone\else - \let\next=\maketoks - \addtokens\toksB{\the\toksD} - \ifx\first,\addtokens\toksB{\space}\fi - \fi - \else \addtokens\toksC{\the\toksD}\global\countC=1\let\next=\maketoks - \fi - \next -} -\def\makenote{\addtokens\toksB - {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countC=0} -\def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} -\def\pdfURL#1#2{\ifpdftex\pdfannotlink height\ht\strutbox depth\dp\strutbox - attr {/Border [0 0 0]} user { /Type /Action /Subtype /Link /A - << /S /URI /URI (#2) >> }\PDFlinkcolor #1\Black \pdfendlink - \else\ifpdf{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% - \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight - \space depth \thedepth\space << /Border [0 0 0] - /Type /Action /Subtype /Link /A << /S /URI /URI (#2) >> >>}\box0\relax}% - \else #1 ({\tt#2})\fi\fi} -{\catcode`\~=12 \gdef\TILDE/{~}} % ~ in a URL -{\catcode`\_=12 \gdef\UNDER/{_}} % _ in a URL \def\sanitizecommand#1#2{\addtokens\usersanitizer {\noexpand\dosanitizecommand\noexpand#1{#2}}} \def\dosanitizecommand#1#2{\ifx\nxt#1\addF{#2}\fi} -\sanitizecommand\to{..} % a trivial example \catcode`\[=1 \catcode`\]=2 \catcode`\{=12 \catcode`\}=12 \def\lbchar[{] \def\rbchar[}] @@ -187,7 +157,7 @@ \else\ifx\nxt\~\ifTnum\addF{0}\else\addF\tildechar\fi % 077->\T{\~77} \else\ifx\nxt\_\ifTnum\addF{E}\else\addF_\fi % 0.1E5->\T{0.1\_5} \else\ifx\nxt\^\ifTnum\addF{0x}\else\addF^\fi % 0x77 -> \T{\^77} - \else\ifx\nxt\$\ifTnum\tokprocessedtrue\else\addF$\fi % \T{77\$L} %$% + \else\ifx\nxt\$\ifTnum\tokprocessedtrue\else\addF$\fi %$% \T{77\$L} \else\ifx\nxt\{\addF\lbchar \else\ifx\nxt\}\addF\rbchar \else\ifx\nxt\ \addF\space \else\ifx\nxt\#\addF{\string\#}% \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi @@ -205,9 +175,65 @@ \outlinest\let\outlinedone=\relax} \fi % End of pdf macros +\ifHINT +% The following uses HINT primitives to implement: +% \HINThome to mark the position of the home page +% \HINTlabel to attach a label to the top of a section +% \HINTlink to link a section number to the section label +% \HINTcontents to produce an 'outline' item +% These are the top level HINT macros that are used in this file +% No HINT primitives are used directly. +\def\HINThome{\HINTdest name {HINT.home}% + \HINToutline goto name {HINT.home} depth 1 {Table of Contents}} +\def\HINTlabel{{\let\*=\empty\HINTdest num \modstar top}} +\def\HINTlink#1#2{\HINTstartlink goto num #1 {#1}\HINTendlink}% #2 not used ??? +\def\HINTcontents#1#2#3{\HINToutline goto num #3 depth #2 {#1}} +\let\pdflink=\HINTlink +\fi % End of HINT macros + +% Common macros for \ifacro and \ifHINT +\ifacroHINT +\def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA} +\def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}% + \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\toksD={} + \toksC={}\let\space\empty}\makenote}\maketoks}} +\def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} +\ifHINT\else\sanitizecommand\to{..}\fi % a trivial example; requires \addtokens +\def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}% + \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi\toksA={#2}} +\def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|% + \ifnum\countB>`9 \countB=0 \fi + \ifnum\countB<`0 + \ifnum0=\countC\else\makenote\fi + \ifx\first.\let\next=\maketoksdone\else + \let\next=\maketoks + \addtokens\toksB{\the\toksD} + \ifx\first,\addtokens\toksB{\space}\fi + \fi + \else \addtokens\toksC{\the\toksD}\global\countC=1\let\next=\maketoks + \fi + \next +} +\def\makenote{\addtokens\toksB + {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countC=0} +\def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} +\fi % End of common macros + +\def\pdfURL#1#2{\ifpdftex\pdfannotlink height\ht\strutbox depth\dp\strutbox + attr {/Border [0 0 0]} user { /Type /Action /Subtype /Link /A + << /S /URI /URI (#2) >> }\PDFlinkcolor #1\Black \pdfendlink + \else\ifpdf{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% + \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight + \space depth \thedepth\space << /Border [0 0 0] + /Type /Action /Subtype /Link /A << /S /URI /URI (#2) >> >>}\box0\relax}% + \else #1 ({\tt#2})\fi\fi} +{\catcode`\~=12 \gdef\TILDE/{~}} % ~ in a URL +{\catcode`\_=12 \gdef\UNDER/{_}} % _ in a URL + \def\lapstar{\rlap{*}} \def\stsec{\rightskip=0pt % get out of Pascal mode (cf. \P) \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 + \ifHINT\HINTlabel\fi% Start page before section \noindent{\let\*=\lapstar\bf\modstar.\quad}% \ifacro \smash{\raise\baselineskip\hbox to0pt{\let\*=\empty \ifpdftex \pdfdest num \modstar fith% @@ -265,7 +291,7 @@ \let\W=\land % logical and \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name \XX$\langle\,$#2{\eightrm\kern.5em - \ifacro{\pdfnote#1.}\else#1\fi}$\,\rangle$\XX} + \ifacroHINT{\pdfnote#1.}\else#1\fi}$\,\rangle$\XX} \def\Y{\par\yskip} \let\Z=\let % now you can \send the control sequence \Z \def\){\hbox{\.{@\$}}} % sign for string pool check sum @@ -345,7 +371,9 @@ \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height \hsize=.5\pagewidth \advance\hsize by -10pt % column width for the index (20pt between cols) + \ifHINT\else \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines + \fi \def\lr{L} % this tells whether the left or right column is next \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R} \else\normaloutput{\vbox to\pageheight{\box\sbox\vss @@ -354,7 +382,7 @@ \message{Index:} \parskip 0pt plus .5pt \outer\def\:##1, ##2.{\par\hangindent2em\noindent##1:\kern1em - \ifacro\pdfnote##2.\else##2\fi.} % index entry + \ifacroHINT\pdfnote##2.\else##2\fi.} % index entry \let\ttentry=\. \def\.##1{\ttentry{##1\kern.2em}} % give \tt a little room \def\[##1]{$\underline{##1}$} % underlined index item \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar @@ -369,7 +397,7 @@ \message{Section names:} \output={\normaloutput\page\lheader\rheader} \setpage - \def\note##1##2.{\quad{\eightrm##1~\ifacro{\pdfnote##2.}\else{##2}\fi.}} + \def\note##1##2.{\quad{\eightrm##1~\ifacroHINT{\pdfnote##2.}\else{##2}\fi.}} \linepenalty=10 % try to conserve lines \def\U{\note{Used in section}} % crossref for use of a section \def\Us{\note{Used in sections}} % crossref for uses of a section @@ -404,15 +432,20 @@ \pageno=\contentspagenumber \def\grouptitle{TABLE OF CONTENTS} \message{Table of contents:} + \ifHINT\HINThome\fi% Mark the Table of contents as home page \topofcontents \startpdf - \line{\hfil Section\hbox to3em{\hss Page}} + \line{\hfil Section\ifHINT\else\hbox to3em{\hss Page}\fi}% No Page in HINT \let\Z=\contentsline \readcontents\relax % read the contents info \botofcontents \end} % print the contents page(s) and terminate \def\contentsline#1#2#3#4{% \line{\ignorespaces#1 \rm\leaders\hbox to .5em{.\hfil}\hfil - \ \ifacro\pdflink{#2}{\romannumeral#2}\else#2\fi\hbox to3em{\hss#3}}} + \ \ifHINT + \HINTlink{#2}{\romannumeral#2}% No page numbers in HINT + \HINTcontents{#1}{#2}{#3}% + \else\ifacro\pdflink{#2}{\romannumeral#2}\else#2\fi + \hbox to3em{\hss#3}\fi}} \def\today{\ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi -- cgit v1.2.3