Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % File: hrefhide.dtx
4 % Version: 2025-01-27 v1.1b
5 % Info: Hiding hyperrefs when printing pdf files
6 %
7 % Copyright © 2010 - 2025 by
8 % H.-Martin Münch <Martin dot Muench at Uni-Bonn dot de>
9 %
10 % This work may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either
12 % version 1.3c of this license or (at your option) any later
13 % version. This version of this license is in
14 % https://www.latex-project.org/lppl/lppl-1-3c.txt
15 % and the latest version of this license is in
16 % https://www.latex-project.org/lppl.txt
17 % and version 1.3c or later is part of all distributions of
18 % LaTeX version 2005-12-01 or later.
19 %
20 % This work has the LPPL maintenance status "maintained".
21 %
22 % The Current Maintainer of this work is H.-Martin Münch.
23 %
24 % This work consists of the main source file hrefhide.dtx,
25 % the README, and the derived files
26 % hrefhide.sty, hrefhide.pdf,
27 % hrefhide.ins, hrefhide.drv,
28 % hrefhide-example.tex, hrefhide-example.pdf.
29 %
30 % "hrefhide" is available on CTAN:
31 % https://ctan.org/pkg/hrefhide
32 %
33 % Also a TDS.ZIP file is provided that contains all the files
34 % already sorted in a TDS tree:
35 % https://mirror.ctan.org/install/macros/latex/contrib/hrefhide.tds.zip
36 %
37 %<*ignore>
38 \begingroup
39 \catcode123=1 %
40 \catcode125=2 %
41 \def\x{LaTeX2e}%
42 \expandafter\endgroup
43 \ifcase 0\ifx\install y1\fi\expandafter
44 \ifx\csname processbatchFile\endcsname\relax\else1\fi
45 \ifx\fmtname\x\else 1\fi\relax
46 \else\csname fi\endcsname
47 %</ignore>
48 %<*install>
49 \input docstrip.tex
50 \Msg{************************************************************************************}
51 \Msg{* Installation *}
52 \Msg{* Package: hrefhide 2025-01-27 v1.1b Hiding hyperrefs when printing pdf files (HMM)*}
53 \Msg{************************************************************************************}
54
55 \keepsilent
56 \askforoverwritefalse
57
58 \let\MetaPrefix\relax
59 \preamble
60
61 This is a generated file.
62
63 Project: hrefhide
64 Version: 2025-01-27 v1.1b
65 Info: Hiding hyperrefs when printing pdf files
66
67 Copyright (C) 2010 - 2025 by
68 H.-Martin Muench <Martin dot Muench at Uni-Bonn dot de>
69
70 This work may be distributed and/or modified under the
71 conditions of the LaTeX Project Public License, either
72 version 1.3c of this license or (at your option) any later
73 version. This version of this license is in
74 https://www.latex-project.org/lppl/lppl-1-3c.txt
75 and the latest version of this license is in
76 https://www.latex-project.org/lppl.txt
77 and version 1.3c or later is part of all distributions of
78 LaTeX version 2005-12-01 or later.
79
80 This work has the LPPL maintenance status "maintained".
81
82 The Current Maintainer of this work is H.-Martin Muench.
83
84 This work consists of the main source file hrefhide.dtx,
85 the README, and the derived files
86 hrefhide.sty, hrefhide.pdf,
87 hrefhide.ins, hrefhide.drv,
88 hrefhide-example.tex, hrefhide-example.pdf.
89
90 In memoriam
91 Claudia Simone Barth + 1996-01-30
92 Tommy Muench + 2014-01-02
93 Hans-Klaus Muench + 2014-08-24
94
95 \endpreamble
96 \let\MetaPrefix\DoubleperCent
97
98 \generate{%
99 \file{hrefhide.ins}{\from{hrefhide.dtx}{install}}%
100 \file{hrefhide.drv}{\from{hrefhide.dtx}{driver}}%
101 \usedir{tex/latex/hrefhide}%
102 \file{hrefhide.sty}{\from{hrefhide.dtx}{package}}%
103 \usedir{doc/latex/hrefhide}%
104 \file{hrefhide-example.tex}{\from{hrefhide.dtx}{example}}%
105 }
106
107 \catcode32=13\relax% active space
108 \let =\space%
109 \Msg{************************************************************************}
110 \Msg{*}
111 \Msg{* To finish the installation you have to move the following}
112 \Msg{* file into a directory searched by TeX:}
113 \Msg{*}
114 \Msg{* hrefhide.sty}
115 \Msg{*}
116 \Msg{* To produce the documentation run the file `hrefhide.drv'}
117 \Msg{* through (pdf)LaTeX, e.g.}
118 \Msg{* pdflatex hrefhide.drv}
119 \Msg{* makeindex -s gind.ist hrefhide.idx}
120 \Msg{* pdflatex hrefhide.drv}
121 \Msg{* makeindex -s gind.ist hrefhide.idx}
122 \Msg{* pdflatex hrefhide.drv}
123 \Msg{*}
124 \Msg{* At least three runs are necessary e.g. to get the}
125 \Msg{* references right!}
126 \Msg{*}
127 \Msg{* Happy TeXing!}
128 \Msg{*}
129 \Msg{************************************************************************}
130
131 \endbatchfile
132 %</install>
133 %<*ignore>
134 \fi
135 %</ignore>
136 %
137 % \section{The documentation driver file}
138 %
139 % The next bit of code contains the documentation driver file for
140 % \TeX , i.\,e., the file that will produce the documentation you
141 % are currently reading. It will be extracted from this file by the
142 % \texttt{docstrip} programme. That is, run \LaTeX{} on \texttt{docstrip}
143 % and specify the \texttt{driver} option when \texttt{docstrip}
144 % asks for options.
145 %
146 % \begin{macrocode}
147 %<*driver>
148 \NeedsTeXFormat{LaTeX2e}[2024-11-01]
149 \ProvidesFile{hrefhide.drv}%
150 [2025-01-27 v1.1b Hiding hyperrefs when printing pdf files (HMM)]
151 \documentclass{ltxdoc}[2024/02/08]% v2.1j Standard LaTeX documentation class
152 \usepackage{holtxdoc}[2019/12/09]% v0.30 Private additional ltxdoc support (HO)
153 \hypersetup{%
154 pdfsubject={Hiding hyperrefs when printing pdf files (HMM)},%
155 pdfkeywords={LaTeX, hrefhide, hyperref, href, pdf, hide, print},%
156 pdfencoding=auto,%
157 pdflang={en},%
158 breaklinks=true,%
159 linktoc=all,%
160 pdfstartview=FitH,%
161 pdfpagelayout=OneColumn,%
162 bookmarksnumbered=true,%
163 bookmarksopen=true,%
164 bookmarksopenlevel=3,%
165 pdfmenubar=true,%
166 pdftoolbar=true,%
167 pdfwindowui=true,%
168 pdfnewwindow=true%
169 }
170 \CodelineIndex
171 \hyphenation{docu-ment}
172 \begin{document}
173 \DocInput{hrefhide.dtx}%
174 \end{document}
175 %</driver>
176 % \end{macrocode}
177 % \fi
178 %
179 % \GetFileInfo{hrefhide.drv}
180 %
181 % \begingroup
182 % \def\x{\#,\$,\^,\_,\~,\ ,\&,\{,\},\%}%
183 % \makeatletter
184 % \@onelevel@sanitize\x
185 % \expandafter\endgroup
186 % \expandafter\DoNotIndex\expandafter{\x}
187 % \expandafter\DoNotIndex\expandafter{\string\ }
188 % \begingroup
189 % \makeatletter
190 % \lccode`9=32\relax
191 % \lowercase{%^^A
192 % \edef\x{\noexpand\DoNotIndex{\@backslashchar9}}%^^A
193 % }%^^A
194 % \expandafter\endgroup\x
195 %
196 % \DoNotIndex{\@anchorbordercolor,\@anchorcolor,\@citebordercolor,\@citecolor,\@filebordercolor,%
197 % \@filecolor,\@ifl@t@r,\@ifundefined,\@linkbordercolor,\@linkcolor,\@menubordercolor,%
198 % \@menucolor,\@runbordercolor,\@runcolor,\@urlbordercolor,\@urlcolor,\\,%
199 % \AddToHook,\begin,\bigskip,\color,\DeclareKeys,%
200 % \DeclareRobustCommand,\DeclareStringOption,\definecolor,\documentclass,\end,\fmtversion,%
201 % \href,\hrefhide@anchorbordercolor,\hrefhide@backgroundcolour,%
202 % \hrefhide@driver,\hrefhide@linktextcolour,\hrefhide@pdfborder,%
203 % \hrefhidefalse,\hrefhidetrue,\Hy@driver,\hypersetup,\hypertarget,%
204 % \IfFormatAtLeastTF,\IfPackageLoadedWithOptionsTF,\ifx,\Large,\linebreak,%
205 % \lipsum,\listfiles,\markboth,\MessageBreak,\NeedsTeXFormat,\newif,\newline,\noindent,%
206 % \ocgx,\PackageError,\PackageInfo,\PackageWarning,\pagebreak,%
207 % \pagenumbering,\ProcessKeyOptions,\ProvidesPackage,%
208 % \RequirePackage,\section,\SetKeys,\space,\textbf,\textit,\textsf,\texttt,%
209 % \usepackage,\verb}
210 %
211 % \title{The \xpackage{hrefhide} package}
212 % \date{2025-01-27 v1.1b}
213 % \author{H.-Martin Münch\\\xemail{Martin.Muench at Uni-Bonn.de}}
214 %
215 % \maketitle
216 %
217 % \begin{abstract}
218 % \noindent This \LaTeX{} package allows to \textquotedblleft hide\textquotedblright{} some
219 % (hyperlinked) text when printing the document while keeping the layout and
220 % to simulate switching \texttt{ocgcolor} of \xpackage{hyperref} package on and off.~--\newline
221 % This package is possibly obsolete, see section~\ref{s:Alternatives}: Alternatives.
222 % \end{abstract}
223 % \bigskip
224 %
225 % \noindent Disclaimer for web links: The author is not responsible for any contents
226 % referred to in this work unless having full knowledge of illegal contents.
227 % If any damage occurs by the use of information presented there,
228 % only the author of the respective pages might be liable,
229 % not the one who has referred to those pages.
230 %
231 % \tableofcontents
232 % \bigskip
233 %
234 % \section{Introduction}
235 % \indent This \LaTeX{} package provides the command |\hrefdisplayonly|
236 % (additionally to |\href| of the \xpackage{hyperref} package). While the
237 % (hyperlinked) text appears like an ordinary \texttt{\textbackslash href}
238 % in the compiled \xext{pdf}-file, the same text will be
239 % \textquotedblleft hidden\textquotedblright{} when printing the text.
240 % It is not really invisible, but just has the same color as the background
241 % (default: |white|). Therefore the layout is not changed when printing
242 % the document.\newline
243 % Further the commands |\hycon| and |\hycoff| (|hy|per-|c|olour-|on|/|off|)
244 % can be used to \emph{simulate} switching option |ocgcolorlinks| of the
245 % \xpackage{hyperref} package on and off.\newline
246 % This package is probably obsolete, see section~\ref{s:Alternatives}: Alternatives.
247 %
248 % \section{Usage}
249 % \indent Just load the package placing
250 % \begin{quote}
251 % |\usepackage[<|\textit{options}|>]{hrefhide}|
252 % \end{quote}
253 % \noindent in the preamble of your \LaTeXe{} source file \textbf{after}
254 % the \xpackage{hyperref} package. For a link, which shall not be printed,
255 % use |\hrefdisplayonly| instead of |\href|. This might be practical
256 % for example for internal links, which make no sense in a printed
257 % version (\textquotedblleft Click here\textquotedblright{} does
258 % not work with physical paper).\newline
259 % |\hypersetup{ocgcolorlinks=true}| and |\hypersetup{ocgcolorlinks=false}|
260 % may work -- or they may not. (|ocgcolorlinks| is a decision to be made
261 % in the preamble and performs changes which cannot easily be reverted.)
262 % But it is possible to use |ocgcolorlinks| while letting the links
263 % \emph{appear} as if |ocgcolorlinks=false| was chosen. Therefore this
264 % package provides the command |\hycoff| (and |\hycon| to switch back to
265 % default |ocgcolorlinks=true| behaviour). Note that |ocgcolorlinks=true|
266 % really is enabled, therefore all limitation of this apply
267 % (e.\,g.~no breaks in links).
268 %
269 % \subsection{Options}
270 % \DescribeMacro{options}
271 % \indent The \xpackage{hrefhide} package takes the following options:
272 %
273 % \subsubsection{linktextcolour}
274 % \DescribeMacro{linktextcolour}
275 % \indent The option \texttt{linktextcolour} takes the color of
276 % the text of the links. The default is \texttt{black}.
277 %
278 % \subsubsection{backgroundcolour}
279 % \DescribeMacro{backgroundcolour}
280 % \indent The option \texttt{backgroundcolour} takes the color of
281 % the background of the links. The default is \texttt{white}.
282 %
283 % \subsubsection{pdfborder}
284 % \DescribeMacro{pdfborder}
285 % \indent The option \texttt{pdfborder} takes the configuration of
286 % the pdfborder around the link. The default is \texttt{\{0~0~1\}},
287 % \hbox{i.\,e. a 1\,pt} rectangular line. \texttt{\{0~0~0\}} means no line.
288 % \pagebreak
289 %
290 % \section{Alternatives\label{s:Alternatives}}
291 % \DescribeMacro{ocgcolorlinks}
292 % If option \texttt{ocgcolorlinks} (of the \xpackage{hyperref} package)
293 % is already used in your document (i.\,e. you \emph{want} colored links),
294 % do \textbf{NOT} use this \xpackage{hrefhide} package to hide links!
295 % For a link to be \textquotedblleft hidden\textquotedblright, just say
296 % \begin{verbatim}
297 % {\color{white} \href{...}{...}}
298 % \end{verbatim}
299 % \vspace{-\baselineskip}
300 % (and replace \texttt{white} with the background color;
301 % when the \href{https://ctan.org/pkg/pagecolor}{\pkg{pagecolor}}
302 % package is used, |\thepagecolor| instead of |white| should be used).\bigskip
303 %
304 % \DescribeMacro{pdfcomment}
305 % For hiding text, which does not contain links, the
306 % \href{https://ctan.org/pkg/pdfcomment}{\xpackage{pdfcomment}}
307 % package by \textsc{Josef Kleber} should be noted.\bigskip
308 %
309 % \DescribeMacro{ocgx2}
310 % This |hrefhide| package is probably obsolete. Using the
311 % \href{https://ctan.org/pkg/ocgx2}{\xpackage{ocgx2}} package
312 % \begin{verbatim}
313 % \usepackage[<options>]{ocgx2}
314 % \begin{ocg}[<options>]{<layer name>}{<OCG id>}{<initial visibility>}
315 % ... material to be put on a PDF layer ...
316 % \end{ocg}
317 % \end{verbatim}
318 % \vspace{-\baselineskip}
319 % one can say
320 % \begin{verbatim}
321 % \begin{ocg}[printocg=never, exportocg=never, listintoolbar=never%
322 % ]{MyLayer}{example}{1}%
323 % \hyperref[RefB]{B} \url{https://ctan.org/} simple text etc.%
324 % \end{ocg}%
325 % \end{verbatim}
326 % \vspace{-\baselineskip}
327 % and the links will be visible in the pdf document
328 % but will turn into blank space when printed.
329 %
330 % \section{Example}
331 % \begin{macrocode}
332 %<*example>
333 \NeedsTeXFormat{LaTeX2e}[2024-11-01]
334 \documentclass[british]{article}[2024/06/29]% v1.4n Standard LaTeX document class
335 \usepackage{lipsum}[2021-09-20]% v2.7 150 paragraphs of Lorem Ipsum dummy text
336 \usepackage[ocgcolorlinks,bookmarks=false,bookmarksopen=false%
337 ]{hyperref}[2024-11-05]% v7.01l Hypertext links for LaTeX
338 % Bookmarks are not needed here, but are possible, of course.
339 \hypersetup{extension=pdf,%
340 plainpages=false,%
341 pdfpagelabels=true,%
342 hyperindex=false,%
343 pdflang={en},%
344 pdftitle={hrefhide package example},%
345 pdfauthor={H.-Martin Muench},%
346 pdfsubject={Example for the hrefhide package},%
347 pdfkeywords={LaTeX, hrefhide},%
348 pdfview=Fit,pdfstartview=Fit,%
349 pdfpagelayout=SinglePage%
350 }
351 \usepackage[linktextcolour=black,backgroundcolour=white,pdfborder={0 0 1}%
352 ]{hrefhide}[2025-01-27]% v1.1b Hiding hyperrefs when printing pdf files (HMM)
353 \listfiles
354 \begin{document}
355 \pagenumbering{arabic}
356 \section*{Example for hrefhide}
357 \markboth{Example for hrefhide}{Example for hrefhide}
358
359 This example demonstrates the use of package\newline
360 \textsf{hrefhide}, v1.1b as of 2025-01-27 (HMM).\newline
361 % \end{macrocode}
362 % \pagebreak
363 % \begin{macrocode}
364 The used options were \texttt{linktextcolour=black},
365 \texttt{backgroundcolour=white}, and \texttt{pdfborder={0 0 1}}
366 (the default ones).\newline
367 For more details please see the documentation!\bigskip
368
369 \textit{Print-\textbf{preview} the first page of this document
370 and compare it with the page as displayed in your pdf reader.}\bigskip
371
372 Lorem ipsum dolor sit amet \href{\#target}{link to target} consectetuer
373 adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet
374 dolore magna aliquam erat volutpat.
375
376 Ut wisi enim ad minim
377 veniam \hrefdisplayonly{\#target}{hidden link to target} quis nostrud
378 exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea
379 commodo consequat.
380
381 Duis autem vel eum iriure dolor \href{\#target}{link to target} in
382 hendrerit in vulputate velit esse molestie consequat, vel illum dolore
383 eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
384 dignissim qui blandit praesent luptatum zzril delenit augue
385 duis dolore te feugait nulla facilisi.
386
387 \noindent \textbf{\textsf{%
388 \hrefdisplayonly{\#RefA}{A}
389 \hrefdisplayonly{\#RefB}{B}
390 \hrefdisplayonly{\#RefC}{C}
391 \hrefdisplayonly{\#RefD}{D}
392 \hrefdisplayonly{\#RefE}{E}
393 \hrefdisplayonly{\#RefF}{F}
394 \hrefdisplayonly{\#RefG}{G}
395 \hrefdisplayonly{\#RefH}{H}
396 \hrefdisplayonly{\#RefI}{I}
397 \hrefdisplayonly{\#RefJ}{J}
398 \hrefdisplayonly{\#RefK}{K}
399 \hrefdisplayonly{\#RefL}{L}
400 \hrefdisplayonly{\#RefM}{M}
401 \hrefdisplayonly{\#RefN}{N}
402 \hrefdisplayonly{\#RefO}{O}
403 \hrefdisplayonly{\#RefP}{P}
404 \hrefdisplayonly{\#RefQ}{Q}
405 \hrefdisplayonly{\#RefR}{R}
406 \hrefdisplayonly{\#RefS}{S}
407 \hrefdisplayonly{\#RefT}{T}
408 \hrefdisplayonly{\#RefU}{U}
409 \hrefdisplayonly{\#RefV}{V}
410 \hrefdisplayonly{\#RefW}{W}
411 \hrefdisplayonly{\#RefX}{X}
412 \hrefdisplayonly{\#RefY}{Y}
413 \hrefdisplayonly{\#RefZ}{Z}}}\linebreak
414
415 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
416 vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida
417 mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
418
419 Switching to colored links with \verb|\hycon|:\newline
420 \hycon%
421 \href{\#RefX}{section X} and also
422 \href{https://ctan.org/pkg/hrefhide}{https://ctan.org/pkg/hrefhide}.
423
424 Switching off the colored links with \verb|\hycoff| again:\newline
425 \hycoff%
426 \href{\#RefX}{section X} and also
427 \href{https://ctan.org/pkg/hrefhide}{https://ctan.org/pkg/hrefhide}.
428 \pagebreak
429
430 {\Large \textbf{Targets}}\newline
431 Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
432 nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
433 volutpat. \hypertarget{target}{target text} Ut wisi enim ad minim
434 veniam, quis nostrud exerci tation ullamcorper suscipit lobortis
435 nisl ut aliquip ex ea commodo consequat.
436
437 \section[A]{\hypertarget{RefA}{A}} \lipsum[1]
438 \section[B]{\hypertarget{RefB}{B}} \lipsum[1]
439 \section[C]{\hypertarget{RefC}{C}} \lipsum[1]
440 \section[D]{\hypertarget{RefD}{D}} \lipsum[1]
441 \section[E]{\hypertarget{RefE}{E}} \lipsum[1]
442 \section[F]{\hypertarget{RefF}{F}} \lipsum[1]
443 \section[G]{\hypertarget{RefG}{G}} \lipsum[1]
444 \section[H]{\hypertarget{RefH}{H}} \lipsum[1]
445 \section[I]{\hypertarget{RefI}{I}} \lipsum[1]
446 \section[J]{\hypertarget{RefJ}{J}} \lipsum[1]
447 \section[K]{\hypertarget{RefK}{K}} \lipsum[1]
448 \section[L]{\hypertarget{RefL}{L}} \lipsum[1]
449 \section[M]{\hypertarget{RefM}{M}} \lipsum[1]
450 \section[N]{\hypertarget{RefN}{N}} \lipsum[1]
451 \section[O]{\hypertarget{RefO}{O}} \lipsum[1]
452 \section[P]{\hypertarget{RefP}{P}} \lipsum[1]
453 \section[Q]{\hypertarget{RefQ}{Q}} \lipsum[1]
454 \section[R]{\hypertarget{RefR}{R}} \lipsum[1]
455 \section[S]{\hypertarget{RefS}{S}} \lipsum[1]
456 \section[T]{\hypertarget{RefT}{T}} \lipsum[1]
457 \section[U]{\hypertarget{RefU}{U}} \lipsum[1]
458 \section[V]{\hypertarget{RefV}{V}} \lipsum[1]
459 \section[W]{\hypertarget{RefW}{W}} \lipsum[1]
460 \section[X]{\hypertarget{RefX}{X}} \lipsum[1]
461 \section[Y]{\hypertarget{RefY}{Y}} \lipsum[1]
462 \section[Z]{\hypertarget{RefZ}{Z}} \lipsum[1]
463 \end{document}
464 %</example>
465 % \end{macrocode}
466 %
467 % \StopEventually{}
468 % \newpage
469 %
470 % \section{The implementation}
471 % We start off by checking that we are loading into \LaTeXe{} and
472 % announcing the name and version of this package.
473 %
474 % \begin{macrocode}
475 %<*package>
476 \NeedsTeXFormat{LaTeX2e}[2024-11-01]
477 \ProvidesPackage{hrefhide}[2025-01-27 v1.1b %
478 Hiding hyperrefs when printing pdf files (HMM)]
479 %% Allows to "hide" hyperlinked text in a pdf file when printing
480 %% ("Click here" does not work on physical paper)
481 %% by providing the command \hrefdisplayonly
482 %% and allows simulating to switch on/off ocgcolourlinks
483 %% of the hyperref package.
484
485 \@ifl@t@r\fmtversion{2024/11/01}{% would have understood
486 % \IfFormatAtLeastTF{2024-11-01}{<true code>}{<false code>}
487 }{\PackageError{hrefhide}{%
488 Newer LaTeX format needed or older hrefhide package%
489 }{Needed LaTeX format version: 2024-11-01 or newer.\MessageBreak%
490 Found\space\space LaTeX format version: \fmtversion.\MessageBreak%
491 Please update your TeX distribution.
492 }
493 }
494
495 % \end{macrocode}
496 %
497 % We need the \xpackage{xcolor} package by \textsc{Dr.~Uwe Kern}
498 % \begin{macrocode}
499 \RequirePackage{xcolor}[2024/09/29]% v3.02 LaTeX color extensions (UK)
500 % \end{macrocode}
501 % and the \xpackage{hyperref} package:
502 % \begin{macrocode}
503 \RequirePackage[ocgcolorlinks]{hyperref}[2024-11-05]% v7.01l Hypertext links for LaTeX
504 % \end{macrocode}
505 % \indent See subsection~\ref{ss:Downloads} about how to get them.
506 %
507 % The options are introduced:
508 %
509 % \begin{macrocode}
510
511 \DeclareKeys[hrefhide]
512 {linktextcolour .store = \hrefhide@linktextcolour ,
513 linktextcolour .usage = preamble ,
514 backgroundcolour .store = \hrefhide@backgroundcolour ,
515 backgroundcolour .usage = preamble ,
516 pdfborder .store = \hrefhide@pdfborder ,
517 pdfborder .usage = preamble
518 }
519
520 \SetKeys[hrefhide]{linktextcolour=black,backgroundcolour=white,pdfborder={0 0 1}}
521
522 \ProcessKeyOptions[hrefhide]
523
524 \newif\ifhrefhide
525
526 % \end{macrocode}
527 %
528 % The new commands are defined:
529 %
530 % \begin{macro}{\hycon}
531 % \DescribeMacro{\hycon}
532 % \vspace{-1.15\baselineskip}
533 % \begin{macrocode}
534 \DeclareRobustCommand{\hycon}{%
535 \ifhrefhide%
536 \PackageWarning{hrefhide}{\string\hycon\space called when OCG-link %
537 coloring was not OFF\MessageBreak%
538 - nothing done}%
539 \else%
540 \@ifundefined{@anchorbordercolor}{%
541 \hypersetup{anchorcolor=\hrefhide@anchorbordercolor}%
542 }{%
543 \definecolor{hyanchorbordercolor}{rgb}{\@anchorbordercolor}%
544 \hypersetup{anchorcolor=hyanchorbordercolor}%
545 }%
546 % \end{macrocode}
547 % because there is no \texttt{anchorborder(color)} in \xpackage{hyperref}.
548 % \begin{macrocode}
549 \definecolor{hycitebordercolor}{rgb}{\@citebordercolor}%
550 \hypersetup{citecolor=hycitebordercolor}%
551 \definecolor{hyfilebordercolor}{rgb}{\@filebordercolor}%
552 \hypersetup{filecolor=hyfilebordercolor}%
553 \definecolor{hylinkbordercolor}{rgb}{\@linkbordercolor}%
554 \hypersetup{linkcolor=hylinkbordercolor}%
555 \definecolor{hymenubordercolor}{rgb}{\@menubordercolor}%
556 \hypersetup{menucolor=hymenubordercolor}%
557 \definecolor{hyrunbordercolor}{rgb}{\@runbordercolor}%
558 \hypersetup{runcolor=hyrunbordercolor}%
559 \definecolor{hyurlbordercolor}{rgb}{\@urlbordercolor}%
560 \hypersetup{urlcolor=hyurlbordercolor}%
561 \hypersetup{pdfborder=0 0 0}%
562 \hrefhidetrue%
563 \PackageInfo{hrefhide}{OCG-link coloring ON\MessageBreak}%
564 \fi%
565 }
566
567 % \end{macrocode}
568 %
569 % If link coloring is already |ON|, nothing is done. Otherwise
570 % |\hycon| looks for the color of the border of a link type and
571 % sets the color of the text of that link type to that color.
572 % \end{macro}
573 %
574 % \begin{macro}{\hycoff}
575 % \DescribeMacro{\hycoff}
576 % \indent This package on the one hand uses the \texttt{ocgcolor} option
577 % of the \xpackage{hyperref} package, but on the other hand
578 % does not really want colored links (see \ref{s:Alternatives}).
579 % Thus we simulate to turn it off:
580 %
581 % \begin{macrocode}
582 \DeclareRobustCommand{\hycoff}{%
583 \ifhrefhide%
584 \@ifundefined{@anchorbordercolor}{%
585 \xdef\hrefhide@anchorbordercolor{\@anchorcolor}%
586 }{\hypersetup{anchorbordercolor=\@anchorcolor}%
587 }%
588 % \end{macrocode}
589 % because there is no \texttt{anchorborder(color)} in \xpackage{hyperref}.
590 % \begin{macrocode}
591 \hypersetup{anchorcolor=\hrefhide@linktextcolour}%
592 \hypersetup{citebordercolor=\@citecolor}%
593 \hypersetup{citecolor=\hrefhide@linktextcolour}%
594 \hypersetup{filebordercolor=\@filecolor}%
595 \hypersetup{filecolor=\hrefhide@linktextcolour}%
596 \hypersetup{linkbordercolor=\@linkcolor}%
597 \hypersetup{linkcolor=\hrefhide@linktextcolour}%
598 \hypersetup{menubordercolor=\@menucolor}%
599 \hypersetup{menucolor=\hrefhide@linktextcolour}%
600 \hypersetup{runbordercolor=\@runcolor}%
601 \hypersetup{runcolor=\hrefhide@linktextcolour}%
602 \hypersetup{urlbordercolor=\@urlcolor}%
603 \hypersetup{urlcolor=\hrefhide@linktextcolour}%
604 \hypersetup{pdfborder=\hrefhide@pdfborder}%
605 \hrefhidefalse%
606 % \end{macrocode}
607 %
608 % If link coloring is already |OFF|, nothing is done. Otherwise
609 % the color of the respective border is set to the color of the text
610 % of the link type, setting the color of the text of the link type to
611 % |\hrefhide@linktextcolour| (default: black) and the link border again to
612 % |\hrefhide@pdfborder| (default: rectangle with \hbox{1\,pt line}
613 % thickness).\newline
614 % While link coloring is really ON, we thus emulate the behaviour
615 % of link coloring OFF, therefore we give this message:
616 %
617 % \begin{macrocode}
618 \PackageInfo{hrefhide}{OCG-link coloring OFF (sort of; hrefhide package)%
619 \MessageBreak}%
620 \else%
621 \PackageWarning{hrefhide}{\string\hycoff\space called when OCG-link %
622 coloring was not ON\MessageBreak%
623 - nothing done}%
624 \fi%
625 }
626
627 % \end{macrocode}
628 % Nevertheless, all restrictions of |ocgcolorlinks|, e.\,g.~no links breaking
629 % over lines, still prevail!
630 % \end{macro}
631 %
632 % \begin{macro}{\hrefdisplayonly}
633 % The command |\hrefdisplayonly| is defined:
634 % \begin{macrocode}
635 \DeclareRobustCommand{\hrefdisplayonly}[2]{%
636 {\color{\hrefhide@backgroundcolour}\href{#1}{#2}}}
637
638 % \end{macrocode}
639 % \noindent which just sets the color of the link to |\hrefhide@backgroundcolour|
640 % for printing, thereby turning it \textquotedblleft invisible\textquotedblright.
641 % \end{macro}
642 %
643 % \DescribeMacro{\AddToHook\{begindocument\}}
644 % \begin{macrocode}
645 \AddToHook{begindocument}{%
646 % \end{macrocode}
647 % \indent Here it is checked whether the \xpackage{hyperref} package
648 % was loaded with option \texttt{ocgcolorlinks}. (\xpackage{hrefhide} calls it
649 % with option |ocgcolorlinks| (i.\,e. |=true|), but in the preamble it would
650 % be possible to really turn it off again by |\hypersetup{ocgcolorlinks=false}|.
651 % This \xpackage{hrefhide} package needs the \xpackage{hyperref} package with option
652 % \texttt{ocgcolorlinks}. If package and/or option are/is missing, the appropriate
653 % error message is given.
654 %
655 % \begin{macrocode}
656 \IfPackageLoadedWithOptionsTF{hyperref}{ocgcolorlinks}{\hrefhidetrue}{%
657 \hrefhidefalse%
658 \PackageError{hrefhide}{hyperref package missing option ocgcolorlinks}{%
659 The package hrefhide needs the hyperref package\MessageBreak%
660 with option ocgcolorlinks.\MessageBreak%
661 That option is missing!\MessageBreak%
662 Now the link(s) will be ''hidden'' in pdf view also.\MessageBreak%
663 }%
664 }%
665 % \end{macrocode}
666 %
667 % \noindent We check whether |\Hy@driver| is |hpdftex|, i.\,e.~a~\xext{pdf}-file
668 % is in production.
669 %
670 % \begin{macrocode}
671 \def\hrefhide@driver{hpdftex}%
672 \ifx\Hy@driver\hrefhide@driver\relax%
673 \else%
674 % \end{macrocode}
675 %
676 % \noindent If this is not the case (for example for a \xext{dvi}-file),
677 % the error message is given.
678 %
679 % \begin{macrocode}
680 \PackageError{hrefhide}{Producing not a pdf file}{%
681 The package hrefhide only works for a pdf file,\MessageBreak%
682 but driver \Hy@driver\space instead of \hrefhide@driver\space%
683 was found.\MessageBreak%
684 Use pdfLaTeX to compile your document.\MessageBreak%
685 (Probably no large harm was done, but the respective\MessageBreak%
686 link text will neither be hidden when printing.)\MessageBreak%
687 }%
688 \fi%
689 % \end{macrocode}
690 %
691 % Because we need link coloring, we use option \texttt{ocgcolorlinks},
692 % but because we do not want colored links, we emulate the behaviour
693 % of link coloring OFF, therefore |\hycoff| is used at the beginning:
694 % \begin{macrocode}
695 \hycoff%
696 }
697
698 %</package>
699 % \end{macrocode}
700 % \newpage
701 %
702 % \section{Installation}
703 % \subsection{Downloads\label{ss:Downloads}}
704 % Everything is available at \url{https://www.ctan.org},
705 % but may need additional packages themselves.\bigskip
706 %
707 % \DescribeMacro{hrefhide.dtx}
708 % For unpacking the |hrefhide.dtx| file and constructing the documentation
709 % it is required:
710 % \begin{description}
711 % \item[-] \TeX Format \LaTeXe{} 2024-11-01 or newer: \url{https://www.CTAN.org}
712 %
713 % \item[-] document class \xclass{ltxdoc}, 2024/02/08, v2.1j,
714 % \url{https://www.ctan.org/pkg/ltxdoc}
715 %
716 % \item[-] package \xpackage{holtxdoc}, 2019/12/09, v0.30,
717 % \url{https://www.ctan.org/pkg/holtxdoc}
718 % \end{description}
719 %
720 % \DescribeMacro{hrefhide.sty}
721 % The |hrefhide.sty| for \LaTeXe{} (i.\,e. each document using
722 % the \xpackage{hrefhide} package) requires:
723 % \begin{description}
724 % \item[-] \TeX{} Format \LaTeXe{} 2024-11-01 or newer, \url{https://www.CTAN.org}
725 %
726 % \item[-] package \xpackage{xcolor}, 2024/09/29, v3.02,
727 % \url{https://www.ctan.org/pkg/xcolor}
728 %
729 % \item[-] package \xpackage{hyperref}, 2024-11-05, v7.01l,
730 % \url{https://www.ctan.org/pkg/hyperref}
731 %
732 % \item[-] package \xpackage{hrefhide}, 2025-01-27, v1.1b,
733 % \url{https://www.ctan.org/pkg/hrefhide}
734 % (Because you are reading the documentation for the
735 % \xpackage{hrefhide} package, it can be assumed that you already
736 % have some version of it~-- is it the current one?)
737 % \end{description}
738 %
739 % \DescribeMacro{hrefhide-example.tex}
740 % The |hrefhide-example.tex| requires the same files as all
741 % documents using the \xpackage{hrefhide} package
742 % (see preceding paragraph |hrefhide.sty|) and additionally:
743 % \begin{description}
744 % \item[-] class \xpackage{article}, 2024/06/29, v1.4n, from \xpackage{classes}:
745 % \url{https://ctan.org/pkg/classes}
746 %
747 % \item[-] package \xpackage{lipsum}, 2021-09-20, v2.7,
748 % \url{https://www.ctan.org/pkg/lipsum}\newline
749 % This package is only needed for some blind text.
750 % \end{description}
751 %
752 % \DescribeMacro{Alternatives}
753 % As possible alternatives in section~\ref{s:Alternatives}, Alternatives,
754 % there are listed (newer versions might be available):
755 % \begin{description}
756 % \item[-] package \xpackage{hyperref}, 2023-02-07, v7.00v,
757 % \url{https://www.ctan.org/pkg/hyperref}
758 % with option |ocgcolorlinks| and |{\color{white}\href{...}{...}}|.
759 %
760 % \item[-] package \xpackage{pdfcomment}, 2024-11-05, v7.01l,
761 % \url{https://www.ctan.org/pkg/pdfcomment}
762 % for text \textbf{outside} of links
763 %
764 % \item[-] package \xpackage{ocgx2}, 2024-09-16, v060,
765 % \url{https://www.ctan.org/pkg/ocgx2}
766 % \end{description}
767 %
768 % \DescribeMacro{Oberdiek}
769 % \DescribeMacro{holtxdoc}
770 % All packages of the `oberdiek' bundle
771 % (especially \xpackage{holtxdoc}) are also available in a TDS compliant ZIP archive:\newline
772 % \url{https://mirror.ctan.org/install/macros/latex/contrib/oberdiek.tds.zip}.\newline
773 % It is probably best to download and use this, because the packages in there
774 % are quite probably both recent and compatible among themselves.\bigskip
775 %
776 % \DescribeMacro{hyperref}
777 % \noindent \xpackage{hyperref} is not included in that bundle and needs to be
778 % downloaded separately,\newline
779 % \url{https://mirror.ctan.org/install/macros/latex/contrib/hyperref.tds.zip}.\bigskip
780 %
781 % \DescribeMacro{Münch}
782 % A hyperlinked list of my (other) packages can be found at\newline
783 % \url{https://www.ctan.org/author/muench-hm}.
784 %
785 % \subsection{Package, unpacking TDS}
786 % \paragraph{Package.} This package is available on \url{https://www.CTAN.org}.
787 % \begin{description}
788 % \item[\url{https://mirror.ctan.org/macros/latex/contrib/hrefhide/hrefhide.dtx}]\hspace*{0.1cm}\newline
789 % The source file.
790 % \item[\url{https://mirror.ctan.org/macros/latex/contrib/hrefhide/hrefhide.pdf}]\hspace*{0.1cm}\newline
791 % The documentation.
792 % \item[\url{https://mirror.ctan.org/macros/latex/contrib/hrefhide/hrefhide-example.pdf}]\hspace*{0cm}%
793 % The compiled example file, as it should look like.
794 % \item[\url{https://mirror.ctan.org/macros/latex/contrib/hrefhide/README}]\hspace*{0.1cm}\newline
795 % The README file.
796 % \end{description}
797 %
798 % There is also a |hrefhide.tds.zip| available:
799 % \begin{description}
800 % \item[\url{https://mirror.ctan.org/install/macros/latex/contrib/hrefhide.tds.zip}]\hspace*{0cm}%
801 % Everything in TDS compliant, compiled format.
802 % \end{description}
803 % which additionally contains\newline
804 % \begin{tabular}{ll}
805 % hrefhide.ins & The installation file.\\
806 % hrefhide.drv & The driver to generate the documentation.\\
807 % hrefhide.sty & The \xext{sty}le file.\\
808 % hrefhide-example.tex & The example file.
809 % \end{tabular}
810 %
811 % \bigskip
812 %
813 % \noindent For required other packages, please see the preceding subsection.
814 %
815 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
816 % \docstrip{} archive. The files are extracted by running the
817 % \xext{.dtx} through \plainTeX{}:
818 % \begin{quote}
819 % \verb|tex hrefhide.dtx|
820 % \end{quote}
821 %
822 % About generating the documentation see paragraph~\ref{GenDoc} below.\bigskip
823 %
824 % \paragraph{TDS.} Now the different files must be moved into
825 % the different directories in your installation TDS tree
826 % (also known as \xfile{texmf} tree):
827 % \begin{quote}
828 % \def\t{^^A
829 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
830 % hrefhide.sty & tex/latex/hrefhide.sty\\
831 % hrefhide.pdf & doc/latex/hrefhide.pdf\\
832 % hrefhide-example.tex & doc/latex/hrefhide-example.tex\\
833 % hrefhide-example.pdf & doc/latex/hrefhide-example.pdf\\
834 % hrefhide.dtx & source/latex/hrefhide.dtx\\
835 % \end{tabular}^^A
836 % }^^A
837 % \sbox0{\t}^^A
838 % \ifdim\wd0>\linewidth
839 % \begingroup
840 % \advance\linewidth by\leftmargin
841 % \advance\linewidth by\rightmargin
842 % \edef\x{\endgroup
843 % \def\noexpand\lw{\the\linewidth}^^A
844 % }\x
845 % \def\lwbox{^^A
846 % \leavevmode
847 % \hbox to \linewidth{^^A
848 % \kern-\leftmargin\relax
849 % \hss
850 % \usebox0
851 % \hss
852 % \kern-\rightmargin\relax
853 % }^^A
854 % }^^A
855 % \ifdim\wd0>\lw
856 % \sbox0{\small\t}^^A
857 % \ifdim\wd0>\linewidth
858 % \ifdim\wd0>\lw
859 % \sbox0{\footnotesize\t}^^A
860 % \ifdim\wd0>\linewidth
861 % \ifdim\wd0>\lw
862 % \sbox0{\scriptsize\t}^^A
863 % \ifdim\wd0>\linewidth
864 % \ifdim\wd0>\lw
865 % \sbox0{\tiny\t}^^A
866 % \ifdim\wd0>\linewidth
867 % \lwbox
868 % \else
869 % \usebox0
870 % \fi
871 % \else
872 % \lwbox
873 % \fi
874 % \else
875 % \usebox0
876 % \fi
877 % \else
878 % \lwbox
879 % \fi
880 % \else
881 % \usebox0
882 % \fi
883 % \else
884 % \lwbox
885 % \fi
886 % \else
887 % \usebox0
888 % \fi
889 % \else
890 % \lwbox
891 % \fi
892 % \else
893 % \usebox0
894 % \fi
895 % \end{quote}
896 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
897 % TDS installing feature, then some files can already be in the right
898 % place, see the documentation of \docstrip{}.
899 %
900 % \subsection{Refresh file name databases}
901 %
902 % If your \TeX~distribution (\TeX\,Live, \mikTeX, \dots) relies on
903 % file name databases, you must refresh these. For example, \TeX\,Live\ users
904 % run \verb|texhash| or \verb|mktexlsr|.
905 %
906 % \subsection{Some details for the interested}
907 %
908 % \paragraph{Unpacking with \LaTeX{}.}
909 % The \xfile{.dtx} chooses its action depending on the format:
910 % \begin{description}
911 % \item[\plainTeX:] Run \docstrip{} and extract the files.
912 % \item[\LaTeX:] Generate the documentation.
913 % \end{description}
914 % If you insist on using \LaTeX{} for \docstrip{} (really,
915 % \docstrip{} does not need \LaTeX ), then inform the autodetect routine
916 % about your intention:
917 % \begin{quote}
918 % \verb|latex \let\install=y\input{hrefhide.dtx}|
919 % \end{quote}
920 % Do not forget to quote the argument according to the demands
921 % of your shell.
922 %
923 % \paragraph{Generating the documentation.\label{GenDoc}}
924 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
925 % the documentation. The process can be configured by a
926 % configuration file \xfile{ltxdoc.cfg}. For instance, put the following
927 % line into this file, if you want to have A4 as paper format:
928 % \begin{quote}
929 % \verb|\PassOptionsToClass{a4paper}{article}|
930 % \end{quote}
931 %
932 % \noindent An example follows how to generate the
933 % documentation with \pdfLaTeX :
934 %
935 % \begin{quote}
936 %\begin{verbatim}
937 %pdflatex hrefhide.dtx
938 %makeindex -s gind.ist hrefhide.idx
939 %pdflatex hrefhide.dtx
940 %makeindex -s gind.ist hrefhide.idx
941 %pdflatex hrefhide.dtx
942 %\end{verbatim}
943 % \end{quote}
944 %
945 % \subsection{Compiling the example}
946 %
947 % The example file, \textsf{hrefhide-example.tex}, can be compiled via\newline
948 % \indent |pdflatex hrefhide-example.tex|\newline
949 % (but \textbf{not} |latex hrefhide-example.tex|!)\newline
950 % and will need at least two compiler runs to get all references right.
951 %
952 % \section{Acknowledgements}
953 %
954 % I would like to thank \textsc{Heiko Oberdiek} for providing a lot of
955 % useful packages (from which I also got everything I know about creating
956 % a file in \xext{dtx} format, ok, say it: copying).
957 %
958 % \phantomsection
959 % \begin{History}\label{History}
960 % \begin{Version}{2010/02/18 v0.1}
961 % \item First idea about this as a reply of mine to a question on
962 % \Newsgroup{comp.text.tex} (Subject: "Hiding" interactive parts of pdf when printing), see e.\,g.
963 % \url{https://groups.google.com/g/comp.text.tex/c/JGXs0n2UUhw/m/o9c3KL_u2YAJ}.
964 % \end{Version}
965 % \begin{Version}{2010/06/01 v1.0(a)}
966 % \item First version of the \xpackage{hrefhide} package.
967 % \end{Version}
968 % \begin{Version}{2010/06/03 v1.0b}
969 % \item Example adapted to other examples of mine.
970 % \item Updated references to other packages.
971 % \item TDS locations updated.
972 % \item Several changes in the documentation and the Readme file.
973 % \end{Version}
974 % \begin{Version}{2010/06/24 v1.0c}
975 % \item \xpackage{pdfcomment} package listed as alternative for text \textbf{outside}
976 % of hyperlinks.
977 % \item \xpackage{holtxdoc} warning in \xfile{drv} updated.
978 % \item Corrected the location of the package at CTAN.\newline
979 % (In that version \xfile{TDS} was still missing due to packaging error.)
980 % \item Updated reference to other package: \xpackage{hyperref}.
981 % \end{Version}
982 % \begin{Version}{2010/07/29 v1.0d}
983 % \item Corrected given url of \texttt{hrefhide.tds.zip} and other urls.
984 % \item Included a url for the newsgroup post (in History).
985 % \item Included a |\CheckSum| [later removed].
986 % \end{Version}
987 % \begin{Version}{2011/02/01 v1.0e}
988 % \item Changed the |\unit| definition (got rid of an old |\rm|).\newline
989 % {}[Removed in version 1.1a.]
990 % \item Moved the package from \texttt{.../latex/muench/hrefhide/...} to\newline
991 % \texttt{.../latex/hrefhide/...}.
992 % \end{Version}
993 % \begin{Version}{2011/04/29 v1.0f}
994 % \item The \xpackage{holtxdoc} package was fixed (then: 2011/02/04, v0.21), therefore
995 % the warning in \xfile{drv} could be removed.~-- Adapted the style of this
996 % documentation to new \textsc{Oberdiek} \xfile{dtx} style.
997 % \item Removed the \textsf{ltxdoc.cfg} file for the documentation.
998 % \item Bug fix: The previous versions only hide links of type
999 % \textquotedblleft link\textquotedblright. Now the types citation, page reference,
1000 % URL, local file reference, and \textquotedblleft other links\textquotedblright-type
1001 % are \textquotedblleft hidden\textquotedblright.
1002 % \item With |\hycon| and |\hycoff| it is now possible to \emph{simulate} the switching
1003 % on/off of~|ocgcolorlinks| in the document.
1004 % \item Instead of \xpackage{color} now the \xpackage{xcolor} package is used.
1005 % \item A lot of details.
1006 % \end{Version}
1007 % \begin{Version}{2023-02-26 v1.1a}
1008 % \item Made the |\newcommand|s robust.
1009 % \item Removed |\unit|.
1010 % \item Converted to UTF-8.
1011 % \item Updated to [then] current \LaTeX{} format.
1012 % \item Extensive updates of the Documentation and README.
1013 % \end{Version}
1014 % \begin{Version}{2025-01-27 v1.1b}
1015 % \item No longer loads \xpackage{kvotions} (but \xpackage{hyperref} does).
1016 % \item Updates of the documentation.
1017 % \end{Version}
1018 % \end{History}
1019 %
1020 % \bigskip
1021 %
1022 % When you find a mistake or have a suggestion for an improvement of this package,
1023 % please send an e-mail to the maintainer, thanks! (Please see BUG REPORTS in the README.)
1024 %
1025 % \PrintIndex
1026 %
1027 % \Finale
1028 \endinput