有没有办法在 cooltooltips 参数中包含图形?比如
\cooltooltip[0.5 0.25 1]{Example}%
{\includegraphics{graphic}}%
{http://www.panoramio.com/user/4366708}{Visit my site}{My Name\strut}
提前致谢。
答案1
不可以,\cooltooltip
来自同名包的宏不能,但\coolToolTip
下面定义的宏可以。它采用与原始宏相同的参数:
\coolToolTip[<popup colour>][<link colour>]
{<subject>}
{<message>}
{<URL>}
{<tooltip>}
{<link text>}
点击消息框后,URL 会在单独的浏览器窗口中打开。
\documentclass[12pt,oneside]{scrbook}
\usepackage{graphicx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% usage:
%
% \coolToolTip[<popup colour>][<link colour>]{<subject>}{<message>}{<URL>}{<tooltip>}{<link text>}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{media9}
\usepackage{calc}
\usetikzlibrary{calc}
\ExplSyntaxOn
\let\tpPdfLink\mix_pdflink:nn
\let\tpPdfAnnot\mix_pdfannot:nnnn\def\tpPdfLastAnn{\g_mix_pdflastann_tl}
\let\tpPdfXform\mix_pdfxform:n\def\tpPdfLastXform{\g_mix_pdflastxform_tl}
\let\tpPdfObj\mix_pdfobj:nnn\def\tpPdfLastObj{\g_mix_pdflastobj_tl}
\ExplSyntaxOff
\makeatletter
\NewDocumentCommand{\coolToolTip}{O{0 1 0}O{0 1 0}mmmmm}{{%
\leavevmode%
\tpPdfObj{}{dict}{/Type/OCG/Name (tipOCG.\thetcnt)%
/Usage<</Print<</PrintState/OFF>>/Export<</ExportState/OFF>>>>%
}%
\xdef\@anim@ocgs{\@anim@ocgs\space\tpPdfLastObj}%
\xdef\@anim@offocgs{\@anim@offocgs\space\tpPdfLastObj}%
\edef\tpTipOcg{\tpPdfLastObj}%
\tpPdfObj{}{dict}{/Type/OCG/Name (msgOCG.\thetcnt)%
/Usage<</Print<</PrintState/OFF>>/Export<</ExportState/OFF>>>>%
}%
\xdef\@anim@ocgs{\@anim@ocgs\space\tpPdfLastObj}%
\xdef\@anim@offocgs{\@anim@offocgs\space\tpPdfLastObj}%
\edef\tpMsgOcg{\tpPdfLastObj}%
\tpPdfLink{%
/Subtype/Screen%
/AA<<%
/E<</S/SetOCGState/State [/ON \tpTipOcg]>>%
/X<</S/SetOCGState/State [/OFF \tpTipOcg]>>%
/D<</S/SetOCGState/State [/Toggle \tpMsgOcg]>>%
>>%
}{{\color[rgb]{#2}#7}}%
\sbox\tiptext{\fcolorbox[rgb]{0 0 0}{1 1 0.75}{#6}}%
\edef\twd{\the\wd\tiptext}%
\edef\tht{\the\ht\tiptext}%
\edef\tdp{\the\dp\tiptext}%
\measureremainder{\whatsleft}\tipshift=0pt%
\ifdim\whatsleft<\twd\setlength\tipshift{\whatsleft-\twd}\fi%
\tpPdfXform{\tiptext}%
\raisebox{\heightof{#7}}[0pt][0pt]{\makebox[0pt][l]{\hspace{\tipshift}%
\tpPdfAnnot{\twd}{\tht}{\tdp}{%
/Subtype/Widget/FT/Btn/Ff 65537/T (tip:\thetcnt)%
/AP<</N \tpPdfLastXform>>%
/MK<</TP 1/I \tpPdfLastXform/IF<</S/A/FB true/A [0.0 0.0]>>>>%
/OC \tpTipOcg
}%
\xdef\@anim@fields{\@anim@fields\space\tpPdfLastAnn}%
}}%
\sbox\tiptext{\fcolorbox[rgb]{0 0 0}{#1}{\vbox{\hbox{#3}\hbox{#4}}}}%
\edef\twd{\the\wd\tiptext}%
\edef\tht{\the\ht\tiptext}%
\edef\tdp{\the\dp\tiptext}%
\measureremainder{\whatsleft}\tipshift=0pt%
\ifdim\whatsleft<\twd\setlength\tipshift{\whatsleft-\twd}\fi%
\tpPdfXform{\tiptext}%
\raisebox{\heightof{#7}}[0pt][0pt]{\makebox[0pt][l]{\hspace{\tipshift}%
\tpPdfAnnot{\twd}{\tht}{\tdp}{%
/Subtype/Widget/FT/Btn/Ff 65536/T (msg:\thetcnt)%
/AP<</N \tpPdfLastXform>>%
/MK<</TP 1/I \tpPdfLastXform/IF<</S/A/FB true/A [0.0 0.0]>>>>%
/A<</S/URI/URI (#5)>>%
/OC \tpMsgOcg
}%
\xdef\@anim@fields{\@anim@fields\space\tpPdfLastAnn}%
}}%
\stepcounter{tcnt}%
}}
\makeatother
\newsavebox\tiptext\newcounter{tcnt}
\newlength{\whatsleft}\newlength{\tipshift}
\newcommand{\measureremainder}[1]{%
\begin{tikzpicture}[overlay,remember picture]
\path let \p0 = (0,0), \p1 = (current page.east) in
[/utils/exec={\pgfmathsetlength#1{\x1-\x0}\global#1=#1}];
\end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
Join the \coolToolTip[0.8 0.4 1][0 0 1]{\small Visit:}{\includegraphics[width=2cm]{tuglogo}}{http://www.tug.org}{\small Visit the TUG}{TUG}!
\end{document}