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