texlive[50449] Master/texmf-dist: xcpdftips (18mar19)

commits+karl at tug.org commits+karl at tug.org
Mon Mar 18 22:16:36 CET 2019


Revision: 50449
          http://tug.org/svn/texlive?view=revision&revision=50449
Author:   karl
Date:     2019-03-18 22:16:35 +0100 (Mon, 18 Mar 2019)
Log Message:
-----------
xcpdftips (18mar19)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/xcpdftips/README.md
    trunk/Master/texmf-dist/doc/latex/xcpdftips/xcpdftips.pdf
    trunk/Master/texmf-dist/source/latex/xcpdftips/xcpdftips.drv
    trunk/Master/texmf-dist/source/latex/xcpdftips/xcpdftips.dtx
    trunk/Master/texmf-dist/tex/latex/xcpdftips/xcpdftips.sty

Modified: trunk/Master/texmf-dist/doc/latex/xcpdftips/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/xcpdftips/README.md	2019-03-18 21:16:17 UTC (rev 50448)
+++ trunk/Master/texmf-dist/doc/latex/xcpdftips/README.md	2019-03-18 21:16:35 UTC (rev 50449)
@@ -41,7 +41,8 @@
 
 ## List of changes
 
-v1.0 Initial release 2019/03/10
+v1.0 2019/03/10 Initial release
+v1.1 2019/03/10 Added support for tooltips on PDF layers (using OCG)
 
 ## License
 

Modified: trunk/Master/texmf-dist/doc/latex/xcpdftips/xcpdftips.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/xcpdftips/xcpdftips.drv
===================================================================
--- trunk/Master/texmf-dist/source/latex/xcpdftips/xcpdftips.drv	2019-03-18 21:16:17 UTC (rev 50448)
+++ trunk/Master/texmf-dist/source/latex/xcpdftips/xcpdftips.drv	2019-03-18 21:16:35 UTC (rev 50449)
@@ -36,9 +36,208 @@
 \DisableCrossrefs %May stay; zapped by \EnableCrossrefs
 \CodelineNumbered %May stay
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{document}
    \DocInput{xcpdftips.dtx}
 \end{document}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newif\ifXCP at redefcite\XCP at redefcitefalse
