Debian Codegraph @

texmf-dist/source/latex/oberdiek/hypgotoe.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: hypgotoe.dtx
4 % Version: 2019/12/29 v0.3
5 % Info: Links to embedded files
6 %
7 % Copyright (C)
8 % 2007 Heiko Oberdiek
9 % 2016-2019 Oberdiek Package Support Group
10 % https://github.com/ho-tex/oberdiek/issues
11 %
12 % This work may be distributed and/or modified under the
13 % conditions of the LaTeX Project Public License, either
14 % version 1.3c of this license or (at your option) any later
15 % version. This version of this license is in
16 % https://www.latex-project.org/lppl/lppl-1-3c.txt
17 % and the latest version of this license is in
18 % https://www.latex-project.org/lppl.txt
19 % and version 1.3 or later is part of all distributions of
20 % LaTeX version 2005/12/01 or later.
21 %
22 % This work has the LPPL maintenance status "maintained".
23 %
24 % The Current Maintainers of this work are
25 % Heiko Oberdiek and the Oberdiek Package Support Group
26 % https://github.com/ho-tex/oberdiek/issues
27 %
28 % This work consists of the main source file hypgotoe.dtx
29 % and the derived files
30 % hypgotoe.sty, hypgotoe.pdf, hypgotoe.ins, hypgotoe.drv,
31 % hypgotoe-example.tex.
32 %
33 % Distribution:
34 % CTAN:macros/latex/contrib/oberdiek/hypgotoe.dtx
35 % CTAN:macros/latex/contrib/oberdiek/hypgotoe.pdf
36 %
37 % Unpacking:
38 % (a) If hypgotoe.ins is present:
39 % tex hypgotoe.ins
40 % (b) Without hypgotoe.ins:
41 % tex hypgotoe.dtx
42 % (c) If you insist on using LaTeX
43 % latex \let\install=y\input{hypgotoe.dtx}
44 % (quote the arguments according to the demands of your shell)
45 %
46 % Documentation:
47 % (a) If hypgotoe.drv is present:
48 % latex hypgotoe.drv
49 % (b) Without hypgotoe.drv:
50 % latex hypgotoe.dtx; ...
51 % The class ltxdoc loads the configuration file ltxdoc.cfg
52 % if available. Here you can specify further options, e.g.
53 % use A4 as paper format:
54 % \PassOptionsToClass{a4paper}{article}
55 %
56 % Program calls to get the documentation (example):
57 % pdflatex hypgotoe.dtx
58 % makeindex -s gind.ist hypgotoe.idx
59 % pdflatex hypgotoe.dtx
60 % makeindex -s gind.ist hypgotoe.idx
61 % pdflatex hypgotoe.dtx
62 %
63 % Installation:
64 % TDS:tex/latex/oberdiek/hypgotoe.sty
65 % TDS:doc/latex/oberdiek/hypgotoe.pdf
66 % TDS:doc/latex/oberdiek/hypgotoe-example.tex
67 % TDS:source/latex/oberdiek/hypgotoe.dtx
68 %
69 %<*ignore>
70 \begingroup
71 \catcode123=1 %
72 \catcode125=2 %
73 \def\x{LaTeX2e}%
74 \expandafter\endgroup
75 \ifcase 0\ifx\install y1\fi\expandafter
76 \ifx\csname processbatchFile\endcsname\relax\else1\fi
77 \ifx\fmtname\x\else 1\fi\relax
78 \else\csname fi\endcsname
79 %</ignore>
80 %<*install>
81 \input docstrip.tex
82 \Msg{************************************************************************}
83 \Msg{* Installation}
84 \Msg{* Package: hypgotoe 2019/12/29 v0.3 Links to embedded files (HO)}
85 \Msg{************************************************************************}
86
87 \keepsilent
88 \askforoverwritefalse
89
90 \let\MetaPrefix\relax
91 \preamble
92
93 This is a generated file.
94
95 Project: hypgotoe
96 Version: 2019/12/29 v0.3
97
98 Copyright (C)
99 2007 Heiko Oberdiek
100 2016-2019 Oberdiek Package Support Group
101
102 This work may be distributed and/or modified under the
103 conditions of the LaTeX Project Public License, either
104 version 1.3c of this license or (at your option) any later
105 version. This version of this license is in
106 https://www.latex-project.org/lppl/lppl-1-3c.txt
107 and the latest version of this license is in
108 https://www.latex-project.org/lppl.txt
109 and version 1.3 or later is part of all distributions of
110 LaTeX version 2005/12/01 or later.
111
112 This work has the LPPL maintenance status "maintained".
113
114 The Current Maintainers of this work are
115 Heiko Oberdiek and the Oberdiek Package Support Group
116 https://github.com/ho-tex/oberdiek/issues
117
118
119 This work consists of the main source file hypgotoe.dtx
120 and the derived files
121 hypgotoe.sty, hypgotoe.pdf, hypgotoe.ins, hypgotoe.drv,
122 hypgotoe-example.tex.
123
124 \endpreamble
125 \let\MetaPrefix\DoubleperCent
126
127 \generate{%
128 \file{hypgotoe.ins}{\from{hypgotoe.dtx}{install}}%
129 \file{hypgotoe.drv}{\from{hypgotoe.dtx}{driver}}%
130 \usedir{tex/latex/oberdiek}%
131 \file{hypgotoe.sty}{\from{hypgotoe.dtx}{package}}%
132 \usedir{doc/latex/oberdiek}%
133 \file{hypgotoe-example.tex}{\from{hypgotoe.dtx}{example}}%
134 }
135
136 \catcode32=13\relax% active space
137 \let =\space%
138 \Msg{************************************************************************}
139 \Msg{*}
140 \Msg{* To finish the installation you have to move the following}
141 \Msg{* file into a directory searched by TeX:}
142 \Msg{*}
143 \Msg{* hypgotoe.sty}
144 \Msg{*}
145 \Msg{* To produce the documentation run the file `hypgotoe.drv'}
146 \Msg{* through LaTeX.}
147 \Msg{*}
148 \Msg{* Happy TeXing!}
149 \Msg{*}
150 \Msg{************************************************************************}
151
152 \endbatchfile
153 %</install>
154 %<*ignore>
155 \fi
156 %</ignore>
157 %<*driver>
158 \NeedsTeXFormat{LaTeX2e}
159 \ProvidesFile{hypgotoe.drv}%
160 [2019/12/29 v0.3 Links to embedded files (HO)]%
161 \documentclass{ltxdoc}
162 \usepackage{holtxdoc}[2011/11/22]
163 \begin{document}
164 \DocInput{hypgotoe.dtx}%
165 \end{document}
166 %</driver>
167 % \fi
168 %
169 %
170 %
171 % \GetFileInfo{hypgotoe.drv}
172 %
173 % \title{The \xpackage{hypgotoe} package}
174 % \date{2019/12/29 v0.3}
175 % \author{Heiko Oberdiek\thanks
176 % {Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}}
177 %
178 % \maketitle
179 %
180 % \begin{abstract}
181 % Experimental package for links to embedded files.
182 % \end{abstract}
183 %
184 % \tableofcontents
185 %
186 % \section{Documentation}
187 %
188 % \subsection{Introduction}
189 %
190 % This is a first experiment for links to embedded files.
191 % The package \xpackage{hypgotoe} is named after the PDF action
192 % name \texttt{/GoToE}.
193 % Feedback is welcome, especially to the user interface.
194 % \begin{itemize}
195 % \item
196 % Currently only embedded files and named destinations are supported.
197 % \item
198 % Missing are support for destination arrays and attached files.
199 % \item
200 % Special characters aren't supported either.
201 % \end{itemize}
202 % In the future the package may be merged into package \xpackage{hyperref}.
203 %
204 % \subsection{User interface}
205 %
206 % \cs{href} is extended to detect the prefix `\texttt{gotoe:}'.
207 % The part after the prefix is evaluated as key value list
208 % from left to right.
209 % For details, see ``8.5.3 Action Types, Embedded Go-To Actions''
210 % \cite{pdfspec}.
211 % \begin{description}
212 % \item[\xoption{dest}:] The destination name. The destination name
213 % can be set by \cs{hypertarget} in the target document. Or check
214 % the \xfile{.aux} file for destination names of \cs{label} commands.
215 % Also the target PDF file can be inspected, look for \texttt{/Dests}
216 % in the /Names entry of the catalog for named destinations. (Required.)
217 % \item[\xoption{root}:] The file name of the root document.
218 % (Optional.)
219 % \item[\xoption{parent}:] Go to the parent document. (No value, optional.)
220 % \item[\xoption{embedded}:] Go to the embedded document. The
221 % value is the file name as it appears in /EmbeddedFiles of the current
222 % document.
223 % \end{description}
224 %
225 % The colors are controlled by \xpackage{hyperref}'s options
226 % \xoption{gotoecolor} and \xoption{gotoebordercolor}. They can
227 % be set in \cs{hypersetup}, for example.
228 % Default is the color of file links.
229 %
230 % \subsection{Example}
231 %
232 % \begin{macrocode}
233 %<*example>
234 \NeedsTeXFormat{LaTeX2e}
235 \begin{filecontents}{hypgotoe-child.tex}
236 \NeedsTeXFormat{LaTeX2e}
237 \documentclass{article}
238 \usepackage{hypgotoe}[2019/12/29]
239 \begin{document}
240 \section{This is the child document.}
241 \href{gotoe:%
242 dest={page.1},parent%
243 }{Go to first page of main document}\\
244 \href{gotoe:%
245 dest={page.2},parent%
246 }{Go to second page of main document}
247 \newpage
248 \section{This is the second page of the child document.}
249 \href{gotoe:%
250 dest={page.1},parent%
251 }{Go to first page of main document}\\
252 \href{gotoe:%
253 dest={page.2},parent%
254 }{Go to second page of main document}
255
256 \hypertarget{foobar}{}
257 Anchor foobar is here.
258 \end{document}
259 \end{filecontents}
260 \documentclass{article}
261 \usepackage{hypgotoe}[2019/12/29]
262 \usepackage{embedfile}
263 \IfFileExists{hypgotoe-child.pdf}{%
264 \embedfile{hypgotoe-child.pdf}%
265 }{%
266 \typeout{}%
267 \typeout{--> Run hypgotoe-child.tex through pdflatex}%
268 \typeout{}%
269 }
270 \begin{document}
271 \section{First page of main document}
272 \href{gotoe:%
273 dest=page.1,embedded=hypgotoe-child.pdf%
274 }{Go to first page of child document}\\
275 \href{gotoe:%
276 dest=page.2,embedded=hypgotoe-child.pdf%
277 }{Go to second page of child document}\\
278 \href{gotoe:%
279 dest=foobar,embedded=hypgotoe-child.pdf%
280 }{Go to foobar in child document}
281 \newpage
282 \section{Second page of main document}
283 \href{gotoe:%
284 dest=section.1,embedded=hypgotoe-child.pdf%
285 }{Go to first section of child document}\\
286 \href{gotoe:%
287 dest=section.2,embedded=hypgotoe-child.pdf%
288 }{Go to second section of child document}\\
289 \href{gotoe:%
290 dest=foobar,embedded=hypgotoe-child.pdf%
291 }{Go to foobar in child document}
292 \end{document}
293 %</example>
294 % \end{macrocode}
295 %
296 % \StopEventually{
297 % }
298 %
299 % \section{Implementation}
300 %
301 % \subsection{Identification}
302 %
303 % \begin{macrocode}
304 %<*package>
305 \NeedsTeXFormat{LaTeX2e}
306 \ProvidesPackage{hypgotoe}%
307 [2019/12/29 v0.3 Links to embedded files (HO)]%
308 % \end{macrocode}
309 %
310 % \subsection{Load packages}
311 %
312 % \begin{macrocode}
313 \RequirePackage{iftex}[2019/11/07]
314 \ifpdf
315 \else
316 \PackageError{hypgotoe}{%
317 Other drivers than pdfTeX in PDF mode are not supported.%
318 \MessageBreak
319 Package loading is aborted%
320 }\@ehc
321 \expandafter\endinput
322 \fi
323 \RequirePackage{pdfescape}[2007/10/27]
324 \RequirePackage{hyperref}[2019/12/29]
325 % \end{macrocode}
326 %
327 % \subsection{Color support}
328 %
329 % \begin{macrocode}
330 \define@key{Hyp}{gotoebordercolor}{%
331 \HyColor@HyperrefBordercolor{#1}%
332 \@gotoebordercolor{hyperref}{gotoebordercolor}%
333 }
334 \providecommand*{\@gotoecolor}{\@filecolor}
335 \providecommand*{\@gotoebordercolor}{\@filebordercolor}
336 % \end{macrocode}
337 %
338 % \subsection{Extend \cs{href}}
339 %
340 % \begin{macro}{\@hyper@readexternallink}
341 % \begin{macrocode}
342 \def\@hyper@readexternallink#1#2#3#4:#5:#6\\#7{%
343 \ifx\\#6\\%
344 \expandafter\@hyper@linkfile file:#7\\{#3}{#2}%
345 \else
346 \ifx\\#4\\%
347 \expandafter\@hyper@linkfile file:#7\\{#3}{#2}%
348 \else
349 \def\@pdftempa{#4}%
350 \ifx\@pdftempa\@pdftempwordfile
351 \expandafter\@hyper@linkfile#7\\{#3}{#2}%
352 \else
353 \ifx\@pdftempa\@pdftempwordrun
354 \expandafter\@hyper@launch#7\\{#3}{#2}%
355 \else
356 \ifx\@pdftempa\@pdftempwordgotoe
357 \hyper@linkgotoe{#3}{#5}%
358 \else
359 \hyper@linkurl{#3}{#7\ifx\\#2\\\else\hyper@hash#2\fi}%
360 \fi
361 \fi
362 \fi
363 \fi
364 \fi
365 }
366 % \end{macrocode}
367 % \end{macro}
368 % \begin{macro}{\@pdftempwordgotoe}
369 % \begin{macrocode}
370 \def\@pdftempwordgotoe{gotoe}
371 % \end{macrocode}
372 % \end{macro}
373 %
374 % \subsection{Implement gotoe action}
375 %
376 % \begin{macro}{\hyper@linkgotoe}
377 % \begin{macrocode}
378 \def\hyper@linkgotoe#1#2{%
379 \begingroup
380 \let\HyGoToE@Root\@empty
381 \let\HyGoToE@Dest\@empty
382 \let\HyGoToE@TBegin\@empty
383 \let\HyGoToE@TEnd\@empty
384 \setkeys{HyGoToE}{#2}%
385 \leavevmode
386 \pdfstartlink
387 attr{%
388 \Hy@setpdfborder
389 \ifx\@pdfhightlight\@empty
390 \else
391 /H\@pdfhighlight
392 \fi
393 \ifx\@urlbordercolor\relax
394 \else
395 /C[\@urlbordercolor]%
396 \fi
397 }%
398 user{%
399 /Subtype/Link%
400 /A<<%
401 /Type/Action%
402 /S/GoToE%
403 \Hy@SetNewWindow
404 \HyGoToE@Root
405 \HyGoToE@Dest
406 \HyGoToE@TBegin
407 \HyGoToE@TEnd
408 >>%
409 }%
410 \relax
411 \Hy@colorlink\@gotoecolor#1%
412 \close@pdflink
413 \endgroup
414 }
415 % \end{macrocode}
416 % \end{macro}
417 %
418 % \subsection{Keys for gotoe action}
419 %
420 % \begin{macrocode}
421 \define@key{HyGoToE}{root}{%
422 \EdefEscapeString\HyGoToE@temp{#1}%
423 \edef\HyGoToE@Root{%
424 /F<<%
425 /Type/Filespec%
426 /F(\HyGoToE@temp)%
427 >>%
428 }%
429 }
430 \define@key{HyGoToE}{dest}{%
431 \EdefEscapeString\HyGoToE@temp{#1}%
432 \edef\HyGoToE@Dest{%
433 /D(\HyGoToE@temp)%
434 }%
435 }
436 \define@key{HyGoToE}{parent}[]{%
437 \def\HyGoToE@temp{#1}%
438 \ifx\HyGoToE@temp\@empty
439 \else
440 \PackageWarning{hypgotoe}{Ignore value for `parent'}%
441 \fi
442 \edef\HyGoToE@TBegin{%
443 \HyGoToE@TBegin
444 /T<<%
445 /R/P%
446 }%
447 \edef\HyGoToE@TEnd{%
448 \HyGoToE@TEnd
449 >>%
450 }%
451 }
452 \define@key{HyGoToE}{embedded}{%
453 \EdefEscapeString\HyGoToE@temp{#1}%
454 \edef\HyGoToE@TBegin{%
455 \HyGoToE@TBegin
456 /T<<%
457 /R/C%
458 /N(\HyGoToE@temp)%
459 }%
460 \edef\HyGoToE@TEnd{%
461 \HyGoToE@TEnd
462 >>%
463 }%
464 }
465 % \end{macrocode}
466 %
467 % \begin{macrocode}
468 %</package>
469 % \end{macrocode}
470 %
471 % \section{Installation}
472 %
473 % \subsection{Download}
474 %
475 % \paragraph{Package.} This package is available on
476 % CTAN\footnote{\CTANpkg{hypgotoe}}:
477 % \begin{description}
478 % \item[\CTAN{macros/latex/contrib/oberdiek/hypgotoe.dtx}] The source file.
479 % \item[\CTAN{macros/latex/contrib/oberdiek/hypgotoe.pdf}] Documentation.
480 % \end{description}
481 %
482 %
483 % \paragraph{Bundle.} All the packages of the bundle `oberdiek'
484 % are also available in a TDS compliant ZIP archive. There
485 % the packages are already unpacked and the documentation files
486 % are generated. The files and directories obey the TDS standard.
487 % \begin{description}
488 % \item[\CTANinstall{install/macros/latex/contrib/oberdiek.tds.zip}]
489 % \end{description}
490 % \emph{TDS} refers to the standard ``A Directory Structure
491 % for \TeX\ Files'' (\CTANpkg{tds}). Directories
492 % with \xfile{texmf} in their name are usually organized this way.
493 %
494 % \subsection{Bundle installation}
495 %
496 % \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the
497 % TDS tree (also known as \xfile{texmf} tree) of your choice.
498 % Example (linux):
499 % \begin{quote}
500 % |unzip oberdiek.tds.zip -d ~/texmf|
501 % \end{quote}
502 %
503 % \subsection{Package installation}
504 %
505 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
506 % \docstrip\ archive. The files are extracted by running the
507 % \xfile{.dtx} through \plainTeX:
508 % \begin{quote}
509 % \verb|tex hypgotoe.dtx|
510 % \end{quote}
511 %
512 % \paragraph{TDS.} Now the different files must be moved into
513 % the different directories in your installation TDS tree
514 % (also known as \xfile{texmf} tree):
515 % \begin{quote}
516 % \def\t{^^A
517 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
518 % hypgotoe.sty & tex/latex/oberdiek/hypgotoe.sty\\
519 % hypgotoe.pdf & doc/latex/oberdiek/hypgotoe.pdf\\
520 % hypgotoe-example.tex & doc/latex/oberdiek/hypgotoe-example.tex\\
521 % hypgotoe.dtx & source/latex/oberdiek/hypgotoe.dtx\\
522 % \end{tabular}^^A
523 % }^^A
524 % \sbox0{\t}^^A
525 % \ifdim\wd0>\linewidth
526 % \begingroup
527 % \advance\linewidth by\leftmargin
528 % \advance\linewidth by\rightmargin
529 % \edef\x{\endgroup
530 % \def\noexpand\lw{\the\linewidth}^^A
531 % }\x
532 % \def\lwbox{^^A
533 % \leavevmode
534 % \hbox to \linewidth{^^A
535 % \kern-\leftmargin\relax
536 % \hss
537 % \usebox0
538 % \hss
539 % \kern-\rightmargin\relax
540 % }^^A
541 % }^^A
542 % \ifdim\wd0>\lw
543 % \sbox0{\small\t}^^A
544 % \ifdim\wd0>\linewidth
545 % \ifdim\wd0>\lw
546 % \sbox0{\footnotesize\t}^^A
547 % \ifdim\wd0>\linewidth
548 % \ifdim\wd0>\lw
549 % \sbox0{\scriptsize\t}^^A
550 % \ifdim\wd0>\linewidth
551 % \ifdim\wd0>\lw
552 % \sbox0{\tiny\t}^^A
553 % \ifdim\wd0>\linewidth
554 % \lwbox
555 % \else
556 % \usebox0
557 % \fi
558 % \else
559 % \lwbox
560 % \fi
561 % \else
562 % \usebox0
563 % \fi
564 % \else
565 % \lwbox
566 % \fi
567 % \else
568 % \usebox0
569 % \fi
570 % \else
571 % \lwbox
572 % \fi
573 % \else
574 % \usebox0
575 % \fi
576 % \else
577 % \lwbox
578 % \fi
579 % \else
580 % \usebox0
581 % \fi
582 % \end{quote}
583 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
584 % TDS installing feature, then some files can already be in the right
585 % place, see the documentation of \docstrip.
586 %
587 % \subsection{Refresh file name databases}
588 %
589 % If your \TeX~distribution
590 % (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
591 % these. For example, \TeX\,Live\ users run \verb|texhash| or
592 % \verb|mktexlsr|.
593 %
594 % \subsection{Some details for the interested}
595 %
596 % \paragraph{Unpacking with \LaTeX.}
597 % The \xfile{.dtx} chooses its action depending on the format:
598 % \begin{description}
599 % \item[\plainTeX:] Run \docstrip\ and extract the files.
600 % \item[\LaTeX:] Generate the documentation.
601 % \end{description}
602 % If you insist on using \LaTeX\ for \docstrip\ (really,
603 % \docstrip\ does not need \LaTeX), then inform the autodetect routine
604 % about your intention:
605 % \begin{quote}
606 % \verb|latex \let\install=y\input{hypgotoe.dtx}|
607 % \end{quote}
608 % Do not forget to quote the argument according to the demands
609 % of your shell.
610 %
611 % \paragraph{Generating the documentation.}
612 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
613 % the documentation. The process can be configured by the
614 % configuration file \xfile{ltxdoc.cfg}. For instance, put this
615 % line into this file, if you want to have A4 as paper format:
616 % \begin{quote}
617 % \verb|\PassOptionsToClass{a4paper}{article}|
618 % \end{quote}
619 % An example follows how to generate the
620 % documentation with pdf\LaTeX:
621 % \begin{quote}
622 %\begin{verbatim}
623 %pdflatex hypgotoe.dtx
624 %makeindex -s gind.ist hypgotoe.idx
625 %pdflatex hypgotoe.dtx
626 %makeindex -s gind.ist hypgotoe.idx
627 %pdflatex hypgotoe.dtx
628 %\end{verbatim}
629 % \end{quote}
630 %
631 % \begin{thebibliography}{9}
632 % \bibitem{pdfspec}
633 % Adobe Systems Incorporated:
634 % \href{http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference.pdf}%
635 % {\textit{PDF Reference, Sixth Edition, Version 1.7}},%
636 % Oktober 2006;
637 % \url{http://www.adobe.com/devnet/pdf/pdf_reference.html}.
638 %
639 % \end{thebibliography}
640 %
641 % \begin{History}
642 % \begin{Version}{2007/10/30 v0.1}
643 % \item
644 % First experimental version.
645 % \end{Version}
646 % \begin{Version}{2016/05/16 v0.2}
647 % \item
648 % Documentation updates.
649 % \end{Version}
650 % \begin{Version}{2019/12/29 v0.3}
651 % \item
652 % \xpackage{iftex} package
653 % \end{Version}
654 % \end{History}
655 %
656 % \PrintIndex
657 %
658 % \Finale
659 \endinput