summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/version-for-dvisvgm/pgfmanual-dvisvgm.cfg
blob: edbd6698ed52ff9ee4621a2c4a379e6e4b16da08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
% Copyright 2019 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\def\pgfsysdriver{pgfsys-dvisvgm.def}

\PassOptionsToPackage{hypertex}{hyperref}
\makeatletter
\g@addto@macro\selectfont{%
  \long\edef\longf@family{\f@family}%
  \ifx\longf@family\ttdefault
    \ignoreligaturesinfont\font\relax
  \fi
}
\makeatother

\usepackage{graphicx,xcolor}

\def\graphicsdvisvgmtext{dvisvgm.def}

\expandafter\ifx\csname Gin@driver\endcsname\graphicsdvisvgmtext
\else
  \PackageError{manual}{You must use dvisvgm.def as your graphics driver}
\fi

% Make sure to compile this using lualatex.


% Add forward button to each page:

\usepackage{everyshi}

\makeatletter
\newbox\pgfmanualbuttonbox
\newcount\pgfmanualcount
\newdimen\mydim

\EveryShipout{%%
  \setbox255=\vbox{%
    \pgfkeys{/pgf/fpu=false}%
    \@tempdima=\ht255\relax%
    \unvbox255%
    \vskip-\@tempdima%
    \pgfmanualaddforwardbackward%
    \pgfmanualaddtoc%
  }%
}

\def\pgfmanualaddforwardbackward{%
  % Adds page forward and page backward buttons at the left and right
  % end of each page
  \let\protect=\relax%
  \pgfmanualcount=\c@page%
  \advance\pgfmanualcount by-1\relax%
  \ifnum\pgfmanualcount>0\relax%
    \begin{pgfpicture}{1in}{-1in}{1in}{-1in}
      \special{dvisvgm:raw <g pointer-events="all" visibility="hidden">}
      \pgftext[top,left]{\href{\jobname-\pgfmanualpadded{\pgfmanualcount}.svg}{{\color{white}\vrule width 2cm height \paperheight}}}
      \special{dvisvgm:raw </g>}
      \special{dvisvgm:raw <g pointer-events="all">}
      \pgftext[top,left]{%
        \href{\jobname-\pgfmanualpadded{\pgfmanualcount}.svg}
             {\vbox to \paperheight{\hsize=2cm\vss\centerline{$\blacktriangleleft$}\vss}}}
      \special{dvisvgm:raw </g>}
    \end{pgfpicture}%
  \fi%
  \advance\pgfmanualcount by2\relax%
  \begin{pgfpicture}{-\paperwidth+1in}{-1in}{-\paperwidth+1in}{-1in}
    \special{dvisvgm:raw <g pointer-events="all" visibility="hidden">}
    \pgftext[top,right]{\href{\jobname-\pgfmanualpadded{\pgfmanualcount}.svg}{\color{white}{\vrule width 2cm height \paperheight}}}
    \special{dvisvgm:raw </g>}
    \special{dvisvgm:raw <g pointer-events="all">}
    \pgftext[top,right]{%
      \href{\jobname-\pgfmanualpadded{\pgfmanualcount}.svg}%
           {\vbox to \paperheight{\hsize=2cm\vss\centerline{$\blacktriangleright$}\vss}}}
    \special{dvisvgm:raw </g>}
  \end{pgfpicture}%
}

\newbox\chapterbox

\newcount\pgfmanualpartcount
\newcount\pgfmanualsectioncount
\newcount\pgfmanualsubsectioncount
\newcount\pgfmanualsubsubsectioncount

\newcount\pgfmanualtempcount

