| 1 |
% \iffalse THIS IS A META-COMMENT |
| 2 |
%<*dtx> |
| 3 |
\ProvidesFile |
| 4 |
%======================================================================== |
| 5 |
{XCPDFTIPS.DTX} |
| 6 |
%======================================================================== |
| 7 |
%</dtx> |
| 8 |
%% Copyright (c) 2019 Mikica Kocic |
| 9 |
% |
| 10 |
% This program is free software: you can redistribute it and/or modify |
| 11 |
% it under the terms of the GNU General Public License as published by |
| 12 |
% the Free Software Foundation, either version 3 of the License, or |
| 13 |
% (at your option) any later version. |
| 14 |
% |
| 15 |
% This program is distributed in the hope that it will be useful, |
| 16 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
% GNU General Public License for more details. |
| 19 |
% |
| 20 |
% You should have received a copy of the GNU General Public License |
| 21 |
% along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 22 |
% |
| 23 |
% This is a contributed file to the LaTeX2e system. |
| 24 |
% ------------------------------------------------- |
| 25 |
% This is a LaTeX package to do citations with PDF tooltips. |
| 26 |
% Installation: |
| 27 |
% LaTeX this file: creates docstrip installation file xcpdftips.ins |
| 28 |
% AND the LaTeX documentation |
| 29 |
% (La)TeX xcpdftips.ins: creates package file xcpdftips.sty, and optionally |
| 30 |
% the documentation driver xcpdftips.drv |
| 31 |
% (xcpdftips.ins and xcpdftips.drv may be edited as needed) |
| 32 |
% Docstrip options available: |
| 33 |
% package - to produce a (LaTeX2e) package .sty file |
| 34 |
% driver - to produce a driver file to print the documentation |
| 35 |
%-------------------------------------------------------------------------- |
| 36 |
% |
| 37 |
% *** Identify the package file:- |
| 38 |
%<package> |
| 39 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 40 |
%<package> |
| 41 |
%<package>\ProvidesPackage{xcpdftips} |
| 42 |
%<package>[2019/03/18 xcpdftips.sty v1.1 - (c) 2019 Mikica Kocic] |
| 43 |
%<package> |
| 44 |
%<package>\RequirePackage{bibentry} |
| 45 |
%<package>\RequirePackage{pdfcomment} |
| 46 |
%<package>\RequirePackage{xparse} |
| 47 |
%<package>\RequirePackage{etoolbox} |
| 48 |
% |
| 49 |
% *** Identify the driver file:- |
| 50 |
% |
| 51 |
%<driver>\NeedsTeXFormat{LaTeX2e} |
| 52 |
%<driver>\ProvidesFile{xcpdftips.drv} |
| 53 |
% |
| 54 |
% *** The DATE, VERSION, and other INFO |
| 55 |
% |
| 56 |
%\fi |
| 57 |
%\ProvidesFile{xcpdftips}[2019/03/18 1.1 (MK)] |
| 58 |
% \changes{1.0}{2019 Mar 10}{Initial version} |
| 59 |
% \changes{1.1}{2019 Mar 18}{Added support for PDF OCG} |
| 60 |
% |
| 61 |
% \CheckSum{282} |
| 62 |
% |
| 63 |
% \CharacterTable |
| 64 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 65 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 66 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 67 |
% Exclamation \! Double quote \" Hash (number) \# |
| 68 |
% Dollar \$ Percent \% Ampersand \& |
| 69 |
% Acute accent \' Left paren \( Right paren \) |
| 70 |
% Asterisk \* Plus \+ Comma \, |
| 71 |
% Minus \- Point \. Solidus \/ |
| 72 |
% Colon \: Semicolon \; Less than \< |
| 73 |
% Equals \= Greater than \> Question mark \? |
| 74 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 75 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 76 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 77 |
% Right brace \} Tilde \~} |
| 78 |
% |
| 79 |
% \iffalse |
| 80 |
%<*install> |
| 81 |
% |
| 82 |
%^^A ============================================= |
| 83 |
%^^A Here is the docstrip installation file |
| 84 |
%^^A It is written on first LaTeX run if it |
| 85 |
%^^A does not already exist |
| 86 |
%^^A ============================================= |
| 87 |
% |
| 88 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 89 |
\begin{filecontents*}{xcpdftips.ins} |
| 90 |
% |
| 91 |
% File: xcpdftips.ins |
| 92 |
% |
| 93 |
% Copyright (c) 2019 Mikica Kocic |
| 94 |
% |
| 95 |
% This program is free software: you can redistribute it and/or modify |
| 96 |
% it under the terms of the GNU General Public License as published by |
| 97 |
% the Free Software Foundation, either version 3 of the License, or |
| 98 |
% (at your option) any later version. |
| 99 |
% |
| 100 |
% This program is distributed in the hope that it will be useful, |
| 101 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 102 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 103 |
% GNU General Public License for more details. |
| 104 |
% |
| 105 |
% You should have received a copy of the GNU General Public License |
| 106 |
% along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 107 |
% |
| 108 |
% It is an installation file for extracting package and driver |
| 109 |
% files from the original source file. Simply process it under |
| 110 |
% TeX or LaTeX. It works with Docstrip versions before and after |
| 111 |
% December 1995. |
| 112 |
|
| 113 |
\def\batchfile{xcpdftips.ins} |
| 114 |
\input docstrip |
| 115 |
|
| 116 |
\preamble |
| 117 |
|
| 118 |
============================================= |
| 119 |
IMPORTANT NOTICE: |
| 120 |
|
| 121 |
This program is free software: you can redistribute it and/or modify |
| 122 |
it under the terms of the GNU General Public License as published by |
| 123 |
the Free Software Foundation, either version 3 of the License, or |
| 124 |
(at your option) any later version. |
| 125 |
|
| 126 |
This program is distributed in the hope that it will be useful, |
| 127 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 128 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 129 |
GNU General Public License for more details. |
| 130 |
|
| 131 |
You should have received a copy of the GNU General Public License |
| 132 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 133 |
|
| 134 |
This is a generated file. |
| 135 |
It may not be distributed without the original source file \inFileName. |
| 136 |
|
| 137 |
Full documentation can be obtained by LaTeXing that original file. |
| 138 |
Only a few abbreviated comments remain here to describe the usage. |
| 139 |
============================================= |
| 140 |
|
| 141 |
\endpreamble |
| 142 |
\postamble |
| 143 |
|
| 144 |
<<<<< End of generated file <<<<<< |
| 145 |
|
| 146 |
\endpostamble |
| 147 |
\keepsilent |
| 148 |
|
| 149 |
% Docstrip before Dec 95 does not have \generate syntax, nor |
| 150 |
% \declarepreamble. Must redefine them. The \generateFile called |
| 151 |
% for each output file individually. |
| 152 |
% Docstrip before Dec 96 cannot interprete multiline \if..\fi |
| 153 |
% Thus for maximum compatibility, have only one-line conditionals |
| 154 |
|
| 155 |
\let\oldDS F\relax |
| 156 |
\expandafter\ifx\csname generate\endcsname\relax \let\oldDS T\relax\fi |
| 157 |
\if\oldDS T \def\declarepreamble#1{\preamble}\fi |
| 158 |
\if\oldDS T \def\declarepostamble#1{\postamble}\fi |
| 159 |
\if\oldDS T \generateFile{xcpdftips.sty}{f}{\from{xcpdftips.dtx}{package}} \fi |
| 160 |
|
| 161 |
\declarepreamble\driver |
| 162 |
============================================ |
| 163 |
This is the driver file to produce the LaTeX documentation |
| 164 |
from the original source file \inFileName. |
| 165 |
|
| 166 |
Make changes to it as needed. (Never change the file \inFileName!) |
| 167 |
============================================ |
| 168 |
\endpreamble |
| 169 |
|
| 170 |
\declarepostamble\driverq |
| 171 |
|
| 172 |
End of documentation driver file. |
| 173 |
\endpostamble |
| 174 |
|
| 175 |
\ifx\oldDS T \generateFile{xcpdftips.drv}{f}{\from{xcpdftips.dtx}{driver}}\fi |
| 176 |
|
| 177 |
\ifx\oldDS T \let\askforoverwritefalse\relax\def\generate#1{}\fi |
| 178 |
|
| 179 |
\askforoverwritefalse |
| 180 |
\generate{\file{xcpdftips.sty}{\from{xcpdftips.dtx}{package}} |
| 181 |
\file{xcpdftips.drv}{\usepreamble\driver\usepostamble\driverq |
| 182 |
\from{xcpdftips.dtx}{driver}} |
| 183 |
} |
| 184 |
|
| 185 |
\obeyspaces |
| 186 |
\Msg{********************************************}% |
| 187 |
\Msg{* For documentation, process xcpdftips.dtx *}% |
| 188 |
\Msg{* or the driver file xcpdftips.drv *}% |
| 189 |
\Msg{********************************************} |
| 190 |
\end{filecontents*} |
| 191 |
%</install> |
| 192 |
%<*driver> |
| 193 |
\documentclass[a4paper]{ltxdoc} |
| 194 |
%<driver>%\documentclass[twoside]{ltxdoc} |
| 195 |
%<driver>%\documentclass[a4paper]{ltxdoc} |
| 196 |
%<driver>%\documentclass[twoside,a4paper]{ltxdoc} |
| 197 |
\raggedbottom |
| 198 |
|
| 199 |
%** To include the detailed explanation of the coding, comment out |
| 200 |
%** the next line |
| 201 |
% \OnlyDescription |
| 202 |
|
| 203 |
%** To produce a command index: add the following line for one run, |
| 204 |
%** then run makeindex -s gind.ist xcpdftips |
| 205 |
%** and reprocess, with or without this line (much faster without) |
| 206 |
%<driver>% \EnableCrossrefs\CodelineIndex |
| 207 |
|
| 208 |
%** To produce a change history: add the following line for one run, |
| 209 |
%** then run makeindex -s gglo.ist -o xcpdftips.gls xcpdftips.glo |
| 210 |
%** and reprocess, with or without this line (faster without) |
| 211 |
%<driver>% \RecordChanges |
| 212 |
|
| 213 |
\DisableCrossrefs %May stay; zapped by \EnableCrossrefs |
| 214 |
\CodelineNumbered %May stay |
| 215 |
|
| 216 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 217 |
\begin{document} |
| 218 |
\DocInput{xcpdftips.dtx} |
| 219 |
\end{document} |
| 220 |
%</driver> |
| 221 |
%\fi |
| 222 |
% |
| 223 |
% \DoNotIndex{\begin,\CodelineIndex,\CodelineNumbered,\def,\DisableCrossrefs} |
| 224 |
% \DoNotIndex{\DocInput,\documentclass,\EnableCrossrefs,\end,\GetFileInfo} |
| 225 |
% \DoNotIndex{\NeedsTeXFormat,\OnlyDescription,\RecordChanges,\usepackage} |
| 226 |
% \DoNotIndex{\ProvidesClass,\ProvidesPackage,\ProvidesFile,\RequirePackage} |
| 227 |
% \DoNotIndex{\filename,\fileversion,\filedate,\let} |
| 228 |
% \DoNotIndex{\@listctr,\@nameuse,\csname,\else,\endcsname,\expandafter} |
| 229 |
% \DoNotIndex{\gdef,\global,\if,\item,\newcommand,\nobibliography} |
| 230 |
% \DoNotIndex{\par,\providecommand,\relax,\renewcommand,\renewenvironment} |
| 231 |
% \DoNotIndex{\stepcounter,\usecounter,\nocite,\fi} |
| 232 |
% \DoNotIndex{\@fileswfalse,\@gobble,\@ifstar,\@unexpandable@protect} |
| 233 |
% \DoNotIndex{\AtBeginDocument,\AtEndDocument,\begingroup,\endgroup} |
| 234 |
% \DoNotIndex{\frenchspacing,\MessageBreak,\newif,\PackageWarningNoLine} |
| 235 |
% \DoNotIndex{\protect,\string,\xdef,\ifx,\texttt,\@biblabel,\bibitem} |
| 236 |
% |
| 237 |
% \setcounter{IndexColumns}{2} |
| 238 |
% \setlength{\IndexMin}{10cm} |
| 239 |
% \setcounter{StandardModuleDepth}{1} |
| 240 |
% |
| 241 |
% \GetFileInfo{xcpdftips} |
| 242 |
% |
| 243 |
% \title{\bfseries Citations with PDF tooltips} |
| 244 |
% |
| 245 |
% \author{Mikica Kocic} |
| 246 |
% |
| 247 |
% \date{\normalsize This paper describes package \texttt{\filename}\\[0.5ex] |
| 248 |
% version \fileversion{} from \filedate |
| 249 |
% } |
| 250 |
% |
| 251 |
% \maketitle |
| 252 |
% |
| 253 |
% \pagestyle{myheadings} |
| 254 |
% \markboth{M. Kocic}{PDF tooltips for natbib citations} |
| 255 |
% |
| 256 |
%^^A In order to keep all marginal notes on the one (left) side: |
| 257 |
%^^A (otherwise they switch sides disasterously with twoside option) |
| 258 |
% \makeatletter \@mparswitchfalse \makeatother |
| 259 |
% |
| 260 |
%\iffalse |
| 261 |
%<*package> |
| 262 |
% |
| 263 |
% PDF tooltips from natbib citations |
| 264 |
% |
| 265 |
%----------------------------------------------------------- |
| 266 |
% See documentation in the source .dtx file for more details. |
| 267 |
%</package> |
| 268 |
%\fi |
| 269 |
% |
| 270 |
% \section{Introduction} |
| 271 |
% |
| 272 |
% This package allows one to be able to do \texttt{natbib} citations |
| 273 |
% with PDF tooltips. |
| 274 |
% |
| 275 |
% \section{Invoking the Package} |
| 276 |
% |
| 277 |
% The macros in this package are included in the main document |
| 278 |
% with the |\usepackage| command of \LaTeXe, |
| 279 |
% \begin{quote} |
| 280 |
% |\documentclass[..]{...}|\\ |
| 281 |
% |\usepackage|\oarg{options}|{|\texttt{\filename}|}| |
| 282 |
% \end{quote} |
| 283 |
% where \oarg{options} is one of: |redefcite|, |ocg|, or |tcolorbox|. |
| 284 |
% |
| 285 |
% The option |redefcite| replaces |natbib|'s |\cite| with |\xcpdfcite|. |
| 286 |
% |
| 287 |
% The option |ocg| puts tooltips on PDF layers using OCG. |
| 288 |
% |
| 289 |
% If |ocg| is used and |tcolorbox| is enabled, the package will use |
| 290 |
% |\tcolorbox| instead of |\fcolorbox|. |
| 291 |
% |
| 292 |
% \section{Usage} |
| 293 |
% |
| 294 |
% \newcommand\btx{\textsc{Bib}\TeX} |
| 295 |
% |
| 296 |
% This package must be used with \btx{} and \texttt{natbib}, not with a |
| 297 |
% hand-written \texttt{thebibliography} environment. |
| 298 |
% More precisely, there must be a \texttt{.bbl} file external to the \LaTeX\ |
| 299 |
% file; whether this is written by hand or by \btx\ is unimportant. |
| 300 |
% \vspace{2ex} |
| 301 |
% |
| 302 |
% \DescribeMacro{\xpdfcite} |
| 303 |
% \noindent A replacement for \texttt{natbib}'s |\cite| macro.\\~ |
| 304 |
% |
| 305 |
% \noindent Similarly to |\cite|, the command |\xpdfcite| may take one or two |
| 306 |
% optional arguments to add some text before and after the citation, |
| 307 |
% |
| 308 |
% \begin{quote} |
| 309 |
% |\xpdfcite|\marg{key(s)}\\[0.2ex] |
| 310 |
% |\xpdfcite|\oarg{post}\marg{key(s)}\\[0.2ex] |
| 311 |
% |\xpdfcite|\oarg{pre}\oarg{post}\marg{key(s)} |
| 312 |
% \end{quote} |
| 313 |
% |
| 314 |
% \section{Caveats} |
| 315 |
% |
| 316 |
% The \texttt{\filename} package will work with |natbib| with its |
| 317 |
% native |\bibitem| format, and with standard \LaTeX. |
| 318 |
% It will also work with |url| package. |
| 319 |
% |
| 320 |
% The OCG support requires |ocgbase| and |pdfbase| versions $\ge$ 2018/04/06 |
| 321 |
% |
| 322 |
% Nothing else can be guaranteed. |
| 323 |
% |
| 324 |
% \StopEventually{\PrintIndex\PrintChanges} |
| 325 |
% |
| 326 |
% \section{Options with \texttt{docstrip}} |
| 327 |
% |
| 328 |
% The source \texttt{.dtx} file is meant to be processed with |
| 329 |
% \texttt{docstrip}, for which a number of options are available: |
| 330 |
% |
| 331 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 332 |
% \begin{description} |
| 333 |
% |
| 334 |
% \item[\ttfamily package] to produce a \texttt{.sty} package file with most |
| 335 |
% comments removed; |
| 336 |
% |
| 337 |
% \item[\ttfamily driver] to produce a driver \texttt{.drv} file that will |
| 338 |
% print out the documentation under \LaTeXe. The documentation cannot |
| 339 |
% be printed under \LaTeX~2.09. |
| 340 |
% |
| 341 |
% \end{description} |
| 342 |
% |
| 343 |
% The source file \texttt{\filename.dtx} is itself a driver file and can |
| 344 |
% be processed directly by \LaTeXe. |
| 345 |
% |
| 346 |
% \section{The Coding} |
| 347 |
% |
| 348 |
% This section presents and explains the actual coding of the macros. |
| 349 |
% It is nested between |%<*package>| and |%</package>|, which |
| 350 |
% are indicators to \texttt{docstrip} that this coding belongs to the package |
| 351 |
% file. |
| 352 |
% |
| 353 |
% \begin{macro}{Package options} |
| 354 |
% |
| 355 |
% |redefcite|, |ocg|, |tcolorbox| |
| 356 |
% |
| 357 |
% \begin{macrocode} |
| 358 |
\newif\ifXCP@redefcite\XCP@redefcitefalse |
| 359 |
\newif\ifXCP@useocg\XCP@useocgfalse |
| 360 |
\newif\ifXCP@usetcolorbox\XCP@usetcolorboxfalse |
| 361 |
|
| 362 |
\DeclareOption{redefcite}{\XCP@redefcitetrue} |
| 363 |
\DeclareOption{ocg}{\XCP@useocgtrue} |
| 364 |
\DeclareOption{tcolorbox}{\XCP@usetcolorboxtrue} |
| 365 |
|
| 366 |
\ProcessOptions\relax |
| 367 |
% \end{macrocode} |
| 368 |
% \end{macro} |
| 369 |
% |
| 370 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 371 |
% \begin{macro}{\XCP@tooltipbox} |
| 372 |
% |
| 373 |
% Command for creating a tooltip box on the OCG layer. |
| 374 |
% The arguments are the same as for |\fcolorbox|. |
| 375 |
% |
| 376 |
% \begin{macrocode} |
| 377 |
\ifXCP@useocg |
| 378 |
\ifXCP@usetcolorbox |
| 379 |
\ifx\tcolorbox\undefined |
| 380 |
\RequirePackage{tcolorbox} |
| 381 |
\fi |
| 382 |
\newcommand{\XCP@tooltipbox}[3]{% |
| 383 |
\begin{tcolorbox}[colframe=#1, colback=#2,% |
| 384 |
width=1.02\columnwidth, arc=2pt,% |
| 385 |
boxsep=2pt, top=0ex, bottom=0ex, left=0.1em, right=0.1em% |
| 386 |
]\normalfont\small #3\end{tcolorbox}% |
| 387 |
} |
| 388 |
\else |
| 389 |
\newcommand{\XCP@tooltipbox}[3]{% |
| 390 |
\fcolorbox{#1}{#2}% |
| 391 |
{\parbox[t]{\columnwidth}{\normalfont\small #3}}% |
| 392 |
} |
| 393 |
\fi |
| 394 |
\fi |
| 395 |
% \end{macrocode} |
| 396 |
% \end{macro} |
| 397 |
% |
| 398 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 399 |
% \begin{macro}{\XCP@ocgtooltip} |
| 400 |
% |
| 401 |
% Usage: |\XCP@ocgtooltip|\marg{link text}\oarg{tooltip box color}\marg{tooltip text} |
| 402 |
% |
| 403 |
% \noindent Warning: Requires |pdfbase| and |ocgbase| $>=$ 2018/04/06 |
| 404 |
% |
| 405 |
% \begin{macrocode} |
| 406 |
\ifXCP@useocg |
| 407 |
|
| 408 |
\RequirePackage{pdfbase,ocgbase} |
| 409 |
|
| 410 |
\RequirePackage{expl3} |
| 411 |
\RequirePackage{calc,linegoal} |
| 412 |
\RequirePackage{xcolor} |
| 413 |
|
| 414 |
% Check the required versions of pdfbase and ocgbase |
| 415 |
|
| 416 |
\ExplSyntaxOn |
| 417 |
|
| 418 |
\msg_set:nnnn{xcpdftips}{support~outdated}{ |
| 419 |
Support~package~`#1'~too~old. |
| 420 |
}{ |
| 421 |
Get~an~up~to~date~version~of~`#1'.\\Aborting. |
| 422 |
} |
| 423 |
\@ifpackagelater{pdfbase}{2018/04/06}{}{ |
| 424 |
\msg_error:nnn{xcpdftips}{support~outdated}{pdfbase.sty} |
| 425 |
\tex_endinput:D |
| 426 |
} |
| 427 |
\@ifpackagelater{ocgbase}{2018/04/06}{}{ |
| 428 |
\msg_error:nnn{xcpdftips}{support~outdated}{ocgbase.sty} |
| 429 |
\tex_endinput:D |
| 430 |
} |
| 431 |
|
| 432 |
\let\XCP@pdfLink\pbs_pdflink:nn % Alias for the pdflink from pdfbase |
| 433 |
|
| 434 |
\ExplSyntaxOff |
| 435 |
|
| 436 |
% Patch hyperref (make the PDF annotations OCG-aware) |
| 437 |
|
| 438 |
\ifx\Hy@setpdfborder\undefined\else |
| 439 |
\let\Hy@setpdfborderOrig\Hy@setpdfborder |
| 440 |
\def\Hy@setpdfborder{\ocgbase@insert@oc\Hy@setpdfborderOrig}% |
| 441 |
\fi |
| 442 |
|
| 443 |
\newsavebox{\XCP@tipText} % Temporary savebox |
| 444 |
\newlength{\XCP@hOffset} \setlength\XCP@hOffset{-0.1em} |
| 445 |
\newlength{\XCP@vOffset} \setlength\XCP@vOffset{0.2ex} |
| 446 |
\newlength{\XCP@lineGoal} |
| 447 |
|
| 448 |
\NewDocumentCommand{\XCP@ocgtooltip}{% |
| 449 |
m % link text |
| 450 |
O{yellow!5} % tooltip box color |
| 451 |
m % tooltip text |
| 452 |
}{{% |
| 453 |
\leavevmode% |
| 454 |
% Create a new PDF layer |
| 455 |
\ocgbase@new@ocg{ref [\XCP@keys]}{% |
| 456 |
/Print<</PrintState/OFF>> % |
| 457 |
/Export<</ExportState/OFF>> % |
| 458 |
/View<</ViewState/OFF>> % |
| 459 |
}{invisible}% |
| 460 |
\edef\XCP@currentOcg{\ocgbase@last@ocg}% |
| 461 |
% Insert the PDF layer into the order hierarchy (shown in the 'Layers' tab) |
| 462 |
\ocgbase@tree@node@begin% |
| 463 |
\XCP@currentOcg% |
| 464 |
\ocgbase@tree@node@end% |
| 465 |
% Disable the simultaneous visibility of multiple tooltips |
| 466 |
\ocgbase@add@ocg@to@radiobtn@grp{tool@tips}{\ocgbase@last@ocg}% |
| 467 |
% Emit the <link text> using \pbs_pdflink:nn |
| 468 |
\XCP@pdfLink{% |
| 469 |
/Subtype/Link/Border[0 0 0]/A % |
| 470 |
<</S/SetOCGState/State [/Toggle \XCP@currentOcg]>> % |
| 471 |
}{#1}% |
| 472 |
% Create a savebox for the <tooltip text> on the PDF layer |
| 473 |
\sbox\XCP@tipText{% |
| 474 |
\ocgbase@oc@bdc{\XCP@currentOcg}% |
| 475 |
\ocgbase@open@stack@push{\XCP@currentOcg}% |
| 476 |
\XCP@tooltipbox{black!50}{#2}{#3}% |
| 477 |
\ocgbase@oc@emc% |
| 478 |
\ocgbase@open@stack@pop% |
| 479 |
\null% |
| 480 |
}% |
| 481 |
% Emit the savebox (at this point we have dimensions to calc the offset) |
| 482 |
\raisebox{% |
| 483 |
\heightof{#1} + \the\dp\XCP@tipText + \XCP@vOffset% |
| 484 |
}[0pt][0pt]{% |
| 485 |
\makebox[0pt][l]{\relax% |
| 486 |
\setlength\XCP@lineGoal{\linegoal}% |
| 487 |
\hspace{\dimexpr\XCP@lineGoal - \linewidth + \XCP@hOffset \relax}% |
| 488 |
\usebox{\XCP@tipText}% |
| 489 |
}% |
| 490 |
}% |
| 491 |
}} |
| 492 |
|
| 493 |
\fi%XCP@useocg |
| 494 |
% \end{macrocode} |
| 495 |
% \end{macro} |
| 496 |
% |
| 497 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 498 |
% \begin{macro}{\XCP@enumeratetips} |
| 499 |
% |
| 500 |
% Gets \texttt{bibentry} for each key from the list of citations. |
| 501 |
% The output is stored into |\XCP@tips|, which can be directly used as |
| 502 |
% a tooltip text in |\pdftooltip|. |
| 503 |
% |
| 504 |
% \begin{macrocode} |
| 505 |
\newsavebox{\XCP@keynum} % Temp box for getting citation numbers using \citenum |
| 506 |
|
| 507 |
\ExplSyntaxOn |
| 508 |
|
| 509 |
\NewDocumentCommand{ \XCP@enumeratetips }% |
| 510 |
{ > { \SplitList , } m }% |
| 511 |
{% |
| 512 |
\global\undef\XCP@tips% |
| 513 |
\global\undef\XCP@keys% |
| 514 |
\tl_map_inline:nn {#1}% |
| 515 |
{% |
| 516 |
\ifx\XCP@tips\undefined% |
| 517 |
\global\def\XCP@keys{}% |
| 518 |
\sbox\XCP@keynum{\citenum{##1}}% |
| 519 |
\expandafter\xdef\csname XCP@k@##1\endcsname{\NAT@num}% |
| 520 |
\xappto{\XCP@keys}{\NAT@num}% |
| 521 |
\global\def\XCP@tips{}% |
| 522 |
\gappto{\XCP@tips}{[\textbf{\@nameuse{XCP@k@##1}}]\ % |
| 523 |
{\@nameuse{BR@r@##1\@extra@b@citeb}}}% |
| 524 |
\else% |
| 525 |
\sbox\XCP@keynum{\citenum{##1}}% |
| 526 |
\expandafter\xdef\csname XCP@k@##1\@extra@b@citeb\endcsname{\NAT@num}% |
| 527 |
\xappto{\XCP@keys}{,\NAT@num}% |
| 528 |
\gappto{\XCP@tips}{,\textCR[\textbf{\@nameuse{XCP@k@##1}}]\ % |
| 529 |
{\@nameuse{BR@r@##1\@extra@b@citeb}}}% |
| 530 |
\fi% |
| 531 |
}% |
| 532 |
} |
| 533 |
|
| 534 |
\ExplSyntaxOff |
| 535 |
% \end{macrocode} |
| 536 |
% \end{macro} |
| 537 |
% |
| 538 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 539 |
% \begin{macro}{\xcsetauthor} |
| 540 |
% |
| 541 |
% Set the author used for pdf comments (default: {}). |
| 542 |
% |
| 543 |
% \begin{macrocode} |
| 544 |
\gdef\XCP@opt@author{{}} |
| 545 |
\newcommand{\xcsetauthor}[1]{\gdef\XCP@opt@author{#1}} |
| 546 |
% \end{macrocode} |
| 547 |
% \end{macro} |
| 548 |
% |
| 549 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 550 |
% \begin{macro}{\xcsetmarkup} |
| 551 |
% |
| 552 |
% Set the markup used for pdf comments (default: Underline). |
| 553 |
% |
| 554 |
% \begin{macrocode} |
| 555 |
\gdef\XCP@opt@markup{Underline} |
| 556 |
\newcommand{\xcsetmarkup}[1]{\gdef\XCP@opt@markup{#1}} |
| 557 |
% \end{macrocode} |
| 558 |
% \end{macro} |
| 559 |
% |
| 560 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 561 |
% \begin{macro}{\xcsetcolor} |
| 562 |
% |
| 563 |
% Set the color used for pdf comments (default: yellow). |
| 564 |
% |
| 565 |
% \begin{macrocode} |
| 566 |
\gdef\XCP@opt@color{1 1 0} |
| 567 |
\newcommand{\xcsetcolor}[1]{\gdef\XCP@opt@color{#1}} |
| 568 |
% \end{macrocode} |
| 569 |
% \end{macro} |
| 570 |
% |
| 571 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 572 |
% \begin{macro}{\xcsetopacity} |
| 573 |
% |
| 574 |
% Set the opacity used for pdf comments (default: 0). |
| 575 |
% |
| 576 |
% \begin{macrocode} |
| 577 |
\gdef\XCP@opt@opacity{0} |
| 578 |
\newcommand{\xcsetopacity}[1]{\gdef\XCP@opt@opacity{#1}} |
| 579 |
% \end{macrocode} |
| 580 |
% \end{macro} |
| 581 |
% |
| 582 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 583 |
% \begin{macro}{\XCP@citetp} |
| 584 |
% |
| 585 |
% This macro is in fact |\xpdfcite|. \\ |
| 586 |
% It is a wrapper for |\XCP@@citetp| to handle variable number of arguments. |
| 587 |
% |
| 588 |
% \begin{macrocode} |
| 589 |
\newcommand\XCP@citetp{\@ifnextchar[{\XCP@@citetp}{\XCP@@citetp[]}} |
| 590 |
|
| 591 |
\newcommand\XCP@@citetp{} |
| 592 |
\def\XCP@@citetp[#1]{\@ifnextchar[{\XCP@citex[#1]}{\XCP@citex[][#1]}} |
| 593 |
% \end{macrocode} |
| 594 |
% \end{macro} |
| 595 |
% |
| 596 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 597 |
% \begin{macro}{\XCP@citex} |
| 598 |
% |
| 599 |
% An internal macro that does the actual job for |\xpdfcite|. |
| 600 |
% |
| 601 |
% \begin{macrocode} |
| 602 |
\newcommand\XCP@citex{} |
| 603 |
\gdef\XCP@citex[#1][#2]#3% |
| 604 |
{%{\protect\NoHyper% |
| 605 |
\ifXCP@useocg% |
| 606 |
\let\textCR\par% |
| 607 |
\XCP@enumeratetips{#3}% |
| 608 |
\XCP@ocgtooltip% |
| 609 |
{{{\protect\NoHyper\XCP@oldcite[#1][#2]{#3}\protect\endNoHyper}}}% |
| 610 |
{\XCP@tips}% |
| 611 |
\else% |
| 612 |
\XCP@enumeratetips{#3}% |
| 613 |
\pdftooltip{\XCP@oldcite[#1][#2]{#3}}{\XCP@tips}% |
| 614 |
\pdfmarkupcomment[% |
| 615 |
author=\XCP@opt@author,% |
| 616 |
markup=\XCP@opt@markup,% |
| 617 |
color=\XCP@opt@color,% |
| 618 |
opacity=\XCP@opt@opacity,% |
| 619 |
]{\vphantom{.}}{\XCP@tips}% |
| 620 |
\fi% |
| 621 |
}%\protect\endNoHyper}} |
| 622 |
|
| 623 |
\let\XCP@oldcite\citep % Save \citep (in the case if it becomes redefined) |
| 624 |
% \end{macrocode} |
| 625 |
% \end{macro} |
| 626 |
% |
| 627 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 628 |
% \begin{macro}{\xpdfcite} |
| 629 |
% |
| 630 |
% A wrapper for |\citep| + |\pdftooltip|. |
| 631 |
% It has the same syntax as |\citep|. |
| 632 |
% |
| 633 |
% \begin{macrocode} |
| 634 |
\let\xpdfcite\XCP@citetp |
| 635 |
\robustify{\xpdfcite} |
| 636 |
|
| 637 |
\AtBeginDocument{\nobibliography*} % Necessary to get bibentries. |
| 638 |
|
| 639 |
\ifXCP@redefcite % Override \cite |
| 640 |
\let\cite\xpdfcite |
| 641 |
\robustify{\cite} % Required for, e.g., captions |
| 642 |
\fi |
| 643 |
% \end{macrocode} |
| 644 |
% \end{macro} |
| 645 |
% |
| 646 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 647 |
% \Finale |