+\newif\ifXCP at useocg\XCP at useocgfalse
+\newif\ifXCP at usetcolorbox\XCP at usetcolorboxfalse
+
+\DeclareOption{redefcite}{\XCP at redefcitetrue}
+\DeclareOption{ocg}{\XCP at useocgtrue}
+\DeclareOption{tcolorbox}{\XCP at usetcolorboxtrue}
+
+\ProcessOptions\relax
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifXCP at useocg
+ \ifXCP at usetcolorbox
+  \ifx\tcolorbox\undefined
+    \RequirePackage{tcolorbox}
+  \fi
+  \newcommand{\XCP at 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 at tooltipbox}[3]{%
+    \fcolorbox{#1}{#2}%
+      {\parbox[t]{\columnwidth}{\normalfont\small #3}}%
+  }
+ \fi
+\fi
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifXCP at useocg
+
+\RequirePackage{pdfbase,ocgbase}
+
+\RequirePackage{expl3}
+\RequirePackage{calc,linegoal}
+\RequirePackage{xcolor}
+
+
+\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 at pdfLink\pbs_pdflink:nn  % Alias for the pdflink from pdfbase
+
+\ExplSyntaxOff
+
+
+\ifx\Hy at setpdfborder\undefined\else
+  \let\Hy at setpdfborderOrig\Hy at setpdfborder
+  \def\Hy at setpdfborder{\ocgbase at insert@oc\Hy at setpdfborderOrig}%
+\fi
+
+\newsavebox{\XCP at tipText} % Temporary savebox
+\newlength{\XCP at hOffset} \setlength\XCP at hOffset{-0.1em}
+\newlength{\XCP at vOffset} \setlength\XCP at vOffset{0.2ex}
+\newlength{\XCP at lineGoal}
+
+\NewDocumentCommand{\XCP at ocgtooltip}{%
+  m % link text
+  O{yellow!5} % tooltip box color
+  m % tooltip text
+}{{%
+  \leavevmode%
+  % Create a new PDF layer
+  \ocgbase at new@ocg{ref [\XCP at keys]}{%
+    /Print<</PrintState/OFF>> %
+    /Export<</ExportState/OFF>> %
+    /View<</ViewState/OFF>> %
+  }{invisible}%
+  \edef\XCP at currentOcg{\ocgbase at last@ocg}%
+  % Insert the PDF layer into the order hierarchy (shown in the 'Layers' tab)
+  \ocgbase at tree@node at begin%
+  \XCP at currentOcg%
+  \ocgbase at tree@node at end%
+  % Disable the simultaneous visibility of multiple tooltips
+  \ocgbase at add@ocg at to@radiobtn at grp{tool at tips}{\ocgbase at last@ocg}%
+  % Emit the <link text> using \pbs_pdflink:nn
+  \XCP at pdfLink{%
+    /Subtype/Link/Border[0 0 0]/A %
+      <</S/SetOCGState/State [/Toggle \XCP at currentOcg]>> %
+  }{#1}%
+  % Create a savebox for the <tooltip text> on the PDF layer
+  \sbox\XCP at tipText{%
+    \ocgbase at oc@bdc{\XCP at currentOcg}%
+    \ocgbase at open@stack at push{\XCP at currentOcg}%
+      \XCP at tooltipbox{black!50}{#2}{#3}%
+    \ocgbase at oc@emc%
+    \ocgbase at open@stack at pop%
+    \null%
+  }%
+  % Emit the savebox (at this point we have dimensions to calc the offset)
+  \raisebox{%
+    \heightof{#1} + \the\dp\XCP at tipText + \XCP at vOffset%
+  }[0pt][0pt]{%
+    \makebox[0pt][l]{\relax%
+      \setlength\XCP at lineGoal{\linegoal}%
+      \hspace{\dimexpr\XCP at lineGoal - \linewidth + \XCP at hOffset \relax}%
+      \usebox{\XCP at tipText}%
+    }%
+  }%
+}}
+
+\fi%XCP at useocg
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newsavebox{\XCP at keynum} % Temp box for getting citation numbers using \citenum
+
+\ExplSyntaxOn
+
+\NewDocumentCommand{ \XCP at enumeratetips }%
+{ > { \SplitList , } m }%
+{%
+  \global\undef\XCP at tips%
+  \global\undef\XCP at keys%
+  \tl_map_inline:nn {#1}%
+  {%
+    \ifx\XCP at tips\undefined%
+      \global\def\XCP at keys{}%
+      \sbox\XCP at keynum{\citenum{##1}}%
+      \expandafter\xdef\csname XCP at k@##1\endcsname{\NAT at num}%
+      \xappto{\XCP at keys}{\NAT at num}%
+      \global\def\XCP at tips{}%
+      \gappto{\XCP at tips}{[\textbf{\@nameuse{XCP at k@##1}}]\ %
+        {\@nameuse{BR at r@##1\@extra at b@citeb}}}%
+    \else%
+      \sbox\XCP at keynum{\citenum{##1}}%
+      \expandafter\xdef\csname XCP at k@##1\@extra at b@citeb\endcsname{\NAT at num}%
+      \xappto{\XCP at keys}{,\NAT at num}%
+      \gappto{\XCP at tips}{,\textCR[\textbf{\@nameuse{XCP at k@##1}}]\ %
+        {\@nameuse{BR at r@##1\@extra at b@citeb}}}%
+    \fi%
+  }%
+}
+
+\ExplSyntaxOff
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\XCP at opt@author{{}}
+\newcommand{\xcsetauthor}[1]{\gdef\XCP at opt@author{#1}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\XCP at opt@markup{Underline}
+\newcommand{\xcsetmarkup}[1]{\gdef\XCP at opt@markup{#1}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\XCP at opt@color{1 1 0}
+\newcommand{\xcsetcolor}[1]{\gdef\XCP at opt@color{#1}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\XCP at opt@opacity{0}
+\newcommand{\xcsetopacity}[1]{\gdef\XCP at opt@opacity{#1}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand\XCP at citetp{\@ifnextchar[{\XCP@@citetp}{\XCP@@citetp[]}}
+
+\newcommand\XCP@@citetp{}
+\def\XCP@@citetp[#1]{\@ifnextchar[{\XCP at citex[#1]}{\XCP at citex[][#1]}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand\XCP at citex{}
+\gdef\XCP at citex[#1][#2]#3%
+  {%{\protect\NoHyper%
+    \ifXCP at useocg%
+      \let\textCR\par%
+      \XCP at enumeratetips{#3}%
+      \XCP at ocgtooltip%
+        {{{\protect\NoHyper\XCP at oldcite[#1][#2]{#3}\protect\endNoHyper}}}%
+        {\XCP at tips}%
+    \else%
+      \XCP at enumeratetips{#3}%
+      \pdftooltip{\XCP at oldcite[#1][#2]{#3}}{\XCP at tips}%
+      \pdfmarkupcomment[%
+        author=\XCP at opt@author,%
+        markup=\XCP at opt@markup,%
+        color=\XCP at opt@color,%
+        opacity=\XCP at opt@opacity,%
+      ]{\vphantom{.}}{\XCP at tips}%
+    \fi%
+  }%\protect\endNoHyper}}
+
+\let\XCP at oldcite\citep  % Save \citep (in the case if it becomes redefined)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\let\xpdfcite\XCP at citetp
+\robustify{\xpdfcite}
+
+\AtBeginDocument{\nobibliography*} % Necessary to get bibentries.
+
+\ifXCP at redefcite % Override \cite
+  \let\cite\xpdfcite
+  \robustify{\cite} % Required for, e.g., captions
+\fi
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% 
 %% End of documentation driver file.
 %%

Modified: trunk/Master/texmf-dist/source/latex/xcpdftips/xcpdftips.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/xcpdftips/xcpdftips.dtx	2019-03-18 21:16:17 UTC (rev 50448)
+++ trunk/Master/texmf-dist/source/latex/xcpdftips/xcpdftips.dtx	2019-03-18 21:16:35 UTC (rev 50449)
@@ -39,7 +39,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}
 %<package>
 %<package>\ProvidesPackage{xcpdftips}
-%<package>[2019/03/10 xcpdftips.sty v1.0 - Copyright 2019 by Mikica Kocic]
+%<package>[2019/03/18 xcpdftips.sty v1.1 - (c) 2019 Mikica Kocic]
 %<package>
 %<package>\RequirePackage{bibentry}
 %<package>\RequirePackage{pdfcomment}
@@ -54,10 +54,12 @@
 %  *** The DATE, VERSION, and other INFO
 %
 %\fi
-%\ProvidesFile{xcpdftips}[2019/03/10 1.0 (PWD)]
+%\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{55}
+% \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
@@ -83,6 +85,7 @@
 %^^A    does not already exist
 %^^A =============================================
 %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{filecontents*}{xcpdftips.ins}
 %
 % File: xcpdftips.ins
@@ -210,6 +213,7 @@
 \DisableCrossrefs %May stay; zapped by \EnableCrossrefs
 \CodelineNumbered %May stay
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{document}
    \DocInput{xcpdftips.dtx}
 \end{document}
@@ -240,14 +244,14 @@
 %
 % \author{Mikica Kocic}
 %
-% \date{This paper describes package \texttt{\filename}\\
+% \date{\normalsize This paper describes package \texttt{\filename}\\[0.5ex]
 %       version \fileversion{} from \filedate
-%  }
+% }
 %
 % \maketitle
 %
 % \pagestyle{myheadings}
-% \markboth{M. Kocic}{PDF tooltips from natbib citations}
+% \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)
@@ -274,9 +278,17 @@
 % with the |\usepackage| command of \LaTeXe,
 % \begin{quote}
 % |\documentclass[..]{...}|\\
-% |\usepackage{|\texttt{\filename}|}|
+% |\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}
@@ -288,31 +300,27 @@
 % \vspace{2ex}
 %
 % \DescribeMacro{\xpdfcite}
-% This is a replacement for \texttt{natbib}'s |\cite| macro. 
-% Usage is the same:
+% \noindent A replacement for \texttt{natbib}'s |\cite| macro.\\~
 %
-% \begin{quote}
-%      |\xpdfcite|\marg{key(s)}
-% \end{quote}
-%
 % \noindent Similarly to |\cite|, the command |\xpdfcite| may take one or two
-% optional arguments to add some text before and after the citation.
-% \vspace{2ex}
+% optional arguments to add some text before and after the citation,
 %
-% \noindent It is also possible to replace |\cite|:
-%
 % \begin{quote}
-%      |\usepackage{xcpdftips}| \\
-%      |\let\cite\xpdfcite|
+%      |\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 \texttt{natbib} with its
-% native |\bibitem| format, and with standard \LaTeX. Nothing else can be
-% guaranteed.
-% It will also work with \texttt{url} package. 
+% 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}}
@@ -320,6 +328,7 @@
 % 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
@@ -341,94 +350,298 @@
 % are indicators to \texttt{docstrip} that this coding belongs to the package
 % file.
 %
-% \begin{macro}{\XC at enumeratetips}
+% \begin{macro}{Package options}
+% 
+% |redefcite|, |ocg|, |tcolorbox|
 %
-% The macro |\XC at enumeratetips| gets \texttt{bibentry} for each key from 
-% the list of citations. The output is stored into |\XC at tips|, which can
-% be directly used as a tooltip text in |\pdftooltip|.
+%    \begin{macrocode}
+\newif\ifXCP at redefcite\XCP at redefcitefalse
+\newif\ifXCP at useocg\XCP at useocgfalse
+\newif\ifXCP at usetcolorbox\XCP at usetcolorboxfalse
+
+\DeclareOption{redefcite}{\XCP at redefcitetrue}
+\DeclareOption{ocg}{\XCP at useocgtrue}
+\DeclareOption{tcolorbox}{\XCP at usetcolorboxtrue}
+
+\ProcessOptions\relax
+%    \end{macrocode}
+% \end{macro}
 %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\XCP at tooltipbox}
+%
+% Command for creating a tooltip box on the OCG layer. 
+% The arguments are the same as for |\fcolorbox|.
+%
 %    \begin{macrocode}
-%<*package>
+\ifXCP at useocg
+ \ifXCP at usetcolorbox
+  \ifx\tcolorbox\undefined
+    \RequirePackage{tcolorbox}
+  \fi
+  \newcommand{\XCP at 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 at tooltipbox}[3]{%
+    \fcolorbox{#1}{#2}%
+      {\parbox[t]{\columnwidth}{\normalfont\small #3}}%
+  }
+ \fi
+\fi
+%    \end{macrocode}
+% \end{macro}
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\XCP at ocgtooltip}
+%
+% Usage: |\XCP at ocgtooltip|\marg{link text}\oarg{tooltip box color}\marg{tooltip text}
+%
+% \noindent Warning: Requires |pdfbase| and |ocgbase| $>=$ 2018/04/06
+%
+%    \begin{macrocode}
+\ifXCP at useocg
 
+\RequirePackage{pdfbase,ocgbase}
+  
+\RequirePackage{expl3}
+\RequirePackage{calc,linegoal}
+\RequirePackage{xcolor}
+  
+% Check the required versions of pdfbase and ocgbase
+
 \ExplSyntaxOn
 
-\NewDocumentCommand{ \XC at enumeratetips }%
+\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 at pdfLink\pbs_pdflink:nn  % Alias for the pdflink from pdfbase
+
+\ExplSyntaxOff
+
+% Patch hyperref (make the PDF annotations OCG-aware)
+
+\ifx\Hy at setpdfborder\undefined\else
+  \let\Hy at setpdfborderOrig\Hy at setpdfborder
+  \def\Hy at setpdfborder{\ocgbase at insert@oc\Hy at setpdfborderOrig}%
+\fi
+
+\newsavebox{\XCP at tipText} % Temporary savebox
+\newlength{\XCP at hOffset} \setlength\XCP at hOffset{-0.1em}
+\newlength{\XCP at vOffset} \setlength\XCP at vOffset{0.2ex}
+\newlength{\XCP at lineGoal}
+
+\NewDocumentCommand{\XCP at ocgtooltip}{%
+  m % link text
+  O{yellow!5} % tooltip box color
+  m % tooltip text
+}{{%
+  \leavevmode%
+  % Create a new PDF layer
+  \ocgbase at new@ocg{ref [\XCP at keys]}{%
+    /Print<</PrintState/OFF>> %
+    /Export<</ExportState/OFF>> %
+    /View<</ViewState/OFF>> %
+  }{invisible}%
+  \edef\XCP at currentOcg{\ocgbase at last@ocg}%
+  % Insert the PDF layer into the order hierarchy (shown in the 'Layers' tab)
+  \ocgbase at tree@node at begin%
+  \XCP at currentOcg%
+  \ocgbase at tree@node at end%
+  % Disable the simultaneous visibility of multiple tooltips
+  \ocgbase at add@ocg at to@radiobtn at grp{tool at tips}{\ocgbase at last@ocg}%
+  % Emit the <link text> using \pbs_pdflink:nn
+  \XCP at pdfLink{%
+    /Subtype/Link/Border[0 0 0]/A %
+      <</S/SetOCGState/State [/Toggle \XCP at currentOcg]>> %
+  }{#1}%
+  % Create a savebox for the <tooltip text> on the PDF layer
+  \sbox\XCP at tipText{%
+    \ocgbase at oc@bdc{\XCP at currentOcg}%
+    \ocgbase at open@stack at push{\XCP at currentOcg}%
+      \XCP at tooltipbox{black!50}{#2}{#3}%
+    \ocgbase at oc@emc%
+    \ocgbase at open@stack at pop%
+    \null%
+  }%
+  % Emit the savebox (at this point we have dimensions to calc the offset)
+  \raisebox{%
+    \heightof{#1} + \the\dp\XCP at tipText + \XCP at vOffset%
+  }[0pt][0pt]{%
+    \makebox[0pt][l]{\relax%
+      \setlength\XCP at lineGoal{\linegoal}%
+      \hspace{\dimexpr\XCP at lineGoal - \linewidth + \XCP at hOffset \relax}%
+      \usebox{\XCP at tipText}%
+    }%
+  }%
+}}
+  
+\fi%XCP at useocg
+%    \end{macrocode}
+% \end{macro}
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\XCP at enumeratetips}
+%
+% Gets \texttt{bibentry} for each key from the list of citations. 
+% The output is stored into |\XCP at tips|, which can be directly used as 
+% a tooltip text in |\pdftooltip|.
+%
+%    \begin{macrocode}
+\newsavebox{\XCP at keynum} % Temp box for getting citation numbers using \citenum
+
+\ExplSyntaxOn
+
+\NewDocumentCommand{ \XCP at enumeratetips }%
 { > { \SplitList , } m }%
 {%
-  \global\undef\XC at tips%
-  \tl_map_inline:nn {#1}% 
+  \global\undef\XCP at tips%
+  \global\undef\XCP at keys%
+  \tl_map_inline:nn {#1}%
   {%
-    \ifx\XC at tips\undefined%
-      \global\def\XC at tips{}%
-      \gappto{\XC at tips}{--~~\@nameuse{BR at r@##1\@extra at b@citeb}}%
+    \ifx\XCP at tips\undefined%
+      \global\def\XCP at keys{}%
+      \sbox\XCP at keynum{\citenum{##1}}%
+      \expandafter\xdef\csname XCP at k@##1\endcsname{\NAT at num}%
+      \xappto{\XCP at keys}{\NAT at num}%
+      \global\def\XCP at tips{}%
+      \gappto{\XCP at tips}{[\textbf{\@nameuse{XCP at k@##1}}]\ %
+        {\@nameuse{BR at r@##1\@extra at b@citeb}}}%
     \else%
-      \gappto{\XC at tips}{,\textCR--~~\@nameuse{BR at r@##1\@extra at b@citeb}}%
+      \sbox\XCP at keynum{\citenum{##1}}%
+      \expandafter\xdef\csname XCP at k@##1\@extra at b@citeb\endcsname{\NAT at num}%
+      \xappto{\XCP at keys}{,\NAT at num}%
+      \gappto{\XCP at tips}{,\textCR[\textbf{\@nameuse{XCP at k@##1}}]\ %
+        {\@nameuse{BR at r@##1\@extra at b@citeb}}}%
     \fi%
   }%
 }
 
 \ExplSyntaxOff
-
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\XC at citetp}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\xcsetauthor}
 %
-% This macro is in fact |\xpdfcite|. \\
-% It is a wrapper for |\XC@@citetp| to handle variable number of arguments.
+% Set the author used for pdf comments (default: {}).
 %
 %    \begin{macrocode}
-
-\newcommand\XC at citetp{\@ifnextchar[{\XC@@citetp}{\XC@@citetp[]}}
-
+\gdef\XCP at opt@author{{}}
+\newcommand{\xcsetauthor}[1]{\gdef\XCP at opt@author{#1}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\XC@@citetp}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\xcsetmarkup}
 %
-% This macro is called from |\xpdfcite|. \\
-% It is a wrapper for |\XC at citex| to handle variable number of arguments.
+% Set the markup used for pdf comments (default: Underline).
 %
 %    \begin{macrocode}
+\gdef\XCP at opt@markup{Underline}
+\newcommand{\xcsetmarkup}[1]{\gdef\XCP at opt@markup{#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\xcsetcolor}
+%
+% Set the color used for pdf comments (default: yellow).
+%
+%    \begin{macrocode}
+\gdef\XCP at opt@color{1 1 0}
+\newcommand{\xcsetcolor}[1]{\gdef\XCP at opt@color{#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\xcsetopacity}
+%
+% Set the opacity used for pdf comments (default: 0).
+%
+%    \begin{macrocode}
+\gdef\XCP at opt@opacity{0}
+\newcommand{\xcsetopacity}[1]{\gdef\XCP at opt@opacity{#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\XCP at citetp}
+%
+% This macro is in fact |\xpdfcite|. \\
+% It is a wrapper for |\XCP@@citetp| to handle variable number of arguments.
+%
+%    \begin{macrocode}
+\newcommand\XCP at citetp{\@ifnextchar[{\XCP@@citetp}{\XCP@@citetp[]}}
 
-\newcommand\XC@@citetp{}
-
-\def\XC@@citetp[#1]{\@ifnextchar[{\XC at citex[#1]}{\XC at citex[][#1]}}
-
+\newcommand\XCP@@citetp{}
+\def\XCP@@citetp[#1]{\@ifnextchar[{\XCP at citex[#1]}{\XCP at citex[][#1]}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\XC at citex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{macro}{\XCP at citex}
 %
-% This macro does the actual job.
-% It is an internal wrapper for the combined |\pdftooltip| and |\citep|. 
+% An internal macro that does the actual job for |\xpdfcite|.
 %
 %    \begin{macrocode}
+\newcommand\XCP at citex{}
+\gdef\XCP at citex[#1][#2]#3%
+  {%{\protect\NoHyper%
+    \ifXCP at useocg%
+      \let\textCR\par%
+      \XCP at enumeratetips{#3}%
+      \XCP at ocgtooltip%
+        {{{\protect\NoHyper\XCP at oldcite[#1][#2]{#3}\protect\endNoHyper}}}%
+        {\XCP at tips}%
+    \else%
+      \XCP at enumeratetips{#3}%
+      \pdftooltip{\XCP at oldcite[#1][#2]{#3}}{\XCP at tips}%
+      \pdfmarkupcomment[%
+        author=\XCP at opt@author,%
+        markup=\XCP at opt@markup,%
+        color=\XCP at opt@color,%
+        opacity=\XCP at opt@opacity,%
+      ]{\vphantom{.}}{\XCP at tips}%
+    \fi%
+  }%\protect\endNoHyper}}
 
-\newcommand\XC at citex{}
-
-\def\XC at citex[#1][#2]#3{%
-  \XC at enumeratetips{#3}%
-  \pdftooltip{\XC at oldcite[#1][#2]{#3}}{\XC at tips}%
-}
-
-\let\XC at oldcite\citep  % Save \citep (in the case if it becomes redefined)
-
+\let\XCP at oldcite\citep  % Save \citep (in the case if it becomes redefined)
 %    \end{macrocode}
 % \end{macro}
 %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % \begin{macro}{\xpdfcite}
 %
-% A wrapper for the combined |\pdftooltip| and |\citep|.\\
+% A wrapper for |\citep| + |\pdftooltip|.
 % It has the same syntax as |\citep|.
 %
 %    \begin{macrocode}
+\let\xpdfcite\XCP at citetp
+\robustify{\xpdfcite}
 
-\let\xpdfcite\XC at citetp
-
 \AtBeginDocument{\nobibliography*} % Necessary to get bibentries.
 
+\ifXCP at redefcite % Override \cite
+  \let\cite\xpdfcite  
+  \robustify{\cite} % Required for, e.g., captions
+\fi
 %    \end{macrocode}
 % \end{macro}
 %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % \Finale

Modified: trunk/Master/texmf-dist/tex/latex/xcpdftips/xcpdftips.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/xcpdftips/xcpdftips.sty	2019-03-18 21:16:17 UTC (rev 50448)
+++ trunk/Master/texmf-dist/tex/latex/xcpdftips/xcpdftips.sty	2019-03-18 21:16:35 UTC (rev 50449)
@@ -34,55 +34,210 @@
 \NeedsTeXFormat{LaTeX2e}
 
 \ProvidesPackage{xcpdftips}
-[2019/03/10 xcpdftips.sty v1.0 - Copyright 2019 by Mikica Kocic]
+[2019/03/18 xcpdftips.sty v1.1 - (c) 2019 Mikica Kocic]
 
 \RequirePackage{bibentry}
 \RequirePackage{pdfcomment}
 \RequirePackage{xparse}
 \RequirePackage{etoolbox}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newif\ifXCP at redefcite\XCP at redefcitefalse
+\newif\ifXCP at useocg\XCP at useocgfalse
+\newif\ifXCP at usetcolorbox\XCP at usetcolorboxfalse
 
+\DeclareOption{redefcite}{\XCP at redefcitetrue}
+\DeclareOption{ocg}{\XCP at useocgtrue}
+\DeclareOption{tcolorbox}{\XCP at usetcolorboxtrue}
+
+\ProcessOptions\relax
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifXCP at useocg
+ \ifXCP at usetcolorbox
+  \ifx\tcolorbox\undefined
+    \RequirePackage{tcolorbox}
+  \fi
+  \newcommand{\XCP at 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 at tooltipbox}[3]{%
+    \fcolorbox{#1}{#2}%
+      {\parbox[t]{\columnwidth}{\normalfont\small #3}}%
+  }
+ \fi
+\fi
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifXCP at useocg
+
+\RequirePackage{pdfbase,ocgbase}
+
+\RequirePackage{expl3}
+\RequirePackage{calc,linegoal}
+\RequirePackage{xcolor}
+
+
 \ExplSyntaxOn
 
-\NewDocumentCommand{ \XC at enumeratetips }%
-{ > { \SplitList , } m }%
-{%
-  \global\undef\XC at tips%
-  \tl_map_inline:nn {#1}%
-  {%
-    \ifx\XC at tips\undefined%
-      \global\def\XC at tips{}%
-      \gappto{\XC at tips}{--~~\@nameuse{BR at r@##1\@extra at b@citeb}}%
-    \else%
-      \gappto{\XC at tips}{,\textCR--~~\@nameuse{BR at r@##1\@extra at b@citeb}}%
-    \fi%
-  }%
+\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 at pdfLink\pbs_pdflink:nn  % Alias for the pdflink from pdfbase
+
 \ExplSyntaxOff
 
 
-\newcommand\XC at citetp{\@ifnextchar[{\XC@@citetp}{\XC@@citetp[]}}
+\ifx\Hy at setpdfborder\undefined\else
+  \let\Hy at setpdfborderOrig\Hy at setpdfborder
+  \def\Hy at setpdfborder{\ocgbase at insert@oc\Hy at setpdfborderOrig}%
+\fi
 
+\newsavebox{\XCP at tipText} % Temporary savebox
+\newlength{\XCP at hOffset} \setlength\XCP at hOffset{-0.1em}
+\newlength{\XCP at vOffset} \setlength\XCP at vOffset{0.2ex}
+\newlength{\XCP at lineGoal}
 
-\newcommand\XC@@citetp{}
+\NewDocumentCommand{\XCP at ocgtooltip}{%
+  m % link text
+  O{yellow!5} % tooltip box color
+  m % tooltip text
+}{{%
+  \leavevmode%
+  % Create a new PDF layer
+  \ocgbase at new@ocg{ref [\XCP at keys]}{%
+    /Print<</PrintState/OFF>> %
+    /Export<</ExportState/OFF>> %
+    /View<</ViewState/OFF>> %
+  }{invisible}%
+  \edef\XCP at currentOcg{\ocgbase at last@ocg}%
+  % Insert the PDF layer into the order hierarchy (shown in the 'Layers' tab)
+  \ocgbase at tree@node at begin%
+  \XCP at currentOcg%
+  \ocgbase at tree@node at end%
+  % Disable the simultaneous visibility of multiple tooltips
+  \ocgbase at add@ocg at to@radiobtn at grp{tool at tips}{\ocgbase at last@ocg}%
+  % Emit the <link text> using \pbs_pdflink:nn
+  \XCP at pdfLink{%
+    /Subtype/Link/Border[0 0 0]/A %
+      <</S/SetOCGState/State [/Toggle \XCP at currentOcg]>> %
+  }{#1}%
+  % Create a savebox for the <tooltip text> on the PDF layer
+  \sbox\XCP at tipText{%
+    \ocgbase at oc@bdc{\XCP at currentOcg}%
+    \ocgbase at open@stack at push{\XCP at currentOcg}%
+      \XCP at tooltipbox{black!50}{#2}{#3}%
+    \ocgbase at oc@emc%
+    \ocgbase at open@stack at pop%
+    \null%
+  }%
+  % Emit the savebox (at this point we have dimensions to calc the offset)
+  \raisebox{%
+    \heightof{#1} + \the\dp\XCP at tipText + \XCP at vOffset%
+  }[0pt][0pt]{%
+    \makebox[0pt][l]{\relax%
+      \setlength\XCP at lineGoal{\linegoal}%
+      \hspace{\dimexpr\XCP at lineGoal - \linewidth + \XCP at hOffset \relax}%
+      \usebox{\XCP at tipText}%
+    }%
+  }%
+}}
 
-\def\XC@@citetp[#1]{\@ifnextchar[{\XC at citex[#1]}{\XC at citex[][#1]}}
+\fi%XCP at useocg
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newsavebox{\XCP at keynum} % Temp box for getting citation numbers using \citenum
 
+\ExplSyntaxOn
 
-\newcommand\XC at citex{}
-
-\def\XC at citex[#1][#2]#3{%
-  \XC at enumeratetips{#3}%
-  \pdftooltip{\XC at oldcite[#1][#2]{#3}}{\XC at tips}%
+\NewDocumentCommand{ \XCP at enumeratetips }%
+{ > { \SplitList , } m }%
+{%
+  \global\undef\XCP at tips%
+  \global\undef\XCP at keys%
+  \tl_map_inline:nn {#1}%
+  {%
+    \ifx\XCP at tips\undefined%
+      \global\def\XCP at keys{}%
+      \sbox\XCP at keynum{\citenum{##1}}%
+      \expandafter\xdef\csname XCP at k@##1\endcsname{\NAT at num}%
+      \xappto{\XCP at keys}{\NAT at num}%
+      \global\def\XCP at tips{}%
+      \gappto{\XCP at tips}{[\textbf{\@nameuse{XCP at k@##1}}]\ %
+        {\@nameuse{BR at r@##1\@extra at b@citeb}}}%
+    \else%
+      \sbox\XCP at keynum{\citenum{##1}}%
+      \expandafter\xdef\csname XCP at k@##1\@extra at b@citeb\endcsname{\NAT at num}%
+      \xappto{\XCP at keys}{,\NAT at num}%
+      \gappto{\XCP at tips}{,\textCR[\textbf{\@nameuse{XCP at k@##1}}]\ %
+        {\@nameuse{BR at r@##1\@extra at b@citeb}}}%
+    \fi%
+  }%
 }
 
-\let\XC at oldcite\citep  % Save \citep (in the case if it becomes redefined)
+\ExplSyntaxOff
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\XCP at opt@author{{}}
+\newcommand{\xcsetauthor}[1]{\gdef\XCP at opt@author{#1}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\XCP at opt@markup{Underline}
+\newcommand{\xcsetmarkup}[1]{\gdef\XCP at opt@markup{#1}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\XCP at opt@color{1 1 0}
+\newcommand{\xcsetcolor}[1]{\gdef\XCP at opt@color{#1}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\XCP at opt@opacity{0}
+\newcommand{\xcsetopacity}[1]{\gdef\XCP at opt@opacity{#1}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand\XCP at citetp{\@ifnextchar[{\XCP@@citetp}{\XCP@@citetp[]}}
 
+\newcommand\XCP@@citetp{}
+\def\XCP@@citetp[#1]{\@ifnextchar[{\XCP at citex[#1]}{\XCP at citex[][#1]}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand\XCP at citex{}
+\gdef\XCP at citex[#1][#2]#3%
+  {%{\protect\NoHyper%
+    \ifXCP at useocg%
+      \let\textCR\par%
+      \XCP at enumeratetips{#3}%
+      \XCP at ocgtooltip%
+        {{{\protect\NoHyper\XCP at oldcite[#1][#2]{#3}\protect\endNoHyper}}}%
+        {\XCP at tips}%
+    \else%
+      \XCP at enumeratetips{#3}%
+      \pdftooltip{\XCP at oldcite[#1][#2]{#3}}{\XCP at tips}%
+      \pdfmarkupcomment[%
+        author=\XCP at opt@author,%
+        markup=\XCP at opt@markup,%
+        color=\XCP at opt@color,%
+        opacity=\XCP at opt@opacity,%
+      ]{\vphantom{.}}{\XCP at tips}%
+    \fi%
+  }%\protect\endNoHyper}}
 
-\let\xpdfcite\XC at citetp
+\let\XCP at oldcite\citep  % Save \citep (in the case if it becomes redefined)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\let\xpdfcite\XCP at citetp
+\robustify{\xpdfcite}
 
 \AtBeginDocument{\nobibliography*} % Necessary to get bibentries.
 
+\ifXCP at redefcite % Override \cite
+  \let\cite\xpdfcite
+  \robustify{\cite} % Required for, e.g., captions
+\fi
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% 
 %% <<<<< End of generated file <<<<<<
 %% 



More information about the tex-live-commits mailing list