\newtoks\toctoks
{% Read toc into \toctoks

  \global\toctoks{
    \global\pgfmanualpartcount0\relax
    \global\pgfmanualsectioncount0\relax
    \global\pgfmanualsubsectioncount0\relax
    \global\pgfmanualsubsubsectioncount0\relax
  }
  
  \def\contentsline#1#2#3#4{%
    \expandafter\let\expandafter\pgfmanualhandler\csname pgfmanualhandlekind#1\endcsname%
    \ifx\pgfmanualhandler\relax%
      \PackageError{manual}{Unknown contents level '#1'}{}%
    \else%
      \pgfmanualhandler{#2}{#3}{#4}%%
    \fi%
    \ignorespaces%
  }

  \def\pgfmanualhandlekindpart#1#2#3{%
    \pgfmanualtempcount#2\relax%
    \advance\pgfmanualtempcount by-1\relax%
    \edef\pgfmanualtemponepagebefore{\the\pgfmanualtempcount}%
    \pgfmanualtempcount\pgfmanualpartcount\relax%
    \advance\pgfmanualtempcount by-1\relax%
    \expandafter\xdef\csname pgfmanualpartendpage\the\pgfmanualpartcount\endcsname{\pgfmanualtemponepagebefore}%
    \global\advance\pgfmanualpartcount by1\relax%
    \expandafter\gdef\csname pgfmanualpartstartpage\the\pgfmanualpartcount\endcsname{#2}%
    \expandafter\global\expandafter\toctoks\expandafter{\the\toctoks\pgfmanualtypesetpart{#1}{#2}}%
  }
  \def\pgfmanualhandlekindsection#1#2#3{%
    \pgfmanualtempcount#2\relax%
    \advance\pgfmanualtempcount by-1\relax%
    \edef\pgfmanualtemponepagebefore{\the\pgfmanualtempcount}%
    \pgfmanualtempcount\pgfmanualsectioncount\relax%
    \advance\pgfmanualtempcount by-1\relax%
    \expandafter\xdef\csname pgfmanualsectionendpage\the\pgfmanualsectioncount\endcsname{\pgfmanualtemponepagebefore}%
    \global\advance\pgfmanualsectioncount by1\relax%
    \expandafter\gdef\csname pgfmanualsectionstartpage\the\pgfmanualsectioncount\endcsname{#2}%
    \expandafter\global\expandafter\toctoks\expandafter{\the\toctoks\pgfmanualtypesetsection{#1}{#2}}%
  }
  \def\pgfmanualhandlekindsubsection#1#2#3{%
    \pgfmanualtempcount#2\relax%
    \advance\pgfmanualtempcount by-1\relax%
    \edef\pgfmanualtemponepagebefore{\the\pgfmanualtempcount}%
    \pgfmanualtempcount\pgfmanualsubsectioncount\relax%
    \advance\pgfmanualtempcount by-1\relax%
    \expandafter\xdef\csname pgfmanualsubsectionendpage\the\pgfmanualsubsectioncount\endcsname{\pgfmanualtemponepagebefore}%
    \global\advance\pgfmanualsubsectioncount by1\relax%
    \expandafter\gdef\csname pgfmanualsubsectionstartpage\the\pgfmanualsubsectioncount\endcsname{#2}%
    \expandafter\global\expandafter\toctoks\expandafter{\the\toctoks\pgfmanualtypesetsubsection{#1}{#2}}%
  }
  \def\pgfmanualhandlekindsubsubsection#1#2#3{%
    \pgfmanualtempcount#2\relax%
    \advance\pgfmanualtempcount by-1\relax%
    \edef\pgfmanualtemponepagebefore{\the\pgfmanualtempcount}%
    \pgfmanualtempcount\pgfmanualsubsubsectioncount\relax%
    \advance\pgfmanualtempcount by-1\relax%
    \expandafter\xdef\csname pgfmanualsubsubsectionendpage\the\pgfmanualsubsubsectioncount\endcsname{\pgfmanualtemponepagebefore}%
    \global\advance\pgfmanualsubsubsectioncount by1\relax%
    \expandafter\gdef\csname pgfmanualsubsubsectionstartpage\the\pgfmanualsubsubsectioncount\endcsname{#2}%
    \expandafter\global\expandafter\toctoks\expandafter{\the\toctoks\pgfmanualtypesetsubsubsection{#1}{#2}}%
  }
  \def\pgfmanualhandlekindparagraph#1#2#3{%
    % ignore
  }
  
  \IfFileExists{\jobname.toc}{\input{\jobname.toc}}{}%
}

{\catcode`\#=11
\gdef\pgfmanualhashmark{#}
}

\def\pgfmanualaddifnotempty#1#2{%
  \ifvoid#1%
  \else%
    \setbox#1=\vtop{%
      \hsize\mydim%
      \leavevmode{\strut#2}%
      \unvbox#1%
    }%
  \fi%
}

\definecolor{tocbackground}{rgb}{0.99,0.99,0.97}

\def\pgfmanualpickpage#1#2#3#4#5{%
  \c@pgf@counta#2\relax%
  \xdef\pgfmanualtocpage{\the\c@pgf@counta}%
}

\def\pgfmanualaddtoc{%
  \begingroup
    \expandafter\let\expandafter\pgfmanualtemp\csname r@table-of-contents\endcsname%
    \ifx\pgfmanualtemp\relax%
      \def\pgfmanualtocpage{1}%
    \else%
      \expandafter\pgfmanualpickpage\pgfmanualtemp%
    \fi%
    \let\numberline\pgfmanualpagetocnumberline%
    \mydim\paperwidth\advance\mydim by-3cm%
    \mydim=\mydim\relax%
    \footnotesize%
    \setbox\chapterbox=\box\voidb@x%
    \pgfmanualpagetoctobox{\chapterbox}{\pgfmanualpagetocline{\pgfmanualtocpage}{\Large\textbf{Contents}\vrule
        width0pt height7mmdepth2.5mm}{0cm}{tocbackground}}%
    \the\toctoks%
    \begin{pgfpicture}{1in-1.5cm}{-1in}{1in-1.5cm}{-1in}
      \pgftext[top,left]{\vbox{%
          \nointerlineskip%
          \parskip0pt%
          \hsize=\mydim%
          \leftskip0pt%
          \rightskip0pt%
          \parindent0pt%
          \special{dvisvgm:raw
            <style type="text/css">
            \pgfmanualhashmark toc:hover \pgfmanualhashmark content { visibility: visible }
            </style>
            <g id="toc" opacity=".97">
          }%
          \special{dvisvgm:raw <g pointer-events="all" visibility="hidden">}
          {\color{white}{\vrule width\mydim height 2cm}}\break%
          \special{dvisvgm:raw </g> }%
          \hbox{}\vskip-2.6cm\break\leavevmode%
          \special{dvisvgm:raw
            <g id="content" visibility="hidden">
          }%
          \box\chapterbox\break%
          \hbox{}\vskip-2pt\break%
          {\color{tocbackground}{\vrule width\mydim height 5mm}}\break%
          \special{dvisvgm:raw </g> }%
          \special{dvisvgm:raw </g> }
        }}%
    \end{pgfpicture}    
  \endgroup
}
\def\pgfmanualpadded#1{%
  \ifnum#1<1000 0\fi%
  \ifnum#1<100 0\fi%
  \ifnum#1<10 0\fi%
  \the#1%
}

\def\pgfmanualpagetocnumberline#1{}
\def\pgfmanualpagetoctobox#1#2{%
  \setbox#1=\vtop{%
    \unvbox#1%
    #2}%
}
\newdimen\pgfmanualtoclineskip
\pgfmanualtoclineskip1.5pt
\def\pgfmanualpagetocline#1#2#3#4{%
  \pgfmanualtempcount#1%
  \vskip-1pt%
  \hbox{\href{\jobname-\pgfmanualpadded{\pgfmanualtempcount}.svg}{%
      \fboxsep0pt%
      \colorbox{#4}{\vbox{%
          \vskip\pgfmanualtoclineskip
          \hsize\mydim%
          \leftskip#3%
          \advance\leftskip by5mm%
          \rightskip1em plus1fil%
          \advance\rightskip by5mm%
          \noindent\strut#2\strut}}}}%
}


\newif\ifpgfmanualbetweentest

\def\pgfmanualifin#1#2#3#4{%
  \pgfmanualbetweentestfalse
  \expandafter\let\expandafter\pgfmanualstartnum\csname pgfmanual#1startpage\expandafter\the\csname pgfmanual#1count\endcsname\endcsname%
  \ifx\pgfmanualstartnum\relax%
    \def\pgfmanualstartnum{-1}%
  \fi%
  \expandafter\let\expandafter\pgfmanualendnum\csname pgfmanual#1endpage\expandafter\the\csname pgfmanual#1count\endcsname\endcsname%
  \ifx\pgfmanualendnum\relax%
    \def\pgfmanualendnum{1000000000}%
  \fi%
  \ifnum\pgfmanualstartnum>\pgfmanualendnum\relax%
    \let\pgfmanualendnum\pgfmanualstartnum%
  \fi%
  \ifnum\pgfmanualstartnum>#2\relax%
  \else%
    \ifnum\pgfmanualendnum<#2\relax%
    \else%
      \pgfmanualbetweentesttrue%
    \fi%
  \fi%  
  \ifpgfmanualbetweentest%
    #3%
  \else
    #4%
  \fi%
}

\def\pgfmanualtypesetpart#1#2{%
  \pgfmanualcleanuppart#1\relax%
  \global\advance\pgfmanualpartcount by1\relax%
  \pgfmanualifin{part}{\c@page}{\global\let\pgfmanualthispart\pgfmanualparttext}{}%
  \pgfmanualpagetoctobox{\chapterbox}{%
    \pgfmanualpagetocline{#2}{%
      \pgfmanualifin{part}{\c@page}{\bfseries\pgfmanualparttext}{\pgfmanualparttext}%
    }{1.5cm}{tocbackground}}%
}
\def\pgfmanualcleanuppart#1\hspace#2#3\relax{%
  \def\pgfmanualparttext{\llap{\hbox to 1.5cm{Part #1\hss}}#3}%
}

\def\pgfmanualtypesetsection#1#2{%
  \global\advance\pgfmanualsectioncount by1\relax%
  \pgfmanualifin{part}{\c@page}{%
    \pgfmanualifin{section}{\c@page}{\gdef\pgfmanualthischapter{#1}}{}%
    \pgfmanualpagetoctobox{\chapterbox}{%
      \def\numberline##1{\llap{##1\hskip3mm}}%
      \pgfmanualpagetocline{#2}{%
        \pgfmanualifin{section}{\c@page}{\bfseries\itshape#1}{\itshape#1}%
      }{1.5cm}{tocbackground}}%
  }{}%
}
\def\pgfmanualtypesetsubsection#1#2{%
  \global\advance\pgfmanualsubsectioncount by1\relax%
  \pgfmanualifin{part}{\c@page}{%
    \pgfmanualifin{section}{\c@page}{%
      \pgfmanualpagetoctobox{\chapterbox}{%
        \pgfmanualextraskip5mm%
        \pgfmanualpagetocline{#2}{
          \pgfmanualifin{subsection}{\c@page}{\bfseries}{}#1%
        }{2cm}{tocbackground}}%
    }{}%
  }{}%
}
\def\pgfmanualtypesetsubsubsection#1#2{%
  \global\advance\pgfmanualsubsubsectioncount by1\relax%
  \pgfmanualifin{part}{\c@page}{%
    \pgfmanualifin{section}{\c@page}{%
        \pgfmanualextraskip10mm%
        \pgfmanualpagetoctobox{\chapterbox}{\pgfmanualpagetocline{#2}{%
            \pgfmanualifin{subsubsection}{\c@page}{\bfseries}{}\itshape#1%
          }{2.5cm}{tocbackground}}%
    }{}%
  }{}%
}
\def\pgfmanualsplitnumberline#1{%
  \pgfmanualsplitnumberline@#1\relax%
}
\def\pgfmanualsplitnumberline@#1.#2\relax{%
  \llap{#1\rlap{.#2}\hskip3mm\hskip\pgfmanualextraskip}%
}
\newdimen\pgfmanualextraskip

\makeatother