Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28495 views
License: GPL3
ubuntu2004
1
% Copyright (c) 2000 The PARI Group
2
%
3
% This file is part of the PARI/GP documentation
4
%
5
% Permission is granted to copy, distribute and/or modify this document
6
% under the terms of the GNU General Public License
7
8
%% Modifications to parimacro.tex to be run through pdftex instead of
9
%% tex. Code now includes some pdf-specific code for hyperlinks.
10
%%
11
%% Cliff Bergman ([email protected]) Jan. 2000.
12
%%
13
%
14
%% Set the document info
15
\pdfoutput = 1
16
\pdfinfo {
17
/Title (\TITLE)
18
/Creator (pdfTeX)
19
/Producer (PARI, pari@math.u-bordeaux.fr)
20
/Author (C. Batut, K. Belabas, D. Bernardi, H. Cohen, M. Olivier)
21
/Subject (Number Theory) }
22
%
23
\pdfcatalog {/PageMode /UseOutlines}
24
%
25
\catcode`\@=11
26
%% Now we redefine several of the macros so as to provide hyperlinks.
27
%
28
% Colors
29
%
30
%% We use TeX's grouping mechanism to make \currentcolor into a stack.
31
%
32
\def\pushcolor#1{\bgroup\pdfsetcolor{#1}}
33
\def\popcolor{\egroup\pdfsetcolor{\currentcolor}}
34
\def\pdfsetcolor#1{\let\currentcolor=#1\pdfliteral{#1 k}}
35
% %
36
% % Maybe somebody with a better eye would like to pick nicer ones. See
37
% % the file plain/misc/pdfcolor.tex in the pdftex distribution.
38
% %
39
\def\Red{0 1 1 0}
40
\def\Blue{1 1 0 0}
41
\def\Green{1 0 1 0}
42
\def\Black{0 0 0 1}
43
\def\textcolor{\Black}
44
\def\linkcolor{\Red}
45
\def\emacscolor{\Green}
46
\def\unixcolor{\Blue}
47
\let\currentcolor=\textcolor
48
\pdfsetcolor{\textcolor}
49
%
50
%% Bookmarks. These turned out to be a pain. In order to get nested
51
%% bookmarks, Acrobat requires that each entry declare the number of
52
%% subentries in advance. We do this by counting the subentries (the
53
%% main entries are the chapters, subentries are the sections) during
54
%% the first pass and writing them to the aux file as a macro. Then the
55
%% bookmark entry is created on the second pass.
56
57
% These keep track of the number of sections in each chapter and appendix.
58
\newtoks\numsectok \numsectok={\or}
59
\newtoks\numsecapptok \numsecapptok={\or}
60
61
% Append #1 to the token list given in #2, separated by \or. #1 is
62
% expanded first (needed by \numsecs)
63
\def\append#1#2{\toks0=\expandafter{#1 \or }%
64
\edef\act{\global\noexpand#2={\the#2 \the\toks0}}\act}
65
66
\def\writesecnumbers{
67
% Append the number of sections to the last appendix to the toks reg.
68
\append{\the\secno}\numsecapptok
69
% Write the definitions of (\numsecs and \numsecapp) to the aux file.
70
\write\aux{
71
\def\string\numsecs\string##1{%
72
\string\ifcase \string##1 \the\numsectok 0 \string\else 0 \string\fi}
73
\def\string\numsecsapp\string##1{%
74
\string\ifcase \string##1 \the\numsecapptok 0 \string\else 0 \string\fi}}}
75
%
76
% Hyperlink destinations will simply be of the form: pdf@nnn, where nnn
77
% is obtained from a new counter.
78
\newcount\pdfdestcntr \pdfdestcntr=0
79
% \putdest creates a pdf destination. Currently, the destination view
80
% is 'xyz' which means no change from the existing zoom factor.
81
\def\putdest{\global\advance\pdfdestcntr by 1%
82
\pdfdest name {pdf@\number\pdfdestcntr} xyz }
83
84
%% It turns out that I also need a different counter for these
85
%% destinations since they are only computed on the second pass.
86
\newcount\pdfchapcntr \pdfchapcntr=0
87
\def\putchapdest{\global\advance\pdfchapcntr by1%
88
\pdfdest name {pdfchap@\number\pdfchapcntr} fitbh }
89
90
\def\chapter#1#2\par{
91
\ifnum\chapno=0 \else \append{\the\secno}\numsectok \fi
92
\secno=0\global\advance\chapno by 1
93
\title{Chapter \number\chapno:}{#1}#2\noindent\ignorespaces
94
\ifsecondpass
95
\pdfoutline goto name {pdfchap@\number\pdfchapcntr} count -\numsecs\chapno
96
{\number\chapno\ #1}
97
\fi
98
}
99
\def\appendix#1{
100
\ifnum\appno=0 \append{\the\secno}\numsectok
101
\else \append{\the\secno}\numsecapptok \fi
102
\chapno=0
103
\global\secno=0\global\advance\appno by 1
104
\def\applet{\ifcase\appno\or A\or B\or C\or D\or E\or F\or G\fi}
105
\title{Appendix \applet:}{#1}\noindent\ignorespaces
106
\ifsecondpass
107
\pdfoutline goto name {pdfchap@\number\pdfchapcntr}
108
count -\numsecsapp\appno {\applet\ #1}
109
\fi}
110
\def\section#1{
111
\subsecno=0\global\advance\secno by 1
112
\gdef\currentlabel{\number\secno}
113
\sectitle{\maketitle{#1}}
114
\ifsecondpass
115
\pdfoutline goto name {pdfchap@\number\pdfchapcntr}
116
{\number\chapno.\number\secno\ #1}
117
\fi
118
}
119
%
120
%% FIXME: should use \[push|pop]color and not use explicitly \textcolor
121
%% (cf install() in Chapter 3)
122
\def\@restore{\endgraf \global\let\par\endgraf \pdfsetcolor{\textcolor}}
123
\def\unix{\global\let\par\@restore\pdfsetcolor{\unixcolor}\annotepar{UNIX}}
124
\def\emacs{\global\let\par\@restore\pdfsetcolor{\emacscolor}\annotepar{EMACS}}
125
126
%% labels and symbolic cross-refs. For this we use the parameter to
127
%% build the symbolic pdf destination.
128
\@ifundef{pdfstartlink}{\global\let\pdfstartlink\pdfannotlink}{}
129
\def\label#1{\immediate\write\aux{\string
130
\newlabel{#1}{{\the\chapno}{\currentlabel}}}
131
\pdfdest name {pdf@lab#1} xyz}
132
\def\ref#1{\@ifundef{r@#1}
133
{{\bf ??}\@errundef{#1}}
134
{\edef\@temp{\csname r@#1\endcsname}%
135
\def\lbl{\@ref}\def\chp{\@cref}%
136
\pdfjumpref{#1}{\ifx\chp{\the\chapno}\lbl\else\chp.\lbl\fi}}}
137
\def\pdfjumpref#1#2{\pdfstartlink attr {/Border [ 0 0 0 ] /H /O}
138
goto name {pdf@lab#1}\pushcolor{\linkcolor}#2\popcolor\pdfendlink}
139
140