Debian Codegraph @

texmf-dist/source/latex/xbmks/xbmks.dtx

raw
1 %\iffalse
2 % makeindex -s gglo.ist -o xbmks.gls xbmks.glo
3 % makeindex -s gind.ist -o xbmks.ind xbmks.idx
4 %<*copyright>
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 %% xbmks.sty package, %%
7 %% Copyright (C) 2016--2018 %%
8 %% [email protected] %%
9 %% %%
10 %% This program can redistributed and/or modified under %%
11 %% the terms of the LaTeX Project Public License %%
12 %% Distributed from CTAN archives in directory %%
13 %% macros/latex/base/lppl.txt; either version 1.2 of the %%
14 %% License, or (at your option) any later version. %%
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 %</copyright>
17 %<package>\NeedsTeXFormat{LaTeX2e}[1997/12/01]
18 %<package>\ProvidesPackage{xbmks}
19 %<package> [2020/01/16 v2.0.3 xbmks: Cross-document bookmarks (dps)]
20 %<*driver>
21 \documentclass{ltxdoc}
22 \usepackage{xcolor}
23 \usepackage[colorlinks,hyperindex=false,bookmarksopen]{hyperref}
24 \usepackage{fancyvrb,array,calc}
25 \usepackage{xbmks}
26 \xbmksetup{colors={int=red},styles={intbf}}
27 %\pdfstringdefDisableCommands{\let\\\textbackslash}
28 \EnableCrossrefs
29 \CodelineIndex
30 \RecordChanges
31 \bgroup\ttfamily
32 \gdef\brpr#1{\char123\relax#1\char125\relax}\egroup
33 \let\darg\brpr
34 \let\env\texttt
35 \let\opt\texttt
36 \let\pkg\textsf
37 \let\app\textsf
38 \def\visispace{\symbol{32}}
39 %\def\hardspace{{\fontfamily{cmtt}\selectfont\symbol{32}}}
40 \def\ameta#1{\ensuremath{\langle\textit{\texttt{#1}}\rangle}}
41 \def\meta#1{\textsl{\texttt{#1}}}
42 \def\SUB#1{\ensuremath{{}_{\mbox{\scriptsize\ttfamily#1}}}}
43 \def\cs#1{\texttt{\bslash#1}}
44 \DeclareRobustCommand{\tmspace}[3]{%
45 \ifmmode\mskip#1#2\else\kern#1#3\fi\relax}
46 \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}}
47 \let\thinspace\,
48 \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}}
49 \let\negthinspace\!
50 \renewcommand{\:}{\tmspace+\medmuskip{.2222em}}
51 \let\medspace\:
52 \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}}
53 \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}}
54 \let\thickspace\;
55 \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}}
56 \makeatletter
57 \renewcommand{\paragraph}
58 {\@startsection{paragraph}{4}{0pt}{6pt}{-3pt}
59 {\normalfont\normalsize\bfseries}}
60 \renewenvironment{quote}[1][]
61 {\def\@rgi{#1}\ifx\@rgi\@empty
62 \let\rghtm\@empty\else\def\rghtm{\rightmargin\leftmargin}\fi
63 \list{}{\rghtm} %{\rightmargin\leftmargin}%
64 \item\relax}
65 {\endlist}
66 \makeatother
67 \InputIfFileExists{aebdocfmt.def}{\PackageInfo{xbmks}{Inputting aebdocfmt.def}}
68 {\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro}\let\setupFullwidth\relax
69 \PackageInfo{xbmks}{aebdocfmt.def cannot be found}}
70 \begin{document}
71 \def\CMD#1{\textbackslash#1}
72 \GetFileInfo{xbmks.sty}
73 \title{\textsf{xbmks}: Cross-document bookmarks}
74 \author{D. P. Story\\
75 Email: \texttt{[email protected]}}
76 \date{processed \today}
77 \maketitle
78 \tableofcontents
79 \let\Email\texttt
80 \DocInput{xbmks.dtx}
81 \IfFileExists{\jobname.ind}{\newpage\setupFullwidth\par\PrintIndex}{\paragraph*{Index} The index goes here.\\Execute
82 \texttt{makeindex -s gind.ist -o xbmks.ind xbmks.idx}\\on the command line and recompile
83 \texttt{xbmks.dtx}.}
84 \IfFileExists{\jobname.gls}{\PrintChanges}{\paragraph*{Change History} The list of changes goes here.\\Execute
85 \texttt{makeindex -s gglo.ist -o xbmks.gls xbmks.glo}\\on the command line and recompile
86 \texttt{xbmks.dtx}.}
87 \end{document}
88 %</driver>
89 % \fi
90 % \MakeShortVerb{|}
91 %
92 % \InputIfFileExists{aebdonotindex.def}{\PackageInfo{web}{Inputting aebdonotindex.def}}
93 % {\PackageInfo{web}{cannot find aebdonotindex.def}}
94 %
95 % \begin{macrocode}
96 % Begin package
97 %<*package>
98 \RequirePackage{xkeyval}
99 \RequirePackage{ifpdf}[2006/02/20]
100 \RequirePackage{ifxetex}[2006/08/21]
101 % \end{macrocode}
102 %
103 %\section{Description}
104 % More than a couple decades ago (counting back from 2018), I wrote two mathematics tutorials: \textsl{\href{http://www.math.uakron.edu/~dpstory/e-calculus.html}{eCalculus}} and
105 % \textsl{\href{http://www.math.uakron.edu/~dpstory/mpt_home.html}{Algebra Review in Ten Lessons}}. The tutorials consisted of a number of lessons, each in a separate PDF.
106 % The bookmarks of each lessons contained the table of contents for the whole tutorial. A student, in theory, could then
107 % jump from one lesson to another by selecting an entry of interest from the bookmarks. In the intervening years I have not seen
108 % a {\LaTeX} package for merging the table of contents of a set of PDFs and merge them in this each member of the
109 % set. This package attempts to do just that.
110 %
111 % \section{Drivers and options}
112 % We support the drivers \app{dvips} (and \app{dvipsone}), \app{pdflatex}, \app{lualatex}, and \app{xelatex}; these
113 % options are then named \opt{dvipsone}, \opt{dvips}, \opt{pdftex}, \opt{luatex}, and \opt{xetex}.
114 % \changes{v1.1}{2018/06/13}{Fixed misspelling of drive command for pdfmark case}
115 % \begin{macrocode}
116 \def\xbmk@driver{xbmks-pdfmark.def}
117 \DeclareOptionX{dvipsone}{\def\xbmk@driver{xbmks-pdfmark.def}}
118 \DeclareOptionX{dvips}{\def\xbmk@driver{xbmks-pdfmark.def}}
119 \DeclareOptionX{pdftex}{\def\xbmk@driver{xbmks-pdftex.def}}
120 \DeclareOptionX{luatex}{\def\xbmk@driver{xbmks-pdftex.def}}
121 \DeclareOptionX{xetex}{\def\xbmk@driver{xbmks-xetex.def}}
122 % \end{macrocode}
123 % \section{Process the options}
124 % \changes{v2.0.3}{2020/01/16}{Modification to conform to the new \string\texttt{web.cfg} format}
125 % \begin{macrocode}
126 \let\bWebCustomize\endinput
127 \let\eWebCustomize\relax
128 \ifpdf\ExecuteOptionsX{pdftex}\else
129 \ifxetex\ExecuteOptionsX{xetex}\else
130 \let\ExecuteOptions@SAVE\ExecuteOptions
131 \let\ExecuteOptions\ExecuteOptionsX
132 \InputIfFileExists{web.cfg}{}
133 {\@ifundefined{l@tex@@@@driver}{\ExecuteOptionsX{dvips}}
134 {\ExecuteOptionsX{dvipsone}}}%
135 \let\ExecuteOptions\ExecuteOptions@SAVE
136 \fi\fi
137 \ProcessOptionsX
138 % \end{macrocode}
139 % \section{Requirements}
140 % The minimal requirement is \pkg{hyperref} and its built-in bookmark system. It is important to note that
141 % the \pkg{bookmark} package is not supported.
142 % \begin{macrocode}
143 \RequirePackage{hyperref}
144 % \end{macrocode}
145 % \begin{macro}{\xbmksetup}
146 % Set the cross-document options:
147 % \changes{v1.1}{2018/06/13}{Allow an empty value of docbundle, its value is set to \string\cs{jobname}}%
148 %\begin{quote}\ttfamily\obeylines
149 %\string\xbmksetup\darg{%
150 %\qquad docbundle=\darg{\ameta{doc\SUB1},\ameta{doc\SUB2},...,\ameta{doc\SUB{n}}},
151 %\qquad colors=\darg{int=\ameta{color},ext=\ameta{color}},
152 %\qquad styles=\darg{intbf,extbf,intit,extit}
153 %}
154 %\end{quote}
155 %This command must appear in one and only one of the document bundle, perhaps one
156 %of the documents you are calling the `main file'. It writes
157 %the key-values to the file \texttt{xbmks.cfg} which is then read back in by the other
158 %members of the document bundle, as specified by the \texttt{dobundle} key. The base names
159 %of the document bundle must match the name given to it by \cs{jobname}, exact spelling, case
160 %sensitive.
161 %
162 %\paragraph*{Key-values for \cs{xbmksetup}.} The keys belonging to the \texttt{xbmksetup} family:
163 %\IndexOpt{docbundle}\texttt{docbundle}, \IndexOpt{colors}\texttt{colors}, and \IndexOpt{styles}\texttt{styles}.
164 % \begin{macrocode}
165 \define@key{xbmksetup}{docbundle}[]{\def\x@bmks@docs{#1}}
166 \let\x@bmks@docs\@empty
167 \define@key{xbmksetup}{colors}[]{\def\x@bmks@colors{#1}}
168 \let\x@bmks@colors\@empty
169 \define@key{xbmksetup}{styles}[]{\def\x@bmks@styles{#1}}
170 \let\x@bmks@styles\@empty
171 % \end{macrocode}
172 %\subparagraph*{Values for the key \texttt{colors}.} The value recognized are
173 %\begin{quote}\ttfamily
174 % colors=\darg{int=\ameta{color},ext=\ameta{color}}
175 %\end{quote}
176 %If the value of \texttt{int} or \texttt{ext} is empty, then the PDF viewer's default
177 %colors are using (black).
178 % \begin{macrocode}
179 \define@key{xbmk@colors}{int}[]{%
180 \HyColor@BookmarkColor{#1}{\xbmks@intC}{xbmks}{int}%
181 \ifx\xbmks@intC\@empty\else
182 \edef\xbmks@intC{/C[\xbmks@intC]}\fi
183 }
184 \let\xbmks@intC\@empty
185 \define@key{xbmk@colors}{ext}[]{%
186 \HyColor@BookmarkColor{#1}{\xbmks@extC}{xbmks}{ext}%
187 \ifx\xbmks@extC\@empty\else
188 \edef\xbmks@extC{/C[\xbmks@extC]}\fi
189 }
190 \let\xbmks@extC\@empty
191 \let\xbmks@Yes=y \let\xbmks@No=n
192 % \end{macrocode}
193 %\subparagraph*{Values for the key \texttt{colors}.} The value recognized are
194 %\begin{quote}\ttfamily
195 % styles=\darg{intbf,intit,extbf,extit}
196 %\end{quote}
197 %These are valueless keys (Boolean keys, actually). \texttt{intbf} means the interior document bookmarks
198 %are set in bold while \texttt{intbf,intit} creates bold and italic font.
199 % \begin{macrocode}
200 \define@boolkey{xbmk@styles}{intbf}[true]{}
201 \define@boolkey{xbmk@styles}{extbf}[true]{}
202 \define@boolkey{xbmk@styles}{intit}[true]{}
203 \define@boolkey{xbmk@styles}{extit}[true]{}
204 % \end{macrocode}
205 % We evaluate the values of \cs{xbmksetup} by getting the values of
206 % the \texttt{xbmksetup} family.
207 % \begin{macrocode}
208 \newcommand{\xbmksetup}[1]{\setkeys{xbmksetup}{docbundle,#1}%
209 % \end{macrocode}
210 % \changes{v2.0.2}{2018/07/04}{Added an empty docbundle argument. This solves a problem
211 % that the bookmarks not appearing after an even number of compiles.}
212 % \begin{macrocode}
213 \ifx\x@bmks@docs\@empty
214 % \end{macrocode}
215 % If there is no \texttt{docbundle} is specified, we use \cs{jobname} as its
216 % value.
217 % \begin{macrocode}
218 \PackageInfo{xbmks}{The docbundle key of \string\xbmksetup\space
219 is empty,\MessageBreak
220 I will give it a value of `\jobname',\MessageBreak
221 in hopes this is your intention}%
222 \gdef\xbmk@cnt{1}%
223 \def\xbmks@next{\write@xbmks@cfg{docbundle={\jobname},#1}}\else
224 \def\xbmks@next{\write@xbmks@cfg{#1}}\fi\xbmks@next
225 }
226 % \end{macrocode}
227 % We write the key-values of \cs{xbmksetup} to the hard drive in the file
228 % \texttt{xbmks.cfg}, this is \cs{xbmksetupi\darg{\ameta{KVPairs}}}. \cs{xbmksetupi}
229 % is defined below, it is the command that actually does the heavy lifting in
230 % processing the key-values.
231 % \begin{macrocode}
232 \def\write@xbmks@cfg#1{%
233 \newwrite\xbmks@setup \immediate\openout \xbmks@setup xbmks.cfg
234 \set@display@protect
235 \immediate\write\xbmks@setup{\protect\xbmksetupi{#1}}%
236 \set@typeset@protect
237 \immediate\closeout\xbmks@setup
238 }
239 % \end{macrocode}
240 % \cs{xbmksetupi} is an internal command that sets the key-values across all files in the \texttt{docbundle}.
241 % \begin{macrocode}
242 \newcommand{\xbmksetupi}[1]{%
243 \setkeys{xbmksetup}{#1}%
244 \edef\x{\noexpand\x@docbundle{\x@bmks@docs}}\x
245 \edef\x{\noexpand
246 \setkeys{xbmk@colors}{\x@bmks@colors}}\x
247 \edef\x{\noexpand
248 \setkeys{xbmk@styles}{\x@bmks@styles}}\x
249 \let\xbmk@intF\@empty
250 \ifKV@xbmk@styles@intit
251 \ifKV@xbmk@styles@intbf
252 \def\xbmk@intF{/F 3}\else
253 \def\xbmk@intF{/F 1}\fi
254 \else
255 \ifKV@xbmk@styles@intbf
256 \def\xbmk@intF{/F 2}\fi
257 \fi
258 \let\xbmk@extF\@empty
259 \ifKV@xbmk@styles@extit
260 \ifKV@xbmk@styles@extbf
261 \def\xbmk@extF{/F 3}\else
262 \def\xbmk@extF{/F 1}\fi
263 \else
264 \ifKV@xbmk@styles@extbf
265 \def\xbmk@extF{/F 2}\fi
266 \fi
267 }
268 % \end{macrocode}
269 % \end{macro}
270 % \begin{macro}{\x@docbundle}
271 % is a comma-delimited list of document base names:
272 %\begin{quote}\ttfamily\obeylines
273 %\string\x@docbundle\darg{\ameta{doc\SUB1},\ameta{doc\SUB2},...,\ameta{doc\SUB{n}}}
274 %\end{quote}
275 %This command is called internally by \cs{xbmksetupi}.
276 % \begin{macrocode}
277 \def\xbmkcsarg#1#2{\expandafter#1\csname#2\endcsname}
278 \xdef\xbmk@cnt{0}
279 \newcommand{\x@docbundle}[1]{\bgroup
280 \def\thisDoc{\jobname}\count\z@=0 %
281 \edef\@tmpexp{\noexpand\@for\noexpand\@arg:=#1}%
282 \@tmpexp\do{\advance\count\z@ by 1\relax
283 \edef\x{\noexpand\xbmk@recordDoc{\@arg}}\x
284 \edef\x{\noexpand\xbmk@docID{\@arg}}\x
285 }%
286 \xdef\xbmk@cnt{\the\count\z@}\egroup
287 }
288 \newcommand{\xbmk@recordDoc}[1]{%
289 \xbmkcsarg\xdef{xbmk@doc\the\count\z@}{#1}}
290 % \end{macrocode}
291 % Because we are bringing in multiple outline files, there may be duplicate anchor names.
292 % We assign each file in the document bundle a unique ID `\texttt{x1\ameta{anchor}}', `\texttt{x2\ameta{anchor}}', etc.
293 % The IDs are ultimately assigned through \cs{pdfbookmarkx}.
294 % \begin{macrocode}
295 \newcommand{\xbmk@docID}[1]{%
296 \xbmkcsarg\xdef{x#1}{x\the\count\z@}}
297 \xbmkcsarg\xdef{x\jobname}{x0}
298 % \end{macrocode}
299 % \end{macro}
300 %
301 % \section{Extending bookmarks to arbitrary actions}
302 %
303 % It is possible to create bookmarks with arbitrary actions, just as the \pkg{bookmark}
304 % package, does. Here we try to use \pkg{hyperref}'s native bookmark support. The
305 % \pkg{hyperref} commands \cs{pdfbookmark}, \cs{currentbookmark}, \cs{subpdfbookmark}, and
306 % \cs{belowpdfbookmark} are modified.
307 % \begin{macro}{\pdfbookmarkx}\hskip-\marginparsep\,
308 % \texttt{[\ameta{level}]\darg{\ameta{text}}[\ameta{xbmkskeys-kvp}]\darg{\ameta{name}}}\\
309 % Defines a bookmark at \ameta{level}. If \ameta{level} is not provided, the level 1 is assumed.
310 % We write to the outline file the action desired for this bookmark.
311 % \cs{currentAction} is defined below. We do not set an anchor; if the
312 % document author wants an anchor, he should use \cs{pdfbookmark}. As with
313 % \cs{pdfbookmark}, the \cs{pdfbookmarkx} should not normally be directly
314 % used.
315 % \paragraph*{Key-values for the `\cs{...bookmarkx}' commands.} Recognized keys are
316 % \IndexKey{action}\texttt{action}, \IndexKey{color}\texttt{color}, and \IndexKey{style}\texttt{style}.
317 % Note that these keys are singular, as opposed to \texttt{colors} and \texttt{styles} defined in the
318 % \texttt{xbmksetup} family. This is the \texttt{xbmkskeys} family.
319 % \changes{v2.0}{2018/06/21}{Added `\string\cs{...bookmarkx} commands}
320 % \changes{v2.0.1}{2018/06/25}{Added key-values for action, color, and style for custom `\string\cs{...bookmarkx} commands}
321 % \begin{macrocode}
322 \define@key{xbmkskeys}{action}{\def\x@bmks@action{#1}}
323 \let\x@bmks@action\@empty
324 \define@key{xbmkskeys}{color}[]{%
325 \HyColor@BookmarkColor{#1}{\x@bmks@C}{xbmks}{color}%
326 \ifx\x@bmks@C\@empty\else
327 \edef\x@bmks@C{/C[\x@bmks@C]}\fi
328 }
329 \let\x@bmks@C\@empty
330 \define@key{xbmkskeys}{style}[]{%
331 \edef\x{\noexpand\setkeys{xbmks@style}{#1}}\x
332 \let\x@bmks@F\@empty
333 \ifKV@xbmks@style@it
334 \ifKV@xbmks@style@bf
335 \def\x@bmks@F{/F 3}\else
336 \def\x@bmks@F{/F 1}\fi
337 \else
338 \ifKV@xbmks@style@bf
339 \def\x@bmks@F{/F 2}\fi
340 \fi
341 }
342 \let\x@bmks@F\@empty
343 % \end{macrocode}
344 % The \texttt{style} key takes zero, one, or two values, these are \texttt{bf} and \texttt{it}.
345 % \begin{macrocode}
346 \define@boolkey{xbmks@style}{bf}[true]{}
347 \define@boolkey{xbmks@style}{it}[true]{}
348 \def\x@rollCFIntoActionBmrk#1{%
349 \xbmkcsarg\ifx{X_#1}\relax
350 \let\x@bmks@C\@empty\let\x@bmks@F\@empty\fi
351 \ifx\xbmk@J\xbmk@filename
352 \ifx\x@bmks@C\@empty\let\thisCol\xbmks@intC\else
353 \let\thisCol\x@bmks@C\fi
354 \ifx\x@bmks@F\@empty\let\thisF\xbmk@intF\else
355 \let\thisF\x@bmks@F\fi
356 \else
357 \ifx\x@bmks@C\@empty\let\thisCol\xbmks@extC\else
358 \let\thisCol\x@bmks@C\fi
359 \ifx\x@bmks@F\@empty\let\thisF\xbmk@extF\else
360 \let\thisF\x@bmks@F\fi
361 \fi
362 \global\let\x@bmks@C\@empty\global\let\x@bmks@F\@empty
363 }
364 % \end{macrocode}
365 % We finally arrive at \cs{pdfbookmarkx} command.
366 % \begin{macrocode}
367 \newcommand\pdfbookmarkx[2][0]{%
368 \@ifnextchar[%]
369 {\pdfbookmarkx@i{#1}{#2}}
370 {\pdfbookmarkx@i{#1}{#2}[]}}
371 \def\pdfbookmarkx@i#1#2[#3]#4{% level, title, action, name
372 \def\x@rgiii{#3}\ifx\x@rgiii\@empty
373 % \end{macrocode}
374 % if there is no action, treat as a destination
375 % \begin{macrocode}
376 \Hy@writebookmark{}{#2}{#4.#1}{#1}{toc}%
377 \hyper@anchorstart{#4.#1}\hyper@anchorend
378 \else
379 \protected@write\@outlinefile{}{%
380 \string\nextAction% assign doc ID
381 {\@nameuse{x\jobname}#4.#1}{#3}}%
382 \Hy@writebookmark{}{#2}{\@nameuse{x\jobname}#4.#1}{#1}{toc}%
383 \fi
384 }
385 % \end{macrocode}
386 % \end{macro}
387 % \begin{macro}{\currentpdfbookmarkx}
388 % \hskip-\marginparsep\,\texttt{\darg{\ameta{text}}[\ameta{xbmkskeys-kvp}]\darg{\ameta{name}}}\\
389 % The \texttt{action=\ameta{action}} is raw PDF code, for example,
390 %\begin{quote}\ttfamily
391 %\string\currentpdfbookmarkx[/S/URI/URI(http://www.acrotex.net)]\\\null
392 %\qquad\darg{http://www.acrotex.net}\darg{home}
393 %\end{quote}
394 % The command creates a bookmark at the current
395 % bookmark level in the outline tree and associates the specified \ameta{action}. The argument
396 % \ameta{text} appears in the bookmark panel. The \ameta{name} is used for identification purposes.
397 % \begin{macrocode}
398 \newcommand{\currentpdfbookmarkx}[1]{%
399 \@ifnextchar[%]
400 {\currentpdfbookmarkx@i{#1}}
401 {\currentpdfbookmarkx@i{#1}[]}}
402 \def\currentpdfbookmarkx@i#1[#2]#3{%
403 \pdfbookmarkx[\Hy@currentbookmarklevel]{#1}[{#2}]{#3}}
404 % \end{macrocode}
405 % \end{macro}
406 % \begin{macro}{\subpdfbookmarkx}
407 % \hskip-\marginparsep\,\texttt{\darg{\ameta{text}}[\ameta{\ameta{xbmkskeys-kvp}}]\darg{\ameta{name}}}\\
408 % Reduces the current bookmark level by one, then creates
409 % the bookmark at that level. The reduced level is the new current
410 % bookmark level.
411 % \begin{macrocode}
412 \newcommand{\subpdfbookmarkx}[1]{%
413 \@ifnextchar[%]
414 {\subpdfbookmarkx@i{#1}}
415 {\subpdfbookmarkx@i{#1}[]}}
416 \def\subpdfbookmarkx@i#1[#2]#3{%
417 \@tempcnta\Hy@currentbookmarklevel
418 \Hy@StepCount\@tempcnta
419 \expandafter
420 \pdfbookmarkx\expandafter[\the\@tempcnta]{#1}[{#2}]{#3}}
421 % \end{macrocode}
422 % \end{macro}
423 % \begin{macro}{\belowpdfbookmarkx}
424 % \hskip-\marginparsep\,\texttt{\darg{\ameta{text}}[\ameta{xbmkskeys-kvp}]\darg{\ameta{name}}}\\
425 % Creates a bookmark at one level below the current
426 % bookmark level without changing the value of the current bookmark
427 % level.
428 % \begin{macrocode}
429 \newcommand{\belowpdfbookmarkx}[1]{%
430 \@ifnextchar[%]
431 {\belowpdfbookmarkx@i{#1}}
432 {\belowpdfbookmarkx@i{#1}[]}}
433 \def\belowpdfbookmarkx@i#1[#2]#3{%
434 \@tempcnta\Hy@currentbookmarklevel
435 \Hy@StepCount\@tempcnta
436 \expandafter
437 \pdfbookmarkx\expandafter[\the\@tempcnta]{#1}[{#2}]{#3}%
438 \advance\@tempcnta by -1 %
439 \xdef\Hy@currentbookmarklevel{\the\@tempcnta}}
440 % \end{macrocode}
441 % \end{macro}
442 % \begin{macro}{\nextAction@i}
443 % \hskip-\marginparsep\,\texttt{\darg{\ameta{anchor.level}}\darg{\ameta{xbmkskeys-kvp}}}\\
444 % This command is used internally, the document author need not do anything.
445 % The command \cs{nextAction} is \cs{let} to \cs{nextAction@i} just prior to when
446 % the outline file is input; and is \cs{let} to \cs{@gobbletwo}, otherwise.
447 % \begin{macrocode}
448 \def\nextAction@i#1#2{\@ifundefined{X_#1}{%
449 \setkeys{xbmkskeys}{#2}%
450 \xbmkcsarg\xdef{X_#1}{\x@bmks@action}%
451 }{\global\xbmkcsarg\let{X_#1}\relax
452 \PackageWarning{xbmks}
453 {The anchor name `#1' is already defined,\MessageBreak
454 change this name, the bookmark will be created\MessageBreak
455 but it will have no associated action}}}
456 % \end{macrocode}
457 % \end{macro}
458 % \begin{macrocode}
459 \def\x@outWarningMsg{\PackageWarningNoLine{xbmks}{%
460 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\MessageBreak
461 @@ Outline files were not input, compile again @@\MessageBreak
462 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}}%
463 % \end{macrocode}
464 % These commands are implemented in the driver dependent sections.
465 % \begin{macrocode}
466 % End package
467 %</package>
468 %<*pdfmark>
469 % \end{macrocode}
470 % \section{Driver dependent code}
471 % \subsection{The pdfmark driver}
472 % We redefine/modify the \cs{ReadBookmarks} command of \pkg{hyperref},
473 % this definition is driver dependent.
474 % \begin{macrocode}
475 \def\ReadBookmarks{%
476 \pdf@ifdraftmode{}{%
477 \begingroup\def\\{\@backslashchar\@backslashchar}% dps
478 \def\calc@bm@number##1{%
479 \@tempcnta=\check@bm@number{##1}\relax
480 \advance\@tempcnta by 1 %
481 \expandafter\edef\csname B_##1\endcsname{\the\@tempcnta}%
482 }%
483 \def\do##1{%
484 \ifnum\catcode`##1=\active
485 \@makeother##1%
486 \else
487 \ifnum\catcode`##1=6 %
488 \@makeother##1%
489 \fi
490 \fi
491 }%
492 \dospecials
493 \Hy@safe@activestrue
494 \escapechar=`\\%
495 \ifx\WriteBookmarks\relax
496 \global\let\WriteBookmarks\relax
497 \fi
498 \begingroup
499 \def\WriteBookmarks{0}%
500 \count\z@=0\relax
501 \edef\xbmk@J{\jobname}%
502 \@whilenum \count\z@<\xbmk@cnt\relax\do{%
503 \advance\count\z@ by 1 %
504 \edef\xbmk@thisdoc{xbmk@doc\the\count\z@}%
505 \edef\xbmk@filename{\@nameuse{\xbmk@thisdoc}}%
506 \@onelevel@sanitize\xbmk@filename
507 \bgroup
508 \def\@@BOOKMARK[##1][##2]##3##4##5{%
509 \calc@bm@number{##5}%
510 }%
511 \let\nextAction\@gobbletwo
512 \InputIfFileExists{\[email protected]}{}{\x@outWarningMsg}%
513 \def\@@BOOKMARK[##1][##2]##3##4##5{%
514 \def\Hy@temp{##4}%
515 % \end{macrocode}
516 % If `\texttt{X\_\#\#3}' is undefined (\cs{relax}), it is a normal bookmark.
517 % \begin{macrocode}
518 \xbmkcsarg\ifx{X_##3}\relax
519 \ifx\xbmk@J\xbmk@filename
520 \pdfmark{%
521 pdfmark=/OUT,%
522 Count={##2\check@bm@number{##3}},%
523 Raw={\xbmks@intC\xbmk@intF},%
524 Dest={##3},%
525 Title=\expandafter\strip@prefix\meaning\Hy@temp
526 }%
527 \else
528 \pdfmark{%
529 pdfmark=/OUT,%
530 Count={##2\check@bm@number{##3}},%
531 Raw={\xbmks@extC\xbmk@extF},%
532 Action=/GoToR,%
533 File={\[email protected]},%
534 Dest={##3},%
535 Title=\expandafter\strip@prefix\meaning\Hy@temp
536 }%
537 \fi
538 \else
539 % \end{macrocode}
540 % The anchor has an `\texttt{X\_}' definition, it is a bookmark created
541 % from one of the `\texttt{bookmarkx}' commands. We treat this as a separate case.
542 % \begin{macrocode}
543 \x@rollCFIntoActionBmrk{##3}%
544 \pdfmark{%
545 pdfmark=/OUT,%
546 Count={##2\check@bm@number{##3}},%
547 Raw={/Action<<\@nameuse{X_##3}>>\thisCol\thisF},%
548 Title=\expandafter\strip@prefix\meaning\Hy@temp
549 }%
550 \fi
551 }% bookmark
552 \let\nextAction\nextAction@i
553 \InputIfFileExists{\[email protected]}{}{}%
554 \egroup
555 }% \@whilenum
556 \endgroup
557 \endgroup
558 }%
559 \ifx\WriteBookmarks\relax\else
560 \if@filesw
561 \newwrite\@outlinefile
562 \Hy@OutlineRerunCheck
563 \immediate\openout\@outlinefile=\jobname.out\relax
564 \ifHy@typexml
565 \immediate\write\@outlinefile{<relaxxml>\relax}%
566 \fi
567 \fi
568 \fi
569 }
570 %</pdfmark>
571 % \end{macrocode}
572 % \subsection{Code for pdftex/luatex driver}
573 % We redefine/modify the \cs{ReadBookmarks} command of \pkg{hyperref},
574 % this definition is driver dependent.
575 % \begin{macrocode}
576 %<*pdftex>
577 \def\ReadBookmarks{%
578 \pdf@ifdraftmode{}{%
579 \begingroup\def\\{\@backslashchar\@backslashchar}% dps
580 \def\calc@bm@number##1{%
581 \@tempcnta=\check@bm@number{##1}\relax
582 \advance\@tempcnta by 1 %
583 \expandafter\edef\csname B_##1\endcsname{\the\@tempcnta}%
584 }%
585 \def\Hy@OutlineName##1##2##3##4{\def\@rgi{##1}%
586 \expandafter\pdfoutline\ifx\@rgi\@empty\else
587 attr {##1} \fi
588 user {##2} count##3{##4}%
589 % goto name{#2} count#3{#4}%
590 }%
591 \def\do##1{%
592 \ifnum\catcode`##1=\active
593 \@makeother##1%
594 \else
595 \ifnum\catcode`##1=6 %
596 \@makeother##1%
597 \fi
598 \fi
599 }%
600 \dospecials
601 \Hy@safe@activestrue
602 \escapechar=`\\%
603 \ifx\WriteBookmarks\relax
604 \global\let\WriteBookmarks\relax
605 \fi
606 \begingroup
607 \def\WriteBookmarks{0}%
608 \count\z@=0\relax
609 \edef\xbmk@J{\jobname}%
610 \@whilenum \count\z@<\xbmk@cnt\relax\do{%
611 \advance\count\z@ by 1 %
612 \edef\xbmk@thisdoc{xbmk@doc\the\count\z@}%
613 \edef\xbmk@filename{\@nameuse{\xbmk@thisdoc}}%
614 \@onelevel@sanitize\xbmk@filename
615 \bgroup
616 \gdef\@@BOOKMARK[##1][##2]##3##4##5{%
617 \calc@bm@number{##5}%
618 }%
619 \let\nextAction\@gobbletwo
620 \InputIfFileExists{\[email protected]}{}{\x@outWarningMsg}%
621 \gdef\@@BOOKMARK[##1][##2]##3##4##5{%
622 \def\Hy@temp{##4}%
623 \Hy@pstringdef\Hy@pstringName{\HyperDestNameFilter{##3}}%
624 \xbmkcsarg\ifx{X_##3}\relax
625 % \end{macrocode}
626 % Ordinary bookmark
627 % \begin{macrocode}
628 \ifx\xbmk@J\xbmk@filename
629 \Hy@OutlineName{\xbmks@intC\xbmk@intF}{<</S/GoTo%
630 /D(\Hy@pstringName)>>}{%
631 ##2\check@bm@number{\Hy@pstringName}%
632 }{%
633 \expandafter\strip@prefix\meaning\Hy@temp
634 }%
635 \else
636 \Hy@OutlineName{\xbmks@extC\xbmk@extF}{<</S/GoToR%
637 /F(\[email protected])/D(\Hy@pstringName)>>}{%
638 ##2\check@bm@number{##3}%
639 }{%
640 \expandafter\strip@prefix\meaning\Hy@temp
641 }%
642 \fi
643 \else
644 % \end{macrocode}
645 % Bookmark created by one of the `\texttt{...bookmarkx} commands
646 % \begin{macrocode}
647 \x@rollCFIntoActionBmrk{##3}%
648 \Hy@OutlineName{\thisCol\thisF}
649 {<<\@nameuse{X_##3}>>}{%
650 ##2\check@bm@number{\Hy@pstringName}%
651 }{%
652 \expandafter\strip@prefix\meaning\Hy@temp
653 }%
654 \fi
655 }% bookmark
656 \let\nextAction\nextAction@i
657 \InputIfFileExists{\[email protected]}{}{}%
658 \egroup
659 } % \@whilenum
660 \endgroup
661 }%
662 \ifx\WriteBookmarks\relax
663 \else
664 \if@filesw
665 \newwrite\@outlinefile
666 \Hy@OutlineRerunCheck
667 \immediate\openout\@outlinefile=\jobname.out\relax
668 \ifHy@typexml
669 \immediate\write\@outlinefile{<relaxxml>\relax}%
670 \fi
671 \fi
672 \fi
673 }
674 %</pdftex>
675 %<*xetex>
676 % \end{macrocode}
677 % \subsection{Code for xetex driver}
678 % We redefine/modify the \cs{ReadBookmarks} command of \pkg{hyperref},
679 % this definition is driver dependent.
680 % \begin{macrocode}
681 \def\ReadBookmarks{%
682 \pdf@ifdraftmode{}{%
683 \begingroup\def\\{\@backslashchar\@backslashchar}% dps
684 \def\calc@bm@number##1{%
685 \@tempcnta=\check@bm@number{##1}\relax
686 \advance\@tempcnta by 1 %
687 \expandafter\edef\csname B_##1\endcsname{\the\@tempcnta}%
688 }%
689 \def\do##1{%
690 \ifnum\catcode`##1=\active
691 \@makeother##1%
692 \else
693 \ifnum\catcode`##1=6 %
694 \@makeother##1%
695 \fi
696 \fi
697 }%
698 \dospecials
699 \Hy@safe@activestrue
700 \escapechar=`\\%
701 \ifx\WriteBookmarks\relax
702 \global\let\WriteBookmarks\relax
703 \fi
704 \begingroup
705 \def\WriteBookmarks{0}%
706 \count\z@=0\relax
707 \edef\xbmk@J{\jobname}%
708 \@whilenum \count\z@<\xbmk@cnt\relax\do{%
709 \advance\count\z@ by 1 %
710 \edef\xbmk@thisdoc{xbmk@doc\the\count\z@}%
711 \edef\xbmk@filename{\@nameuse{\xbmk@thisdoc}}%
712 \@onelevel@sanitize\xbmk@filename
713 \bgroup
714 \def\@@BOOKMARK[##1][##2]##3##4##5{%
715 \calc@bm@number{##5}%
716 }%
717 \let\nextAction\@gobbletwo
718 \InputIfFileExists{\[email protected]}{}{\x@outWarningMsg}%
719 \def\@@BOOKMARK[##1][##2]##3##4##5{%
720 \def\Hy@temp{##4}%
721 \Hy@pstringdef\Hy@pstringName{\HyperDestNameFilter{##3}}%
722 \x@rollCFIntoActionBmrk{##3}%
723 \@pdfm@mark{%
724 outline \ifHy@DvipdfmxOutlineOpen
725 [\ifnum##21>\z@\else-\fi] \fi
726 ##1<<%
727 /Title(\expandafter\strip@prefix\meaning\Hy@temp)%
728 \xbmkcsarg\ifx{X_##3}\relax
729 % \end{macrocode}
730 % Ordinary bookmark
731 % \begin{macrocode}
732 \ifx\xbmk@J\xbmk@filename
733 /A<<%
734 /S/GoTo%
735 /D(\Hy@pstringName)%
736 >>%
737 \else
738 /A<<%
739 /S/GoToR/F(\[email protected])%
740 /D(\Hy@pstringName)%
741 >>%
742 \fi
743 \else
744 % \end{macrocode}
745 % Bookmark created by one of the \texttt{\string\...bookmarkx} commands
746 % \begin{macrocode}
747 /A<<\@nameuse{X_##3}>>
748 \fi
749 \thisCol\thisF
750 >>%
751 }% \@pdfm@mark
752 \let\thisC\@empty\let\thisF\@empty
753 }% bookmark
754 \let\nextAction\nextAction@i
755 \InputIfFileExists{\[email protected]}{}{}%
756 \egroup
757 }% \@whilenum
758 \endgroup
759 \endgroup
760 }%
761 \ifx\WriteBookmarks\relax
762 \else
763 \if@filesw
764 \newwrite\@outlinefile
765 \Hy@OutlineRerunCheck
766 \immediate\openout\@outlinefile=\jobname.out\relax
767 \ifHy@typexml
768 \immediate\write\@outlinefile{<relaxxml>\relax}%
769 \fi
770 \fi
771 \fi
772 }
773 %</xetex>
774 %<*package>
775 \InputIfFileExists{xbmks.cfg}{}{}
776 \@ifpackageloaded{bookmark}{\PackageWarningNoLine{xbmks}{The
777 bookmark package is not supported;\MessageBreak
778 this package does nothing, as a result}}
779 {\InputIfFileExists{\xbmk@driver}{}{}}
780 %</package>
781 % \end{macrocode}
782 % \Finale