| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: hypdestopt.dtx |
| 4 |
% Version: 2025-06-23 v2.9 |
| 5 |
% Info: Hyperref destination optimizer |
| 6 |
% |
| 7 |
% Copyright (C) |
| 8 |
% 2006-2008, 2011 Heiko Oberdiek |
| 9 |
% 2016-2025 Oberdiek Package Support Group |
| 10 |
% https://github.com/ho-tex/hypdestopt/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/hypdestopt/issues |
| 27 |
% |
| 28 |
% This work consists of the main source file hypdestopt.dtx |
| 29 |
% and the derived files |
| 30 |
% hypdestopt.sty, hypdestopt.pdf, hypdestopt.ins, hypdestopt.drv. |
| 31 |
% |
| 32 |
% Distribution: |
| 33 |
% CTAN:macros/latex/contrib/hypdestopt/hypdestopt.dtx |
| 34 |
% CTAN:macros/latex/contrib/hypdestopt/hypdestopt.pdf |
| 35 |
% |
| 36 |
% Unpacking: |
| 37 |
% (a) If hypdestopt.ins is present: |
| 38 |
% tex hypdestopt.ins |
| 39 |
% (b) Without hypdestopt.ins: |
| 40 |
% tex hypdestopt.dtx |
| 41 |
% (c) If you insist on using LaTeX |
| 42 |
% latex \let\install=y\input{hypdestopt.dtx} |
| 43 |
% (quote the arguments according to the demands of your shell) |
| 44 |
% |
| 45 |
% Documentation: |
| 46 |
% (a) If hypdestopt.drv is present: |
| 47 |
% latex hypdestopt.drv |
| 48 |
% (b) Without hypdestopt.drv: |
| 49 |
% latex hypdestopt.dtx; ... |
| 50 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 51 |
% if available. Here you can specify further options, e.g. |
| 52 |
% use A4 as paper format: |
| 53 |
% \PassOptionsToClass{a4paper}{article} |
| 54 |
% |
| 55 |
% Programm calls to get the documentation (example): |
| 56 |
% pdflatex hypdestopt.dtx |
| 57 |
% makeindex -s gind.ist hypdestopt.idx |
| 58 |
% pdflatex hypdestopt.dtx |
| 59 |
% makeindex -s gind.ist hypdestopt.idx |
| 60 |
% pdflatex hypdestopt.dtx |
| 61 |
% |
| 62 |
% Installation: |
| 63 |
% TDS:tex/latex/hypdestopt/hypdestopt.sty |
| 64 |
% TDS:doc/latex/hypdestopt/hypdestopt.pdf |
| 65 |
% TDS:source/latex/hypdestopt/hypdestopt.dtx |
| 66 |
% |
| 67 |
%<*ignore> |
| 68 |
\begingroup |
| 69 |
\catcode123=1 % |
| 70 |
\catcode125=2 % |
| 71 |
\def\x{LaTeX2e}% |
| 72 |
\expandafter\endgroup |
| 73 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 74 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 75 |
\ifx\fmtname\x\else 1\fi\relax |
| 76 |
\else\csname fi\endcsname |
| 77 |
%</ignore> |
| 78 |
%<*install> |
| 79 |
\input docstrip.tex |
| 80 |
\Msg{************************************************************************} |
| 81 |
\Msg{* Installation} |
| 82 |
\Msg{* Package: hypdestopt 2025-06-23 v2.9 Hyperref destination optimizer (HO)} |
| 83 |
\Msg{************************************************************************} |
| 84 |
|
| 85 |
\keepsilent |
| 86 |
\askforoverwritefalse |
| 87 |
|
| 88 |
\let\MetaPrefix\relax |
| 89 |
\preamble |
| 90 |
|
| 91 |
This is a generated file. |
| 92 |
|
| 93 |
Project: hypdestopt |
| 94 |
Version: 2025-06-23 v2.9 |
| 95 |
|
| 96 |
Copyright (C) |
| 97 |
2006-2008, 2011 Heiko Oberdiek |
| 98 |
2016-2025 Oberdiek Package Support Group |
| 99 |
|
| 100 |
This work may be distributed and/or modified under the |
| 101 |
conditions of the LaTeX Project Public License, either |
| 102 |
version 1.3c of this license or (at your option) any later |
| 103 |
version. This version of this license is in |
| 104 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 105 |
and the latest version of this license is in |
| 106 |
https://www.latex-project.org/lppl.txt |
| 107 |
and version 1.3 or later is part of all distributions of |
| 108 |
LaTeX version 2005/12/01 or later. |
| 109 |
|
| 110 |
This work has the LPPL maintenance status "maintained". |
| 111 |
|
| 112 |
The Current Maintainers of this work are |
| 113 |
Heiko Oberdiek and the Oberdiek Package Support Group |
| 114 |
https://github.com/ho-tex/hypdestopt/issues |
| 115 |
|
| 116 |
|
| 117 |
This work consists of the main source file hypdestopt.dtx |
| 118 |
and the derived files |
| 119 |
hypdestopt.sty, hypdestopt.pdf, hypdestopt.ins, hypdestopt.drv. |
| 120 |
|
| 121 |
\endpreamble |
| 122 |
\let\MetaPrefix\DoubleperCent |
| 123 |
|
| 124 |
\generate{% |
| 125 |
\file{hypdestopt.ins}{\from{hypdestopt.dtx}{install}}% |
| 126 |
\file{hypdestopt.drv}{\from{hypdestopt.dtx}{driver}}% |
| 127 |
\usedir{tex/latex/oberdiek}% |
| 128 |
\file{hypdestopt.sty}{\from{hypdestopt.dtx}{package}}% |
| 129 |
} |
| 130 |
|
| 131 |
\catcode32=13\relax% active space |
| 132 |
\let =\space% |
| 133 |
\Msg{************************************************************************} |
| 134 |
\Msg{*} |
| 135 |
\Msg{* To finish the installation you have to move the following} |
| 136 |
\Msg{* file into a directory searched by TeX:} |
| 137 |
\Msg{*} |
| 138 |
\Msg{* hypdestopt.sty} |
| 139 |
\Msg{*} |
| 140 |
\Msg{* To produce the documentation run the file `hypdestopt.drv'} |
| 141 |
\Msg{* through LaTeX.} |
| 142 |
\Msg{*} |
| 143 |
\Msg{* Happy TeXing!} |
| 144 |
\Msg{*} |
| 145 |
\Msg{************************************************************************} |
| 146 |
|
| 147 |
\endbatchfile |
| 148 |
%</install> |
| 149 |
%<*ignore> |
| 150 |
\fi |
| 151 |
%</ignore> |
| 152 |
%<*driver> |
| 153 |
\NeedsTeXFormat{LaTeX2e} |
| 154 |
\ProvidesFile{hypdestopt.drv}% |
| 155 |
[2025-06-23 v2.9 Hyperref destination optimizer (HO)]% |
| 156 |
\documentclass{ltxdoc} |
| 157 |
\usepackage{holtxdoc}[2011/11/22] |
| 158 |
\begin{document} |
| 159 |
\DocInput{hypdestopt.dtx}% |
| 160 |
\end{document} |
| 161 |
%</driver> |
| 162 |
% \fi |
| 163 |
% |
| 164 |
% |
| 165 |
% |
| 166 |
% \GetFileInfo{hypdestopt.drv} |
| 167 |
% |
| 168 |
% \title{The \xpackage{hypdestopt} package} |
| 169 |
% \date{2025-06-23 v2.9} |
| 170 |
% \author{Heiko Oberdiek\thanks |
| 171 |
% {Please report any issues at \url{https://github.com/ho-tex/hypdestopt/issues}}} |
| 172 |
% |
| 173 |
% \maketitle |
| 174 |
% |
| 175 |
% \begin{abstract} |
| 176 |
% Package \xpackage{hypdestopt} supports \xpackage{hyperref}'s |
| 177 |
% \xoption{pdftex} and \xoption{luatex} driver. It removes unnecessary destinations |
| 178 |
% and shortens the destination names or uses numbered destinations |
| 179 |
% to get smaller PDF files. |
| 180 |
% |
| 181 |
% The package is not compatible with the \LaTeX{} PDFmanagement loaded with |
| 182 |
% \cs{DocumentMetadata} and will do nothing if it detects it. |
| 183 |
% \end{abstract} |
| 184 |
% |
| 185 |
% \tableofcontents |
| 186 |
% |
| 187 |
% \section{User interface} |
| 188 |
% |
| 189 |
% \subsection{Introduction} |
| 190 |
% |
| 191 |
% Before PDF-1.5 annotations and destinations cannot be compressed. |
| 192 |
% If the destination names are not needed for external use, the |
| 193 |
% file size can be decreased by the following means: |
| 194 |
% \begin{itemize} |
| 195 |
% \item Unused destinations are removed. |
| 196 |
% \item The destination names are shortened (option \xoption{name}). |
| 197 |
% \item Using numbered destinations (option \xoption{num}). |
| 198 |
% \end{itemize} |
| 199 |
% |
| 200 |
% \subsection{Requirements} |
| 201 |
% |
| 202 |
% \begin{itemize} |
| 203 |
% \item Package \xpackage{hyperref} 2006/06/01 v6.75a or newer |
| 204 |
% (\cite{hyperref}). |
| 205 |
% \item Package \xpackage{alphalph} 2006/05/30 v1.4 or newer |
| 206 |
% (\cite{alphalph}), if option \xoption{name} is used. |
| 207 |
% \item Package \xpackage{iftex}. |
| 208 |
% \item \pdfTeX\ 1.30.0 or newer. |
| 209 |
% \item \pdfTeX\ or lua\TeX\ in PDF mode. |
| 210 |
% \item \eTeX\ extensions enabled. |
| 211 |
% \item Probably an additional compile run of \pdfLaTeX\ or lua\LaTeX\ is necessary. |
| 212 |
% \end{itemize} |
| 213 |
% |
| 214 |
% In the first compile runs you can get warnings such as: |
| 215 |
%\begin{quote} |
| 216 |
%\begin{verbatim} |
| 217 |
%! pdfTeX warning (dest): name{...} has been referenced ... |
| 218 |
%\end{verbatim} |
| 219 |
%\end{quote} |
| 220 |
% These warnings should vanish in later compile runs. |
| 221 |
% However these warnings also can occur without this package. |
| 222 |
% The package does not cure them, thus these warnings will remain, |
| 223 |
% but the destination name can be different. In such cases test |
| 224 |
% without the package, too. |
| 225 |
% |
| 226 |
% \subsection{Use} |
| 227 |
% |
| 228 |
% If the requirements are met, load the package: |
| 229 |
%\begin{quote} |
| 230 |
%\verb|\usepackage{hypdestopt}| |
| 231 |
%\end{quote} |
| 232 |
% |
| 233 |
% The following options are supported: |
| 234 |
% \begin{description} |
| 235 |
% \item[\xoption{verbose}:] Verbose debug output is enabled and written |
| 236 |
% in the protocol file. |
| 237 |
% \item[\xoption{num}:] Numbered destinations are used. The file size |
| 238 |
% is smaller, because names are no longer used. |
| 239 |
% This is the default. |
| 240 |
% \item[\xoption{name}:] Destinations are identified by names. |
| 241 |
% \end{description} |
| 242 |
% |
| 243 |
% \subsection{Limitations} |
| 244 |
% |
| 245 |
% \begin{itemize} |
| 246 |
% \item Forget this package, if you need preserved destination names. |
| 247 |
% \item Destination name strings use all bytes (0..255) except |
| 248 |
% the carriage return (13), left parenthesis (40), right |
| 249 |
% parenthesis (41), and backslash (92), because they |
| 250 |
% must be quoted in general and therefore occupy two bytes |
| 251 |
% instead of one. |
| 252 |
% |
| 253 |
% Further the zero byte (0) is avoided for programs |
| 254 |
% that implement strings using zero terminated C strings. |
| 255 |
% And 255 (0xFF) is avoided to get rid of a possible |
| 256 |
% unicode marker at the begin. |
| 257 |
% |
| 258 |
% So far I have not seen problems with: |
| 259 |
% \begin{itemize} |
| 260 |
% \item AcrobatReader 5.08/Linux |
| 261 |
% \item AcrobatReader 7.0/Linux |
| 262 |
% \item xpdf 3.00 |
| 263 |
% \item Ghostscript 8.50 |
| 264 |
% \item gv 3.5.8 |
| 265 |
% \item GSview 4.6 |
| 266 |
% \end{itemize} |
| 267 |
% But I have not tested all and all possible PDF viewers. |
| 268 |
% \item Use of named destinations (\cs{pdfdest}, \cs{pdfoutline}, |
| 269 |
% \cs{pdfstartlink}, \dots) that are not supported by this |
| 270 |
% package. |
| 271 |
% \item Currently only \xpackage{hyperref} with \pdfTeX\ and lua\TeX\ in PDF |
| 272 |
% mode is supported. |
| 273 |
% \end{itemize} |
| 274 |
% |
| 275 |
% \subsection{Future} |
| 276 |
% |
| 277 |
% A more general approach is a PDF postprocessor that takes |
| 278 |
% a PDF file, performs some transformations and writes the |
| 279 |
% result in a more optimized PDF file. Then it does not depend, |
| 280 |
% how the original PDF file was generated and further improvements |
| 281 |
% are easier to apply. For example, the destination names could be sorted: |
| 282 |
% often used destination names would then be shorter than seldom used ones. |
| 283 |
% |
| 284 |
% \StopEventually{ |
| 285 |
% } |
| 286 |
% |
| 287 |
% \section{Implementation} |
| 288 |
% |
| 289 |
% \subsection{Identification} |
| 290 |
% |
| 291 |
% \begin{macrocode} |
| 292 |
%<*package> |
| 293 |
\NeedsTeXFormat{LaTeX2e} |
| 294 |
\ProvidesPackage{hypdestopt}% |
| 295 |
[2025-06-23 v2.9 Hyperref destination optimizer (HO)]% |
| 296 |
% \end{macrocode} |
| 297 |
% |
| 298 |
% \subsection{Check for PDF management} |
| 299 |
% \begin{macrocode} |
| 300 |
\IfPDFManagementActiveT |
| 301 |
{ |
| 302 |
\PackageWarning{hypdestopt} |
| 303 |
{ |
| 304 |
LaTeX PDF management detected. \MessageBreak |
| 305 |
The package will do nothing. |
| 306 |
}{} |
| 307 |
} |
| 308 |
\IfPDFManagementActiveT |
| 309 |
{ |
| 310 |
\endinput |
| 311 |
} |
| 312 |
% \end{macrocode} |
| 313 |
% \subsection{Options} |
| 314 |
% |
| 315 |
% \subsubsection{Option \xoption{verbose}} |
| 316 |
% |
| 317 |
% \begin{macrocode} |
| 318 |
\newif\ifHypDest@Verbose |
| 319 |
\DeclareOption{verbose}{\HypDest@Verbosetrue} |
| 320 |
% \end{macrocode} |
| 321 |
% |
| 322 |
% \begin{macro}{\HypDest@VerboseInfo} |
| 323 |
% Wrapper for verbose messages. |
| 324 |
% \begin{macrocode} |
| 325 |
\def\HypDest@VerboseInfo#1{% |
| 326 |
\ifHypDest@Verbose |
| 327 |
\PackageInfo{hypdestopt}{#1}% |
| 328 |
\fi |
| 329 |
} |
| 330 |
% \end{macrocode} |
| 331 |
% \end{macro} |
| 332 |
% |
| 333 |
% \subsubsection{Options \xoption{num} and \xoption{name}} |
| 334 |
% |
| 335 |
% The options \xoption{num} or \xoption{name} specify |
| 336 |
% the method, how destinations are referenced (by name or |
| 337 |
% number). Default is option \xoption{num}. |
| 338 |
% \begin{macrocode} |
| 339 |
\newif\ifHypDest@name |
| 340 |
\DeclareOption{num}{\HypDest@namefalse} |
| 341 |
\DeclareOption{name}{\HypDest@nametrue} |
| 342 |
% \end{macrocode} |
| 343 |
% |
| 344 |
% \begin{macrocode} |
| 345 |
\ProcessOptions*\relax |
| 346 |
% \end{macrocode} |
| 347 |
% |
| 348 |
% \subsection{Check requirements} |
| 349 |
% |
| 350 |
% First \pdfTeX\ must running in PDF mode. |
| 351 |
% \begin{macrocode} |
| 352 |
\RequirePackage{iftex}[2019/11/07] |
| 353 |
\RequirePackage{pdftexcmds}[2007/11/11] |
| 354 |
\ifpdf |
| 355 |
\else |
| 356 |
\PackageError{hypdestopt}{% |
| 357 |
This package requires pdfTeX or luaTeX in PDF mode% |
| 358 |
}\@ehc |
| 359 |
\expandafter\endinput |
| 360 |
\fi |
| 361 |
% \end{macrocode} |
| 362 |
% The version of \pdfTeX\ must not be too old, because |
| 363 |
% \cs{pdfescapehex} and \cs{pdfunescapehex} are used. |
| 364 |
% \begin{macrocode} |
| 365 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 366 |
\expandafter\ifx\csname pdf@escapehex\endcsname\relax |
| 367 |
\PackageError{hypdestopt}{% |
| 368 |
This pdfTeX is too old, at least 1.30.0 is required% |
| 369 |
}\@ehc |
| 370 |
\expandafter\endinput |
| 371 |
\fi |
| 372 |
% \end{macrocode} |
| 373 |
% Features of \eTeX\ are used, e.g. \cs{numexpr}. |
| 374 |
% \begin{macrocode} |
| 375 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 376 |
\expandafter\ifx\csname numexpr\endcsname\relax |
| 377 |
\PackageError{hypdestopt}{% |
| 378 |
e-TeX features are missing% |
| 379 |
}\@ehc |
| 380 |
\expandafter\endinput |
| 381 |
\fi |
| 382 |
% \end{macrocode} |
| 383 |
% Package \xpackage{alphalph} provides \cs{newalphalph} since |
| 384 |
% version 2006/05/30 v1.4. |
| 385 |
% \begin{macrocode} |
| 386 |
\ifHypDest@name |
| 387 |
\RequirePackage{alphalph}[2006/05/30]% |
| 388 |
\fi |
| 389 |
% \end{macrocode} |
| 390 |
% \begin{macrocode} |
| 391 |
\RequirePackage{auxhook}[2009/12/14] |
| 392 |
\RequirePackage{pdfescape}[2007/04/21] |
| 393 |
% \end{macrocode} |
| 394 |
% |
| 395 |
% \subsection{Preamble for auxiliary file} |
| 396 |
% |
| 397 |
% Provide dummy definitions for the macros that are used in the |
| 398 |
% auxiliary files. If the package is used no longer, then these |
| 399 |
% commands will not generate errors. |
| 400 |
% |
| 401 |
% \begin{macro}{\HypDest@PrependDocument} |
| 402 |
% We add our stuff in front of the \cs{AtBeginDocument} hook |
| 403 |
% to ensure that we are before \xpackage{hyperref}'s stuff. |
| 404 |
% Starting with LaTeX 2020/10/01 we use the hook and a rule. |
| 405 |
% \begin{macrocode} |
| 406 |
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} |
| 407 |
\IfFormatAtLeastTF{2020/10/01} |
| 408 |
{ |
| 409 |
\long\def\HypDest@PrependDocument#1{% |
| 410 |
\AddToHook{begindocument}{#1}}% |
| 411 |
\DeclareHookRule{begindocument}{.}{before}{hyperref} |
| 412 |
} |
| 413 |
{ |
| 414 |
\long\def\HypDest@PrependDocument#1{% |
| 415 |
\begingroup |
| 416 |
\toks\z@{#1}% |
| 417 |
\toks\tw@\expandafter{\@begindocumenthook}% |
| 418 |
\xdef\@begindocumenthook{\the\toks\z@\the\toks\tw@}% |
| 419 |
\endgroup |
| 420 |
} |
| 421 |
} |
| 422 |
% \end{macrocode} |
| 423 |
% \end{macro} |
| 424 |
% \begin{macrocode} |
| 425 |
\AddLineBeginAux{% |
| 426 |
\string\providecommand{\string\HypDest@Use}[1]{}% |
| 427 |
} |
| 428 |
% \end{macrocode} |
| 429 |
% |
| 430 |
% \subsection{Generation of destination names} |
| 431 |
% |
| 432 |
% Counter |HypDest| is used for identifying destinations. |
| 433 |
% \begin{macrocode} |
| 434 |
\newcounter{HypDest} |
| 435 |
% \end{macrocode} |
| 436 |
% |
| 437 |
% \begin{macrocode} |
| 438 |
\ifHypDest@name |
| 439 |
% \end{macrocode} |
| 440 |
% |
| 441 |
% \begin{macro}{\HypDest@HexChar} |
| 442 |
% Destination names are generated by automatically |
| 443 |
% numbering with the help of package \xpackage{alphalph}. |
| 444 |
% \cs{HypDest@HexChar} converts a number of the range 1 until 252 |
| 445 |
% into the hexadecimal representation of the string character. |
| 446 |
% \begin{macrocode} |
| 447 |
\def\HypDest@HexChar#1{% |
| 448 |
\ifcase#1\or |
| 449 |
% \end{macrocode} |
| 450 |
% Avoid zero byte because of C strings in PDF viewer |
| 451 |
% applications. |
| 452 |
% \begin{macrocode} |
| 453 |
01\or 02\or 03\or 04\or 05\or 06\or 07\or |
| 454 |
% \end{macrocode} |
| 455 |
% Omit carriage return (13/\verb|^^0d|). |
| 456 |
% It needs quoting, otherwise it would be converted |
| 457 |
% to line feed (10/\verb|^^0a|). |
| 458 |
% \begin{macrocode} |
| 459 |
08\or 09\or 0A\or 0B\or 0C\or 0E\or 0F\or |
| 460 |
10\or 11\or 12\or 13\or 14\or 15\or 16\or 17\or |
| 461 |
18\or 19\or 1A\or 1B\or 1C\or 1D\or 1E\or 1F\or |
| 462 |
20\or 21\or 22\or 23\or 24\or 25\or 26\or 27\or |
| 463 |
% \end{macrocode} |
| 464 |
% Omit left and right parentheses (40/\verb|^^28|, 41/\verb|^^39|), |
| 465 |
% they need quoting in general. |
| 466 |
% \begin{macrocode} |
| 467 |
2A\or 2B\or 2C\or 2D\or 2E\or 2F\or |
| 468 |
30\or 31\or 32\or 33\or 34\or 35\or 36\or 37\or |
| 469 |
38\or 39\or 3A\or 3B\or 3C\or 3D\or 3E\or 3F\or |
| 470 |
40\or 41\or 42\or 43\or 44\or 45\or 46\or 47\or |
| 471 |
48\or 49\or 4A\or 4B\or 4C\or 4D\or 4E\or 4F\or |
| 472 |
50\or 51\or 52\or 53\or 54\or 55\or 56\or 57\or |
| 473 |
% \end{macrocode} |
| 474 |
% Omit backslash (92/\verb|^^5C|), it needs quoting. |
| 475 |
% \begin{macrocode} |
| 476 |
58\or 59\or 5A\or 5B\or 5D\or 5E\or 5F\or |
| 477 |
60\or 61\or 62\or 63\or 64\or 65\or 66\or 67\or |
| 478 |
68\or 69\or 6A\or 6B\or 6C\or 6D\or 6E\or 6F\or |
| 479 |
70\or 71\or 72\or 73\or 74\or 75\or 76\or 77\or |
| 480 |
78\or 79\or 7A\or 7B\or 7C\or 7D\or 7E\or 7F\or |
| 481 |
80\or 81\or 82\or 83\or 84\or 85\or 86\or 87\or |
| 482 |
88\or 89\or 8A\or 8B\or 8C\or 8D\or 8E\or 8F\or |
| 483 |
90\or 91\or 92\or 93\or 94\or 95\or 96\or 97\or |
| 484 |
98\or 99\or 9A\or 9B\or 9C\or 9D\or 9E\or 9F\or |
| 485 |
A0\or A1\or A2\or A3\or A4\or A5\or A6\or A7\or |
| 486 |
A8\or A9\or AA\or AB\or AC\or AD\or AE\or AF\or |
| 487 |
B0\or B1\or B2\or B3\or B4\or B5\or B6\or B7\or |
| 488 |
B8\or B9\or BA\or BB\or BC\or BD\or BE\or BF\or |
| 489 |
C0\or C1\or C2\or C3\or C4\or C5\or C6\or C7\or |
| 490 |
C8\or C9\or CA\or CB\or CC\or CD\or CE\or CF\or |
| 491 |
D0\or D1\or D2\or D3\or D4\or D5\or D6\or D7\or |
| 492 |
D8\or D9\or DA\or DB\or DC\or DD\or DE\or DF\or |
| 493 |
E0\or E1\or E2\or E3\or E4\or E5\or E6\or E7\or |
| 494 |
E8\or E9\or EA\or EB\or EC\or ED\or EE\or EF\or |
| 495 |
F0\or F1\or F2\or F3\or F4\or F5\or F6\or F7\or |
| 496 |
% \end{macrocode} |
| 497 |
% Avoid 255 (0xFF) to get rid of a possible unicode |
| 498 |
% marker at the begin of the string. |
| 499 |
% \begin{macrocode} |
| 500 |
F8\or F9\or FA\or FB\or FC\or FD\or FE% |
| 501 |
\fi |
| 502 |
}% |
| 503 |
% \end{macrocode} |
| 504 |
% \end{macro} |
| 505 |
% \begin{macro}{HypDest@HexString} |
| 506 |
% Now package \xpackage{alphalph} comes into play. |
| 507 |
% \cs{HypDest@HexString} is defined and converts |
| 508 |
% a positive number into a string, given in hexadecimal |
| 509 |
% representation. |
| 510 |
% \begin{macrocode} |
| 511 |
\newalphalph\HypDest@HexString\HypDest@HexChar{250}% |
| 512 |
% \end{macrocode} |
| 513 |
% \end{macro} |
| 514 |
% \begin{macro}{\theHypDest} |
| 515 |
% For use, the hexadecimal string is converted back. |
| 516 |
% \begin{macrocode} |
| 517 |
\renewcommand*{\theHypDest}{% |
| 518 |
\pdf@unescapehex{\HypDest@HexString{\value{HypDest}}}% |
| 519 |
}% |
| 520 |
% \end{macrocode} |
| 521 |
% \end{macro} |
| 522 |
% |
| 523 |
% With option \xoption{num} we use the number directly. |
| 524 |
% \begin{macrocode} |
| 525 |
\else |
| 526 |
\renewcommand*{\theHypDest}{% |
| 527 |
\number\value{HypDest}% |
| 528 |
}% |
| 529 |
\fi |
| 530 |
% \end{macrocode} |
| 531 |
% |
| 532 |
% \subsection{Assign destination names} |
| 533 |
% |
| 534 |
% \begin{macro}{\HypDest@Prefix} |
| 535 |
% The new destination names are remembered in macros whose names |
| 536 |
% start with prefix \cs{HypDest@Prefix}. |
| 537 |
% \begin{macrocode} |
| 538 |
\edef\HypDest@Prefix{HypDest\string:} |
| 539 |
% \end{macrocode} |
| 540 |
% \end{macro} |
| 541 |
% |
| 542 |
% \begin{macro}{\HypDest@Use} |
| 543 |
% During the first read of the auxiliary files, the used destinations |
| 544 |
% get fresh generated short destination names. Also for the old |
| 545 |
% destination names we use the hexadecimal representation. That |
| 546 |
% avoid problems with arbitrary names. |
| 547 |
% \begin{macrocode} |
| 548 |
\def\HypDest@Use#1{% |
| 549 |
\begingroup |
| 550 |
\edef\x{% |
| 551 |
\expandafter\noexpand |
| 552 |
\csname\HypDest@Prefix\pdf@unescapehex{#1}\endcsname |
| 553 |
}% |
| 554 |
\expandafter\ifx\x\relax |
| 555 |
\stepcounter{HypDest}% |
| 556 |
\expandafter\xdef\x{\theHypDest}% |
| 557 |
\let\on@line\@empty |
| 558 |
\ifHypDest@name |
| 559 |
\HypDest@VerboseInfo{% |
| 560 |
Use: (\pdf@unescapehex{#1}) -\string> % |
| 561 |
0x\pdf@escapehex{\x} (\number\value{HypDest})% |
| 562 |
}% |
| 563 |
\else |
| 564 |
\HypDest@VerboseInfo{% |
| 565 |
Use: (\pdf@unescapehex{#1}) -\string> num \x |
| 566 |
}% |
| 567 |
\fi |
| 568 |
\fi |
| 569 |
\endgroup |
| 570 |
} |
| 571 |
% \end{macrocode} |
| 572 |
% \end{macro} |
| 573 |
% |
| 574 |
% After the first \xfile{.aux} file processing the destination names |
| 575 |
% are assigned and we can disable \cs{HypDest@Use}. |
| 576 |
% \begin{macrocode} |
| 577 |
\AtBeginDocument{% |
| 578 |
\let\HypDest@Use\@gobble |
| 579 |
} |
| 580 |
% \end{macrocode} |
| 581 |
% |
| 582 |
% \begin{macro}{\HypDest@MarkUsed} |
| 583 |
% Destinations that are actually used are marked by \cs{HypDest@MarkUsed}. |
| 584 |
% \cs{nofiles} is respected. |
| 585 |
% \begin{macrocode} |
| 586 |
\def\HypDest@MarkUsed#1{% |
| 587 |
\HypDest@VerboseInfo{% |
| 588 |
MarkUsed: (#1)% |
| 589 |
}% |
| 590 |
\if@filesw |
| 591 |
\immediate\write\@auxout{% |
| 592 |
\string\HypDest@Use{\pdf@escapehex{#1}}% |
| 593 |
}% |
| 594 |
\fi |
| 595 |
}% |
| 596 |
% \end{macrocode} |
| 597 |
% \end{macro} |
| 598 |
% |
| 599 |
% \subsection{Redefinition of \xpackage{hyperref}'s hooks} |
| 600 |
% |
| 601 |
% Package \xpackage{hyperref} can be loaded later, therefore |
| 602 |
% we redefine \xpackage{hyperref}'s macros at |\begin{document}|. |
| 603 |
% \begin{macrocode} |
| 604 |
\HypDest@PrependDocument{% |
| 605 |
% \end{macrocode} |
| 606 |
% |
| 607 |
% |
| 608 |
% \subsubsection{Destination setting} |
| 609 |
% |
| 610 |
% luatex compatibility |
| 611 |
% \begin{macrocode} |
| 612 |
\ifx\pdfextension\@undefined\else |
| 613 |
\protected\def\pdfdest{\pdfextension dest } |
| 614 |
\fi |
| 615 |
% \end{macrocode} |
| 616 |
% \begin{macrocode} |
| 617 |
\ifHypDest@name |
| 618 |
\let\HypDest@Org@DestName\Hy@DestName |
| 619 |
\renewcommand*{\Hy@DestName}[2]{% |
| 620 |
\EdefUnescapeString\HypDest@temp{#1}% |
| 621 |
\@ifundefined{\HypDest@Prefix\HypDest@temp}{% |
| 622 |
\HypDest@VerboseInfo{% |
| 623 |
DestName: (\HypDest@temp) unused% |
| 624 |
}% |
| 625 |
}{% |
| 626 |
\HypDest@Org@DestName{% |
| 627 |
\csname\HypDest@Prefix\HypDest@temp\endcsname |
| 628 |
}{#2}% |
| 629 |
\HypDest@VerboseInfo{% |
| 630 |
DestName: (\HypDest@temp) % |
| 631 |
0x\pdf@escapehex{% |
| 632 |
\csname\HypDest@Prefix\HypDest@temp\endcsname |
| 633 |
}% |
| 634 |
}% |
| 635 |
}% |
| 636 |
}% |
| 637 |
\else |
| 638 |
\renewcommand*{\Hy@DestName}[2]{% |
| 639 |
\EdefUnescapeString\HypDest@temp{#1}% |
| 640 |
\@ifundefined{\HypDest@Prefix\HypDest@temp}{% |
| 641 |
\HypDest@VerboseInfo{% |
| 642 |
DestName: (\HypDest@temp) unused% |
| 643 |
}% |
| 644 |
}{% |
| 645 |
\pdfdest num% |
| 646 |
\csname\HypDest@Prefix\HypDest@temp\endcsname#2\relax |
| 647 |
\HypDest@VerboseInfo{% |
| 648 |
DestName: (\HypDest@temp) % |
| 649 |
num \csname\HypDest@Prefix\HypDest@temp\endcsname |
| 650 |
}% |
| 651 |
}% |
| 652 |
}% |
| 653 |
\fi |
| 654 |
% \end{macrocode} |
| 655 |
% |
| 656 |
% \subsubsection{Links} |
| 657 |
% |
| 658 |
% \begin{macrocode} |
| 659 |
\let\HypDest@Org@StartlinkName\Hy@StartlinkName |
| 660 |
\ifHypDest@name |
| 661 |
\renewcommand*{\Hy@StartlinkName}[2]{% |
| 662 |
\HypDest@MarkUsed{#2}% |
| 663 |
\HypDest@Org@StartlinkName{#1}{% |
| 664 |
\@ifundefined{\HypDest@Prefix#2}{% |
| 665 |
#2% |
| 666 |
}{% |
| 667 |
\csname\HypDest@Prefix#2\endcsname |
| 668 |
}% |
| 669 |
}% |
| 670 |
}% |
| 671 |
\else |
| 672 |
\renewcommand*{\Hy@StartlinkName}[2]{% |
| 673 |
\HypDest@MarkUsed{#2}% |
| 674 |
\@ifundefined{\HypDest@Prefix#2}{% |
| 675 |
\HypDest@Org@StartlinkName{#1}{#2}% |
| 676 |
}{% |
| 677 |
\pdfstartlink attr{#1}% |
| 678 |
goto num\csname\HypDest@Prefix#2\endcsname |
| 679 |
\relax |
| 680 |
}% |
| 681 |
}% |
| 682 |
\fi |
| 683 |
% \end{macrocode} |
| 684 |
% |
| 685 |
% \subsubsection{Outlines of package \xpackage{hyperref}} |
| 686 |
% |
| 687 |
% \begin{macrocode} |
| 688 |
\let\HypDest@Org@OutlineName\Hy@OutlineName |
| 689 |
\ifHypDest@name |
| 690 |
\renewcommand*{\Hy@OutlineName}[4]{% |
| 691 |
\HypDest@Org@OutlineName{#1}{% |
| 692 |
\@ifundefined{\HypDest@Prefix#2}{% |
| 693 |
#2% |
| 694 |
}{% |
| 695 |
\csname\HypDest@Prefix#2\endcsname |
| 696 |
}% |
| 697 |
}{#3}{#4}% |
| 698 |
}% |
| 699 |
\else |
| 700 |
\renewcommand*{\Hy@OutlineName}[4]{% |
| 701 |
\@ifundefined{\HypDest@Prefix#2}{% |
| 702 |
\HypDest@Org@OutlineName{#1}{#2}{#3}{#4}% |
| 703 |
}{% |
| 704 |
\pdfoutline goto num\csname\HypDest@Prefix#2\endcsname |
| 705 |
count#3{#4}% |
| 706 |
}% |
| 707 |
}% |
| 708 |
\fi |
| 709 |
% \end{macrocode} |
| 710 |
% Because \cs{Hy@OutlineName} is called after the \xfile{.out} file |
| 711 |
% is written in the previous run. Therefore we mark the destination |
| 712 |
% earlier in \cs{@@writetorep}. |
| 713 |
% \begin{macrocode} |
| 714 |
\let\HypDest@Org@@writetorep\@@writetorep |
| 715 |
\renewcommand*{\@@writetorep}[5]{% |
| 716 |
\begingroup |
| 717 |
\edef\Hy@tempa{#5}% |
| 718 |
\ifx\Hy@tempa\Hy@bookmarkstype |
| 719 |
\HypDest@MarkUsed{#3}% |
| 720 |
\fi |
| 721 |
\endgroup |
| 722 |
\HypDest@Org@@writetorep{#1}{#2}{#3}{#4}{#5}% |
| 723 |
}% |
| 724 |
% \end{macrocode} |
| 725 |
% |
| 726 |
% \subsubsection{Outlines of package \xpackage{bookmark}} |
| 727 |
% |
| 728 |
% \begin{macrocode} |
| 729 |
\@ifpackageloaded{bookmark}{% |
| 730 |
\renewcommand*{\BKM@DefGotoNameAction}[2]{% |
| 731 |
\@ifundefined{\HypDest@Prefix#2}{% |
| 732 |
\edef#1{goto name{hypdestopt\string :unknown}}% |
| 733 |
}{% |
| 734 |
\ifHypDest@name |
| 735 |
\edef#1{goto name{\csname\HypDest@Prefix#2\endcsname}}% |
| 736 |
\else |
| 737 |
\edef#1{goto num\csname\HypDest@Prefix#2\endcsname}% |
| 738 |
\fi |
| 739 |
}% |
| 740 |
}% |
| 741 |
\def\BKM@HypDestOptHook{% |
| 742 |
\ifx\BKM@dest\@empty |
| 743 |
\else |
| 744 |
\ifx\BKM@gotor\@empty |
| 745 |
\HypDest@MarkUsed\BKM@dest |
| 746 |
\fi |
| 747 |
\fi |
| 748 |
}% |
| 749 |
}{}% |
| 750 |
% \end{macrocode} |
| 751 |
% |
| 752 |
% \begin{macrocode} |
| 753 |
} |
| 754 |
% \end{macrocode} |
| 755 |
% |
| 756 |
% |
| 757 |
% \begin{macrocode} |
| 758 |
%</package> |
| 759 |
% \end{macrocode} |
| 760 |
% |
| 761 |
% \section{Installation} |
| 762 |
% |
| 763 |
% \subsection{Download} |
| 764 |
% |
| 765 |
% \paragraph{Package.} This package is available on |
| 766 |
% CTAN\footnote{\CTANpkg{hypdestopt}}: |
| 767 |
% \begin{description} |
| 768 |
% \item[\CTAN{macros/latex/contrib/oberdiek/hypdestopt.dtx}] The source file. |
| 769 |
% \item[\CTAN{macros/latex/contrib/oberdiek/hypdestopt.pdf}] Documentation. |
| 770 |
% \end{description} |
| 771 |
% |
| 772 |
% |
| 773 |
% \subsection{Package installation} |
| 774 |
% |
| 775 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 776 |
% \docstrip\ archive. The files are extracted by running the |
| 777 |
% \xfile{.dtx} through \plainTeX: |
| 778 |
% \begin{quote} |
| 779 |
% \verb|tex hypdestopt.dtx| |
| 780 |
% \end{quote} |
| 781 |
% |
| 782 |
% \paragraph{TDS.} Now the different files must be moved into |
| 783 |
% the different directories in your installation TDS tree |
| 784 |
% (also known as \xfile{texmf} tree): |
| 785 |
% \begin{quote} |
| 786 |
% \def\t{^^A |
| 787 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 788 |
% hypdestopt.sty & tex/latex/oberdiek/hypdestopt.sty\\ |
| 789 |
% hypdestopt.pdf & doc/latex/oberdiek/hypdestopt.pdf\\ |
| 790 |
% hypdestopt.dtx & source/latex/oberdiek/hypdestopt.dtx\\ |
| 791 |
% \end{tabular}^^A |
| 792 |
% }^^A |
| 793 |
% \sbox0{\t}^^A |
| 794 |
% \ifdim\wd0>\linewidth |
| 795 |
% \begingroup |
| 796 |
% \advance\linewidth by\leftmargin |
| 797 |
% \advance\linewidth by\rightmargin |
| 798 |
% \edef\x{\endgroup |
| 799 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 800 |
% }\x |
| 801 |
% \def\lwbox{^^A |
| 802 |
% \leavevmode |
| 803 |
% \hbox to \linewidth{^^A |
| 804 |
% \kern-\leftmargin\relax |
| 805 |
% \hss |
| 806 |
% \usebox0 |
| 807 |
% \hss |
| 808 |
% \kern-\rightmargin\relax |
| 809 |
% }^^A |
| 810 |
% }^^A |
| 811 |
% \ifdim\wd0>\lw |
| 812 |
% \sbox0{\small\t}^^A |
| 813 |
% \ifdim\wd0>\linewidth |
| 814 |
% \ifdim\wd0>\lw |
| 815 |
% \sbox0{\footnotesize\t}^^A |
| 816 |
% \ifdim\wd0>\linewidth |
| 817 |
% \ifdim\wd0>\lw |
| 818 |
% \sbox0{\scriptsize\t}^^A |
| 819 |
% \ifdim\wd0>\linewidth |
| 820 |
% \ifdim\wd0>\lw |
| 821 |
% \sbox0{\tiny\t}^^A |
| 822 |
% \ifdim\wd0>\linewidth |
| 823 |
% \lwbox |
| 824 |
% \else |
| 825 |
% \usebox0 |
| 826 |
% \fi |
| 827 |
% \else |
| 828 |
% \lwbox |
| 829 |
% \fi |
| 830 |
% \else |
| 831 |
% \usebox0 |
| 832 |
% \fi |
| 833 |
% \else |
| 834 |
% \lwbox |
| 835 |
% \fi |
| 836 |
% \else |
| 837 |
% \usebox0 |
| 838 |
% \fi |
| 839 |
% \else |
| 840 |
% \lwbox |
| 841 |
% \fi |
| 842 |
% \else |
| 843 |
% \usebox0 |
| 844 |
% \fi |
| 845 |
% \else |
| 846 |
% \lwbox |
| 847 |
% \fi |
| 848 |
% \else |
| 849 |
% \usebox0 |
| 850 |
% \fi |
| 851 |
% \end{quote} |
| 852 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 853 |
% TDS installing feature, then some files can already be in the right |
| 854 |
% place, see the documentation of \docstrip. |
| 855 |
% |
| 856 |
% \subsection{Refresh file name databases} |
| 857 |
% |
| 858 |
% If your \TeX~distribution |
| 859 |
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh |
| 860 |
% these. For example, \TeX\,Live\ users run \verb|texhash| or |
| 861 |
% \verb|mktexlsr|. |
| 862 |
% |
| 863 |
% \subsection{Some details for the interested} |
| 864 |
% |
| 865 |
% \paragraph{Unpacking with \LaTeX.} |
| 866 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 867 |
% \begin{description} |
| 868 |
% \item[\plainTeX:] Run \docstrip\ and extract the files. |
| 869 |
% \item[\LaTeX:] Generate the documentation. |
| 870 |
% \end{description} |
| 871 |
% If you insist on using \LaTeX\ for \docstrip\ (really, |
| 872 |
% \docstrip\ does not need \LaTeX), then inform the autodetect routine |
| 873 |
% about your intention: |
| 874 |
% \begin{quote} |
| 875 |
% \verb|latex \let\install=y\input{hypdestopt.dtx}| |
| 876 |
% \end{quote} |
| 877 |
% Do not forget to quote the argument according to the demands |
| 878 |
% of your shell. |
| 879 |
% |
| 880 |
% \paragraph{Generating the documentation.} |
| 881 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 882 |
% the documentation. The process can be configured by the |
| 883 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put this |
| 884 |
% line into this file, if you want to have A4 as paper format: |
| 885 |
% \begin{quote} |
| 886 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 887 |
% \end{quote} |
| 888 |
% An example follows how to generate the |
| 889 |
% documentation with pdf\LaTeX: |
| 890 |
% \begin{quote} |
| 891 |
%\begin{verbatim} |
| 892 |
%pdflatex hypdestopt.dtx |
| 893 |
%makeindex -s gind.ist hypdestopt.idx |
| 894 |
%pdflatex hypdestopt.dtx |
| 895 |
%makeindex -s gind.ist hypdestopt.idx |
| 896 |
%pdflatex hypdestopt.dtx |
| 897 |
%\end{verbatim} |
| 898 |
% \end{quote} |
| 899 |
% |
| 900 |
% \begin{thebibliography}{9} |
| 901 |
% |
| 902 |
% \bibitem{alphalph} |
| 903 |
% Heiko Oberdiek: \textit{The \xpackage{alphalph} package}; |
| 904 |
% 2006/05/30 v1.4; |
| 905 |
% \CTANpkg{alphalph}. |
| 906 |
% |
| 907 |
% \bibitem{hyperref} |
| 908 |
% Sebastian Rahtz, Heiko Oberdiek: |
| 909 |
% \textit{The \xpackage{hyperref} package}; |
| 910 |
% 2006/06/01 v6.75a; |
| 911 |
% \CTANpkg{hyperref}. |
| 912 |
% |
| 913 |
% \end{thebibliography} |
| 914 |
% |
| 915 |
% \begin{History} |
| 916 |
% \begin{Version}{2006/06/01 v1.0} |
| 917 |
% \item |
| 918 |
% First version. |
| 919 |
% \end{Version} |
| 920 |
% \begin{Version}{2006/06/01 v2.0} |
| 921 |
% \item |
| 922 |
% New method for referencing destinations by number; an idea |
| 923 |
% proposed by Lars Hellstr\"om in the mailing list LATEX-L. |
| 924 |
% \item |
| 925 |
% Options \xoption{name} and \xoption{num} added. |
| 926 |
% \end{Version} |
| 927 |
% \begin{Version}{2007/11/11 v2.1} |
| 928 |
% \item |
| 929 |
% Use of package \xpackage{pdftexcmds} for \LuaTeX\ support. |
| 930 |
% \end{Version} |
| 931 |
% \begin{Version}{2008/08/08 v2.2} |
| 932 |
% \item |
| 933 |
% Support for package \xpackage{bookmark} added. |
| 934 |
% \end{Version} |
| 935 |
% \begin{Version}{2011/05/13 v2.3} |
| 936 |
% \item |
| 937 |
% Fix for \cs{Hy@DestName} if the destination name contains |
| 938 |
% special characters. |
| 939 |
% \item |
| 940 |
% Fix for option \xoption{name} and package \xpackage{bookmark}. |
| 941 |
% \end{Version} |
| 942 |
% \begin{Version}{2016/05/16 v2.4} |
| 943 |
% \item |
| 944 |
% Documentation updates. |
| 945 |
% \end{Version} |
| 946 |
% \begin{Version}{2016/05/21 v2.5} |
| 947 |
% \item |
| 948 |
% LuaTeX compatibility |
| 949 |
% \end{Version} |
| 950 |
% \begin{Version}{2019/12/29 v2.6} |
| 951 |
% \item |
| 952 |
% use \xpackage{iftex} package. |
| 953 |
% \end{Version} |
| 954 |
% \begin{Version}{2020-09-02 v2.7} |
| 955 |
% \item Adapted to the new hook management of LaTeX (github issue 1) |
| 956 |
% \end{Version} |
| 957 |
% \begin{Version}{2024-08-07 v2.8} |
| 958 |
% \item Disable the package if \cs{DocumentMetadata} is detected (github issue 2) |
| 959 |
% \end{Version} |
| 960 |
% \begin{Version}{2025-06-23 v2.9} |
| 961 |
% \item Adapted test for PDF management. |
| 962 |
% \end{Version} |
| 963 |
% \end{History} |
| 964 |
% |
| 965 |
% \PrintIndex |
| 966 |
% |
| 967 |
% \Finale |
| 968 |
\endinput |