| 1 |
%% |
| 2 |
%% This is file `xcpdftips.drv', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% xcpdftips.dtx (with options: `driver') |
| 8 |
%% ============================================ |
| 9 |
%% This is the driver file to produce the LaTeX documentation |
| 10 |
%% from the original source file xcpdftips.dtx. |
| 11 |
%% |
| 12 |
%% Make changes to it as needed. (Never change the file xcpdftips.dtx!) |
| 13 |
%% ============================================ |
| 14 |
%% Copyright (c) 2019 Mikica Kocic |
| 15 |
\NeedsTeXFormat{LaTeX2e} |
| 16 |
\ProvidesFile{xcpdftips.drv} |
| 17 |
\documentclass[a4paper]{ltxdoc} |
| 18 |
%\documentclass[twoside]{ltxdoc} |
| 19 |
%\documentclass[a4paper]{ltxdoc} |
| 20 |
%\documentclass[twoside,a4paper]{ltxdoc} |
| 21 |
\raggedbottom |
| 22 |
|
| 23 |
%** To include the detailed explanation of the coding, comment out |
| 24 |
%** the next line |
| 25 |
|
| 26 |
%** To produce a command index: add the following line for one run, |
| 27 |
%** then run makeindex -s gind.ist xcpdftips |
| 28 |
%** and reprocess, with or without this line (much faster without) |
| 29 |
% \EnableCrossrefs\CodelineIndex |
| 30 |
|
| 31 |
%** To produce a change history: add the following line for one run, |
| 32 |
%** then run makeindex -s gglo.ist -o xcpdftips.gls xcpdftips.glo |
| 33 |
%** and reprocess, with or without this line (faster without) |
| 34 |
% \RecordChanges |
| 35 |
|
| 36 |
\DisableCrossrefs %May stay; zapped by \EnableCrossrefs |
| 37 |
\CodelineNumbered %May stay |
| 38 |
|
| 39 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 40 |
\begin{document} |
| 41 |
\DocInput{xcpdftips.dtx} |
| 42 |
\end{document} |
| 43 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 44 |
\newif\ifXCP@redefcite\XCP@redefcitefalse |
| 45 |
\newif\ifXCP@useocg\XCP@useocgfalse |
| 46 |
\newif\ifXCP@usetcolorbox\XCP@usetcolorboxfalse |
| 47 |
|
| 48 |
\DeclareOption{redefcite}{\XCP@redefcitetrue} |
| 49 |
\DeclareOption{ocg}{\XCP@useocgtrue} |
| 50 |
\DeclareOption{tcolorbox}{\XCP@usetcolorboxtrue} |
| 51 |
|
| 52 |
\ProcessOptions\relax |
| 53 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 54 |
\ifXCP@useocg |
| 55 |
\ifXCP@usetcolorbox |
| 56 |
\ifx\tcolorbox\undefined |
| 57 |
\RequirePackage{tcolorbox} |
| 58 |
\fi |
| 59 |
\newcommand{\XCP@tooltipbox}[3]{% |
| 60 |
\begin{tcolorbox}[colframe=#1, colback=#2,% |
| 61 |
width=1.02\columnwidth, arc=2pt,% |
| 62 |
boxsep=2pt, top=0ex, bottom=0ex, left=0.1em, right=0.1em% |
| 63 |
]\normalfont\small #3\end{tcolorbox}% |
| 64 |
} |
| 65 |
\else |
| 66 |
\newcommand{\XCP@tooltipbox}[3]{% |
| 67 |
\fcolorbox{#1}{#2}% |
| 68 |
{\parbox[t]{\columnwidth}{\normalfont\small #3}}% |
| 69 |
} |
| 70 |
\fi |
| 71 |
\fi |
| 72 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 73 |
\ifXCP@useocg |
| 74 |
|
| 75 |
\RequirePackage{pdfbase,ocgbase} |
| 76 |
|
| 77 |
\RequirePackage{expl3} |
| 78 |
\RequirePackage{calc,linegoal} |
| 79 |
\RequirePackage{xcolor} |
| 80 |
|
| 81 |
|
| 82 |
\ExplSyntaxOn |
| 83 |
|
| 84 |
\msg_set:nnnn{xcpdftips}{support~outdated}{ |
| 85 |
Support~package~`#1'~too~old. |
| 86 |
}{ |
| 87 |
Get~an~up~to~date~version~of~`#1'.\\Aborting. |
| 88 |
} |
| 89 |
\@ifpackagelater{pdfbase}{2018/04/06}{}{ |
| 90 |
\msg_error:nnn{xcpdftips}{support~outdated}{pdfbase.sty} |
| 91 |
\tex_endinput:D |
| 92 |
} |
| 93 |
\@ifpackagelater{ocgbase}{2018/04/06}{}{ |
| 94 |
\msg_error:nnn{xcpdftips}{support~outdated}{ocgbase.sty} |
| 95 |
\tex_endinput:D |
| 96 |
} |
| 97 |
|
| 98 |
\let\XCP@pdfLink\pbs_pdflink:nn % Alias for the pdflink from pdfbase |
| 99 |
|
| 100 |
\ExplSyntaxOff |
| 101 |
|
| 102 |
|
| 103 |
\ifx\Hy@setpdfborder\undefined\else |
| 104 |
\let\Hy@setpdfborderOrig\Hy@setpdfborder |
| 105 |
\def\Hy@setpdfborder{\ocgbase@insert@oc\Hy@setpdfborderOrig}% |
| 106 |
\fi |
| 107 |
|
| 108 |
\newsavebox{\XCP@tipText} % Temporary savebox |
| 109 |
\newlength{\XCP@hOffset} \setlength\XCP@hOffset{-0.1em} |
| 110 |
\newlength{\XCP@vOffset} \setlength\XCP@vOffset{0.2ex} |
| 111 |
\newlength{\XCP@lineGoal} |
| 112 |
|
| 113 |
\NewDocumentCommand{\XCP@ocgtooltip}{% |
| 114 |
m % link text |
| 115 |
O{yellow!5} % tooltip box color |
| 116 |
m % tooltip text |
| 117 |
}{{% |
| 118 |
\leavevmode% |
| 119 |
% Create a new PDF layer |
| 120 |
\ocgbase@new@ocg{ref [\XCP@keys]}{% |
| 121 |
/Print<</PrintState/OFF>> % |
| 122 |
/Export<</ExportState/OFF>> % |
| 123 |
/View<</ViewState/OFF>> % |
| 124 |
}{invisible}% |
| 125 |
\edef\XCP@currentOcg{\ocgbase@last@ocg}% |
| 126 |
% Insert the PDF layer into the order hierarchy (shown in the 'Layers' tab) |
| 127 |
\ocgbase@tree@node@begin% |
| 128 |
\XCP@currentOcg% |
| 129 |
\ocgbase@tree@node@end% |
| 130 |
% Disable the simultaneous visibility of multiple tooltips |
| 131 |
\ocgbase@add@ocg@to@radiobtn@grp{tool@tips}{\ocgbase@last@ocg}% |
| 132 |
% Emit the <link text> using \pbs_pdflink:nn |
| 133 |
\XCP@pdfLink{% |
| 134 |
/Subtype/Link/Border[0 0 0]/A % |
| 135 |
<</S/SetOCGState/State [/Toggle \XCP@currentOcg]>> % |
| 136 |
}{#1}% |
| 137 |
% Create a savebox for the <tooltip text> on the PDF layer |
| 138 |
\sbox\XCP@tipText{% |
| 139 |
\ocgbase@oc@bdc{\XCP@currentOcg}% |
| 140 |
\ocgbase@open@stack@push{\XCP@currentOcg}% |
| 141 |
\XCP@tooltipbox{black!50}{#2}{#3}% |
| 142 |
\ocgbase@oc@emc% |
| 143 |
\ocgbase@open@stack@pop% |
| 144 |
\null% |
| 145 |
}% |
| 146 |
% Emit the savebox (at this point we have dimensions to calc the offset) |
| 147 |
\raisebox{% |
| 148 |
\heightof{#1} + \the\dp\XCP@tipText + \XCP@vOffset% |
| 149 |
}[0pt][0pt]{% |
| 150 |
\makebox[0pt][l]{\relax% |
| 151 |
\setlength\XCP@lineGoal{\linegoal}% |
| 152 |
\hspace{\dimexpr\XCP@lineGoal - \linewidth + \XCP@hOffset \relax}% |
| 153 |
\usebox{\XCP@tipText}% |
| 154 |
}% |
| 155 |
}% |
| 156 |
}} |
| 157 |
|
| 158 |
\fi%XCP@useocg |
| 159 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 160 |
\newsavebox{\XCP@keynum} % Temp box for getting citation numbers using \citenum |
| 161 |
|
| 162 |
\ExplSyntaxOn |
| 163 |
|
| 164 |
\NewDocumentCommand{ \XCP@enumeratetips }% |
| 165 |
{ > { \SplitList , } m }% |
| 166 |
{% |
| 167 |
\global\undef\XCP@tips% |
| 168 |
\global\undef\XCP@keys% |
| 169 |
\tl_map_inline:nn {#1}% |
| 170 |
{% |
| 171 |
\ifx\XCP@tips\undefined% |
| 172 |
\global\def\XCP@keys{}% |
| 173 |
\sbox\XCP@keynum{\citenum{##1}}% |
| 174 |
\expandafter\xdef\csname XCP@k@##1\endcsname{\NAT@num}% |
| 175 |
\xappto{\XCP@keys}{\NAT@num}% |
| 176 |
\global\def\XCP@tips{}% |
| 177 |
\gappto{\XCP@tips}{[\textbf{\@nameuse{XCP@k@##1}}]\ % |
| 178 |
{\@nameuse{BR@r@##1\@extra@b@citeb}}}% |
| 179 |
\else% |
| 180 |
\sbox\XCP@keynum{\citenum{##1}}% |
| 181 |
\expandafter\xdef\csname XCP@k@##1\@extra@b@citeb\endcsname{\NAT@num}% |
| 182 |
\xappto{\XCP@keys}{,\NAT@num}% |
| 183 |
\gappto{\XCP@tips}{,\textCR[\textbf{\@nameuse{XCP@k@##1}}]\ % |
| 184 |
{\@nameuse{BR@r@##1\@extra@b@citeb}}}% |
| 185 |
\fi% |
| 186 |
}% |
| 187 |
} |
| 188 |
|
| 189 |
\ExplSyntaxOff |
| 190 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 191 |
\gdef\XCP@opt@author{{}} |
| 192 |
\newcommand{\xcsetauthor}[1]{\gdef\XCP@opt@author{#1}} |
| 193 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 194 |
\gdef\XCP@opt@markup{Underline} |
| 195 |
\newcommand{\xcsetmarkup}[1]{\gdef\XCP@opt@markup{#1}} |
| 196 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 197 |
\gdef\XCP@opt@color{1 1 0} |
| 198 |
\newcommand{\xcsetcolor}[1]{\gdef\XCP@opt@color{#1}} |
| 199 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 200 |
\gdef\XCP@opt@opacity{0} |
| 201 |
\newcommand{\xcsetopacity}[1]{\gdef\XCP@opt@opacity{#1}} |
| 202 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 203 |
\newcommand\XCP@citetp{\@ifnextchar[{\XCP@@citetp}{\XCP@@citetp[]}} |
| 204 |
|
| 205 |
\newcommand\XCP@@citetp{} |
| 206 |
\def\XCP@@citetp[#1]{\@ifnextchar[{\XCP@citex[#1]}{\XCP@citex[][#1]}} |
| 207 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 208 |
\newcommand\XCP@citex{} |
| 209 |
\gdef\XCP@citex[#1][#2]#3% |
| 210 |
{%{\protect\NoHyper% |
| 211 |
\ifXCP@useocg% |
| 212 |
\let\textCR\par% |
| 213 |
\XCP@enumeratetips{#3}% |
| 214 |
\XCP@ocgtooltip% |
| 215 |
{{{\protect\NoHyper\XCP@oldcite[#1][#2]{#3}\protect\endNoHyper}}}% |
| 216 |
{\XCP@tips}% |
| 217 |
\else% |
| 218 |
\XCP@enumeratetips{#3}% |
| 219 |
\pdftooltip{\XCP@oldcite[#1][#2]{#3}}{\XCP@tips}% |
| 220 |
\pdfmarkupcomment[% |
| 221 |
author=\XCP@opt@author,% |
| 222 |
markup=\XCP@opt@markup,% |
| 223 |
color=\XCP@opt@color,% |
| 224 |
opacity=\XCP@opt@opacity,% |
| 225 |
]{\vphantom{.}}{\XCP@tips}% |
| 226 |
\fi% |
| 227 |
}%\protect\endNoHyper}} |
| 228 |
|
| 229 |
\let\XCP@oldcite\citep % Save \citep (in the case if it becomes redefined) |
| 230 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 231 |
\let\xpdfcite\XCP@citetp |
| 232 |
\robustify{\xpdfcite} |
| 233 |
|
| 234 |
\AtBeginDocument{\nobibliography*} % Necessary to get bibentries. |
| 235 |
|
| 236 |
\ifXCP@redefcite % Override \cite |
| 237 |
\let\cite\xpdfcite |
| 238 |
\robustify{\cite} % Required for, e.g., captions |
| 239 |
\fi |
| 240 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 241 |
%% |
| 242 |
%% End of documentation driver file. |
| 243 |
%% |
| 244 |
%% End of file `xcpdftips.drv'. |