Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
% Copyright (c) 2000 The PARI Group1%2% This file is part of the PARI/GP documentation3%4% Permission is granted to copy, distribute and/or modify this document5% under the terms of the GNU General Public License67%% Modifications to parimacro.tex to be run through pdftex instead of8%% tex. Code now includes some pdf-specific code for hyperlinks.9%%10%% Cliff Bergman ([email protected]) Jan. 2000.11%%12%13%% Set the document info14\pdfoutput = 115\pdfinfo {16/Title (\TITLE)17/Creator (pdfTeX)18/Producer (PARI, pari@math.u-bordeaux.fr)19/Author (C. Batut, K. Belabas, D. Bernardi, H. Cohen, M. Olivier)20/Subject (Number Theory) }21%22\pdfcatalog {/PageMode /UseOutlines}23%24\catcode`\@=1125%% Now we redefine several of the macros so as to provide hyperlinks.26%27% Colors28%29%% We use TeX's grouping mechanism to make \currentcolor into a stack.30%31\def\pushcolor#1{\bgroup\pdfsetcolor{#1}}32\def\popcolor{\egroup\pdfsetcolor{\currentcolor}}33\def\pdfsetcolor#1{\let\currentcolor=#1\pdfliteral{#1 k}}34% %35% % Maybe somebody with a better eye would like to pick nicer ones. See36% % the file plain/misc/pdfcolor.tex in the pdftex distribution.37% %38\def\Red{0 1 1 0}39\def\Blue{1 1 0 0}40\def\Green{1 0 1 0}41\def\Black{0 0 0 1}42\def\textcolor{\Black}43\def\linkcolor{\Red}44\def\emacscolor{\Green}45\def\unixcolor{\Blue}46\let\currentcolor=\textcolor47\pdfsetcolor{\textcolor}48%49%% Bookmarks. These turned out to be a pain. In order to get nested50%% bookmarks, Acrobat requires that each entry declare the number of51%% subentries in advance. We do this by counting the subentries (the52%% main entries are the chapters, subentries are the sections) during53%% the first pass and writing them to the aux file as a macro. Then the54%% bookmark entry is created on the second pass.5556% These keep track of the number of sections in each chapter and appendix.57\newtoks\numsectok \numsectok={\or}58\newtoks\numsecapptok \numsecapptok={\or}5960% Append #1 to the token list given in #2, separated by \or. #1 is61% expanded first (needed by \numsecs)62\def\append#1#2{\toks0=\expandafter{#1 \or }%63\edef\act{\global\noexpand#2={\the#2 \the\toks0}}\act}6465\def\writesecnumbers{66% Append the number of sections to the last appendix to the toks reg.67\append{\the\secno}\numsecapptok68% Write the definitions of (\numsecs and \numsecapp) to the aux file.69\write\aux{70\def\string\numsecs\string##1{%71\string\ifcase \string##1 \the\numsectok 0 \string\else 0 \string\fi}72\def\string\numsecsapp\string##1{%73\string\ifcase \string##1 \the\numsecapptok 0 \string\else 0 \string\fi}}}74%75% Hyperlink destinations will simply be of the form: pdf@nnn, where nnn76% is obtained from a new counter.77\newcount\pdfdestcntr \pdfdestcntr=078% \putdest creates a pdf destination. Currently, the destination view79% is 'xyz' which means no change from the existing zoom factor.80\def\putdest{\global\advance\pdfdestcntr by 1%81\pdfdest name {pdf@\number\pdfdestcntr} xyz }8283%% It turns out that I also need a different counter for these84%% destinations since they are only computed on the second pass.85\newcount\pdfchapcntr \pdfchapcntr=086\def\putchapdest{\global\advance\pdfchapcntr by1%87\pdfdest name {pdfchap@\number\pdfchapcntr} fitbh }8889\def\chapter#1#2\par{90\ifnum\chapno=0 \else \append{\the\secno}\numsectok \fi91\secno=0\global\advance\chapno by 192\title{Chapter \number\chapno:}{#1}#2\noindent\ignorespaces93\ifsecondpass94\pdfoutline goto name {pdfchap@\number\pdfchapcntr} count -\numsecs\chapno95{\number\chapno\ #1}96\fi97}98\def\appendix#1{99\ifnum\appno=0 \append{\the\secno}\numsectok100\else \append{\the\secno}\numsecapptok \fi101\chapno=0102\global\secno=0\global\advance\appno by 1103\def\applet{\ifcase\appno\or A\or B\or C\or D\or E\or F\or G\fi}104\title{Appendix \applet:}{#1}\noindent\ignorespaces105\ifsecondpass106\pdfoutline goto name {pdfchap@\number\pdfchapcntr}107count -\numsecsapp\appno {\applet\ #1}108\fi}109\def\section#1{110\subsecno=0\global\advance\secno by 1111\gdef\currentlabel{\number\secno}112\sectitle{\maketitle{#1}}113\ifsecondpass114\pdfoutline goto name {pdfchap@\number\pdfchapcntr}115{\number\chapno.\number\secno\ #1}116\fi117}118%119%% FIXME: should use \[push|pop]color and not use explicitly \textcolor120%% (cf install() in Chapter 3)121\def\@restore{\endgraf \global\let\par\endgraf \pdfsetcolor{\textcolor}}122\def\unix{\global\let\par\@restore\pdfsetcolor{\unixcolor}\annotepar{UNIX}}123\def\emacs{\global\let\par\@restore\pdfsetcolor{\emacscolor}\annotepar{EMACS}}124125%% labels and symbolic cross-refs. For this we use the parameter to126%% build the symbolic pdf destination.127\@ifundef{pdfstartlink}{\global\let\pdfstartlink\pdfannotlink}{}128\def\label#1{\immediate\write\aux{\string129\newlabel{#1}{{\the\chapno}{\currentlabel}}}130\pdfdest name {pdf@lab#1} xyz}131\def\ref#1{\@ifundef{r@#1}132{{\bf ??}\@errundef{#1}}133{\edef\@temp{\csname r@#1\endcsname}%134\def\lbl{\@ref}\def\chp{\@cref}%135\pdfjumpref{#1}{\ifx\chp{\the\chapno}\lbl\else\chp.\lbl\fi}}}136\def\pdfjumpref#1#2{\pdfstartlink attr {/Border [ 0 0 0 ] /H /O}137goto name {pdf@lab#1}\pushcolor{\linkcolor}#2\popcolor\pdfendlink}138139140