summaryrefslogtreecommitdiff
path: root/web/pwebmac/pwebmac.tex
diff options
context:
space:
mode:
Diffstat (limited to 'web/pwebmac/pwebmac.tex')
-rw-r--r--web/pwebmac/pwebmac.tex57
1 files changed, 28 insertions, 29 deletions
diff --git a/web/pwebmac/pwebmac.tex b/web/pwebmac/pwebmac.tex
index 6c951058f9..3143de696b 100644
--- a/web/pwebmac/pwebmac.tex
+++ b/web/pwebmac/pwebmac.tex
@@ -5,23 +5,18 @@
% macro integration \`a la CWEB by Andreas Scherer <andreas_tex@freenet.de>.
% 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.7}
-\newif\ifpdf
+\xdef\fmtversion{\fmtversion+WEBMAC4.8}
+\input iftex.sty % TeX engine tests
\ifx\pdf+\pdftrue\fi
% Uncomment the following line if you want PDF goodies to be the default
%\ifx\pdf-\else\pdftrue\fi
\def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color
-\ifx\undefined\XeTeXrevision\else\pdftrue\fi % XeTeX produces PDF output
-\newif\ifpdftex
-\ifx\pdfoutput\undefined \pdftexfalse \else\ifnum\pdfoutput=0 \pdftexfalse
-\else \pdftextrue \pdfoutput=1
+\ifxetex\pdftrue\fi % XeTeX produces PDF output
+\ifpdftex % pdfTeX produces PDF output if \pdfoutput>0
\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
+\fi
+\newif\ifacrohint \ifpdf\acrohinttrue\fi \ifhint\acrohinttrue\fi
\parskip 0pt % no stretch between paragraphs
\parindent 1em % for paragraphs and for the first line of Pascal text
@@ -90,17 +85,19 @@
\newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD
\newtoks\toksE \newtoks\toksF \newtoks\usersanitizer
\newcount\countA \countA=0 \newcount\countB \countB=0
-\newcount\countC \countC=0
+\newcount\countC \countC=0 \newcount\countD \countD=0
+\ifpdftex \ifnum\pdfshellescape=1 {\let\\=\BS
+ \global\countD=\input{|grep -c -e '\\:\\X' \jobname.tex}} \fi\fi
\newif\iftokprocessed \newif\ifTnum \newif\ifinstr
{\def\\{\global\let\spacechar= }\\ }
-\ifacro % The following are pdf macros from 'cwebmac.tex 3.70'
+\ifpdf % The following are pdf macros from 'cwebmac.tex 3.70'
\def\thewidth{\the\wd0 \space}
\def\theheight{\the\ht\strutbox\space}
\def\thedepth{\the\dp\strutbox\space}
\ifpdftex
\ifx\pdfannotlink\undefined\let\pdfannotlink\pdfstartlink\fi% for pdfTeX 0.14
- \def\pdflink#1#2{\hbox{\pdfannotlink height\ht\strutbox depth\dp\strutbox
+ \def\pdflink#1#2{\hbox{\pdfannotlink height \theheight depth \thedepth
attr{/Border [0 0 0]} goto num #1 \PDFlinkcolor #1\Black\pdfendlink}}
\else\def\pdflink#1#2{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}%
\special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight
@@ -191,7 +188,7 @@
\let\pdflink=\HINTlink
\fi % End of HINT macros
-% Common macros for \ifacro and \ifhint
+% Common macros for \ifpdf and \ifhint
\ifacrohint
\def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA}
\def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}%
@@ -219,14 +216,14 @@
\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
+\def\pdfURL#1#2{\ifpdf \ifpdftex\pdfannotlink height \theheight depth \thedepth
+ attr {/Border [0 0 0]} user { /Type /Annot /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}
+ \else {\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}%
+ \special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight
+ depth \thedepth << /Border [0 0 0] /Type /Annot /Subtype /Link /A
+ << /S /URI /URI (#2) >> >>}\box0\relax}\fi
+ \else #1 ({\tt#2})\fi}
{\catcode`\~=12 \gdef\TILDE/{~}} % ~ in a URL
{\catcode`\_=12 \gdef\UNDER/{_}} % _ in a URL
@@ -235,7 +232,7 @@
\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
+ \ifpdf \smash{\raise\baselineskip\hbox to0pt{\let\*=\empty
\ifpdftex \pdfdest num \modstar fith%
\else \special{pdf: dest (\romannumeral\modstar)
[ @thispage /FitH @ypos ]}\fi}}\fi}
@@ -260,15 +257,16 @@
\outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section
\vskip\intersecskip\startsection\ignorespaces}
\outer\def\N#1.#2.{% beginning of starred section
- \ifacro{\toksF={}\makeoutlinetoks#2\outlinedone\outlinedone}\fi
+ \ifpdf{\toksF={}\makeoutlinetoks#2\outlinedone\outlinedone}\fi
\gtitle={#2}\MN#1.\vfil\eject % define running headline
\message{*\modno} % progress report
\def\stripprefix##1>{}\def\gtitletoks{#2}%
\edef\gtitletoks{\expandafter\stripprefix\meaning\gtitletoks}%
\edef\next{\write\cont{\Z{\gtitletoks}{\modno}% write to contents file
{\noexpand\the\pageno}{\the\toksE}}}\next % \Z{title}{sec}{page}{ss}
+ \ifpdftex\relax\else
\ifpdf\special{pdf: outline 0 << /Title (\the\toksE) /Dest
- [ @thispage /FitH @ypos ] >>}\fi
+ [ @thispage /FitH @ypos ] >>}\fi\fi
\ifon\startsection{\bf\ignorespaces#2.\quad}\ignorespaces}
\def\MN#1.{\par % common code for \M, \N
{\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}% remove \* from section name
@@ -330,8 +328,8 @@
\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{\ifpdftex\pdfcatalog{/PageMode /UseOutlines}\else
- \ifpdf{\special{pdf: docview << /PageMode /UseOutlines >>}}\fi\fi}
+\def\startpdf{\ifpdf \ifpdftex\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{}
@@ -402,8 +400,9 @@
\def\U{\note{Used in section}} % crossref for use of a section
\def\Us{\note{Used in sections}} % crossref for uses of a section
\def\:{\par\hangindent 2em}\let\*=*\let\.=\ttentry
- \ifacro \def\outsecname{Names of the sections} \let\Xpdf\X
+ \ifpdf \def\outsecname{Names of the sections} \let\Xpdf\X
\ifpdftex \pdfdest name {NOS} fith
+ \ifnum \the\countD>0 \xdef\modno{\the\countD} \fi
\pdfoutline goto name {NOS} count -\modno {\outsecname}
\def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
{\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
@@ -444,7 +443,7 @@
\ \ifhint
\HINTlink{#2}{\romannumeral#2}% No page numbers in HINT
\HINTcontents{#1}{#2}{#3}%
- \else\ifacro\pdflink{#2}{\romannumeral#2}\else#2\fi
+ \else\ifpdf\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