summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/hrefhide/hrefhide.sty
blob: 6ff837382b836af6fbe159772d124803fc20e332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
%%
%% This is file `hrefhide.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hrefhide.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: hrefhide
%% Version: 2011/04/29 v1.0f
%% 
%% Copyright (C) 2010, 2011 by
%%     H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
%% 
%% The usual disclaimer applys:
%% If it doesn't work right that's your problem.
%% (Nevertheless, send an e-mail to the maintainer
%%  when you find an error in this package.)
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is H.-Martin Muench.
%% 
%% This work consists of the main source file hrefhide.dtx
%% and the derived files
%%    hrefhide.sty, hrefhide.pdf, hrefhide.ins, hrefhide.drv,
%%    hrefhide-example.tex.
%% 
\NeedsTeXFormat{LaTeX2e}[2009/09/24]
\ProvidesPackage{hrefhide}[2011/04/29 v1.0f
            Hiding hyperrefs when printing pdf files (HMM)]%

%% Allows to "hide" hyperlinked text in a pdf file when printing
%% ("Klick here" does not work on real paper)
%% by providing the command \hrefdisplayonly
%% and allows simulating to switch on/off ocgcolourlinks
%% of the hyperref package by Heiko Oberdiek.

\RequirePackage{xcolor}[2007/01/21]% v2.11
\RequirePackage[ocgcolorlinks]{hyperref}[2011/04/17]% v6.82g
\RequirePackage{kvoptions}[2010/12/23]% v3.10
%% hrefhide may work with earlier versions of LaTeX and those
%% packages, but this was not tested. Please consider updating
%% your LaTeX and packages to the most recent version
%% (if they are not already the most recent version).

\SetupKeyvalOptions{family = hrefhide, prefix = hrefhide@}
\DeclareStringOption[black]{linktextcolour}[black]
\DeclareStringOption[white]{backgroundcolour}[white]
\DeclareStringOption[{0 0 1}]{pdfborder}[{0 0 1}]

\ProcessKeyvalOptions*

\gdef\hrefhide@status@ON{ON}
\gdef\hrefhide@status@OFF{OFF}

\newcommand{\hycon}{%
\ifx\hrefhide@status\hrefhide@status@OFF%
\@ifundefined{@anchorbordercolor}{%
\hypersetup{anchorcolor=\hrefhide@anchorbordercolor}%
}{%
\definecolor{hyanchorbordercolor}{rgb}{\@anchorbordercolor}%
\hypersetup{anchorcolor=hyanchorbordercolor}%
}%
\definecolor{hycitebordercolor}{rgb}{\@citebordercolor}%
\hypersetup{citecolor=hycitebordercolor}%
\definecolor{hyfilebordercolor}{rgb}{\@filebordercolor}%
\hypersetup{filecolor=hyfilebordercolor}%
\definecolor{hylinkbordercolor}{rgb}{\@linkbordercolor}%
\hypersetup{linkcolor=hylinkbordercolor}%
\definecolor{hymenubordercolor}{rgb}{\@menubordercolor}%
\hypersetup{menucolor=hymenubordercolor}%
\definecolor{hyrunbordercolor}{rgb}{\@runbordercolor}%
\hypersetup{runcolor=hyrunbordercolor}%
\definecolor{hyurlbordercolor}{rgb}{\@urlbordercolor}%
\hypersetup{urlcolor=hyurlbordercolor}%
\hypersetup{pdfborder=0 0 0}%
\gdef\hrefhide@status{ON}%
\PackageInfo{hrefhide}{OCG-link colouring ON\MessageBreak}%
\else%
\PackageWarning{hrefhide}{\string\hycon\space called when OCG-link colouring was not OFF \MessageBreak%
- nothing done}%
\fi%
}

\newcommand{\hycoff}{%
\ifx\hrefhide@status\hrefhide@status@ON%
\@ifundefined{@anchorbordercolor}{%
\global\edef\hrefhide@anchorbordercolor{\@anchorcolor}%
}{%
\hypersetup{anchorbordercolor=\@anchorcolor}%
}%
\hypersetup{anchorcolor=\hrefhide@linktextcolour}%
\hypersetup{citebordercolor=\@citecolor}%
\hypersetup{citecolor=\hrefhide@linktextcolour}%
\hypersetup{filebordercolor=\@filecolor}%
\hypersetup{filecolor=\hrefhide@linktextcolour}%
\hypersetup{linkbordercolor=\@linkcolor}%
\hypersetup{linkcolor=\hrefhide@linktextcolour}%
\hypersetup{menubordercolor=\@menucolor}%
\hypersetup{menucolor=\hrefhide@linktextcolour}%
\hypersetup{runbordercolor=\@runcolor}%
\hypersetup{runcolor=\hrefhide@linktextcolour}%
\hypersetup{urlbordercolor=\@urlcolor}%
\hypersetup{urlcolor=\hrefhide@linktextcolour}%
\hypersetup{pdfborder=\hrefhide@pdfborder}%
\gdef\hrefhide@status{OFF}%
\PackageInfo{hrefhide}{OCG-link colouring OFF (sort of; hrefhide package)\MessageBreak}%
\else%
\PackageWarning{hrefhide}{\string\hycoff\space called when OCG-link colouring was not ON \MessageBreak%
- nothing done}%
\fi%
}

\newcommand{\hrefdisplayonly}[2]{%
{\color{\hrefhide@backgroundcolour}\href{#1}{#2}}%
}

\AtBeginDocument{%
  \ifHy@ocgcolorlinks%
    \gdef\hrefhide@status{ON}%
  \else%
    \gdef\hrefhide@status{OFF}%
    \PackageError{hrefhide}{hyperref package missing option ocgcolorlinks}{%
      The package hrefhide needs the hyperref package\MessageBreak%
      with option ocgcolorlinks.\MessageBreak%
      That option is missing!\MessageBreak%
      Now the link(s) will be ''hidden'' in pdf view also.\MessageBreak%
      }%
  \fi%
  \def\hrefhide@driver{hpdftex}%
  \ifx\Hy@driver\hrefhide@driver% \relax
  \else%
    \PackageError{hrefhide}{Producing not a pdf file}{%
      The package hrefhide only works for a pdf file,\MessageBreak%
      but driver \Hy@driver\space instead of \hrefhide@driver\space was found.\MessageBreak%
      Use pdfLaTeX to compile your document.\MessageBreak%
      (Probably no large harm was done, but the respective\MessageBreak%
       link text will neither be hidden when printing.)\MessageBreak%
      }%
  \fi%
  \hycoff%
  }

\endinput
%%
%% End of file `hrefhide.sty'.