Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to use biblatex's \citetitle inside a \pdfmark so that the title of a citation pops up as a tooltip in PDFs.

Code looks like this:

%% A tooltip macro using pdfmark

% Creates a tooltip text.
%  arg #1 : the text to display
%  arg #2 : the text to show in the tooltip
      /TU (#2)/T (tooltip \thetooltip)%
      /FT/Btn/Ff 65536/H/N%

Now I can use the tooltip macro with regular text and with commands I create, for example:

% will show "some text" with "tooltip text" as tooltip on mouseover
\tooltip{some text}{tooltip text} 

% will show "Tooltip tooltip" as tooltip
\newcommand{\test}[1]{Tooltip #1}
\tooltip{some text}{\test{tooltip}}

However, if I use \citetitle, it does not expand:

% will show "\citetitle{key}" as tooltip
\tooltip{some text}{\citetitle{key}}

I tried adding some \expandafter at some places to no avail.

Also, inside my tooltip macro \citetitle gets expanded (e.g., if I use #2 outside \pdfmark). It seems that only inside the RAW argument it does not get expanded. On the other hand, my simple command gets expanded also in the RAW.

Since I do not know much about TeX, I was not able to debug the problem further, but it seems like some incompatibility between RAW and the way biblatex defines its macros. Any help?

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

The /TU argument of Raw expects unformatted text. Any citation command is devised to format bibliographic data, so the problem isn't really an issue with biblatex. You can access unformatted data using the biblatex commands \thefield, \thename and \thelist. The latter two return name and literal list fields, respectively. Unfortunately they don't give output suitable for printing.

Below we define the citation commands \tooltipcitefield and \tooltipcitename, which make use of \thefield and \thename. These macros have three arguments to specify the display text, field name and entry keys. If the specified field isn't labelnumber, the fields are prefixed with the label number wrapped in brackets.


    Raw={/TU (#2 )                % annotation text
         /T (tooltip \thetooltip) % annotation title
         /FT /Btn                 % button field
         /Ff 65536                % push button field flag
         /H /N                    % no highlighting




  {\iffieldundef{prenote}{}{\BibliographyWarning{Ignoring prenote argument}}}
     {\csxappto{cbx@tooltiptext}{[\thefield{labelnumber}] }}%
  {\csgappto{cbx@tooltiptext}{; }}
  {\iffieldundef{postnote}{}{\BibliographyWarning{Ignoring postnote argument}}}


    {\ifboolexpr{ test {\ifnumless{\value{listcount}}{\value{liststop}}}
                  or test \ifmorenames }
      {\csgappto{cbx@tooltiptext}{, }}
       \csgappto{cbx@tooltiptext}{ and }}}
  \ifuseprefix{\ifblank{#5}{}{\csgappto{cbx@tooltiptext}{#5 }}}{}%
  \ifboolexpr{ test {\ifnumequal{\value{listcount}}{\value{liststop}}}
               and test \ifmorenames }
     \csgappto{cbx@tooltiptext}{ et al.}}

  {\iffieldundef{prenote}{}{\BibliographyWarning{Ignoring prenote argument}}}
  {\csxappto{cbx@tooltiptext}{[\thefield{labelnumber}] }%
  {\csgappto{cbx@tooltiptext}{; }}
  {\iffieldundef{postnote}{}{\BibliographyWarning{Ignoring postnote argument}}}



Filler text \tooltipcitefield{\cite[e.g.][]{bertram,cicero}}{labeltitle}{bertram,cicero}.
Filler text \tooltipcitename{\cites[10--15]{bertram}[10]{cicero}}{labelname}{bertram,cicero}.
\tooltipcitefield{Tooltip titles}{labeltitle}{bertram,companion,cicero}.
\tooltipcitename{Tooltip names}{labelname}{companion,bertram,vangennep}.
\tooltipcitefield{\emph{Tooltip numbers}}{}{cicero,companion}.

Here's an image of the document taken from Adobe Reader after compiling with latex, bibtex, dvips and ps2pdf.

enter image description here

This solution has a few open problems.

  • Linebreaks. When the display text breaks across a line, the tooltip is applied only to the text after the linebreak. See the above document for an example.

  • Hyperlinks and tooltips. These don't combine well. As a workaround the citation commands apply the tooltip to the baseline of the display text. This area is about 3pt high. It can be made higher and be displayed on mouse rollover. Some details on the \pdfmark options can be found on D.P. Story's page.

  • Citations as display text. With the existing commands you have to specify the entry keys twice. Moreover the tooltip area includes pre- and postnotes and only one tooltip is assigned to citation lists. All of these problems probably can't be addressed with the workaround described above.

share|improve this answer
Thanks Audrey, that works exactly like I asked! Just forgot to add something to the question, perhaps you can help. If I do \tooltipcite{\cite{ctan}}{labeltitle}{ctan} then I get the tooltip, but the hyperref link does not work in the pdf. Is there a simple workaround? –  ttonelli Mar 13 '12 at 19:23
@ttonelli I think so, but I'll need to take a look. –  Audrey Mar 13 '12 at 19:44
Thanks! I should note that I am also using dvips and ps2pdf. Using Okular I can see tooltips in the dvi, unless the base text is \cite{} (then the tooltip says "go to page X"); in the pdf I cannot see the tooltips. Now, in Acrobat Reader (which is my goal), I can see the tooltip always, even if I use \cite{} for the base text. But then, the link does not work in Acrobat... –  ttonelli Mar 13 '12 at 20:06
@ttonelli The links work, but you have to click outside the tooltip area, toward the top of the link box. This isn't very user-friendly. The issue has been discussed at comp.text.tex. I think a workaround could be found if tooltip area can be made smaller. I'll look into this and make an edit to this answer when I find some time. If it's any consolation, I found a nice way to format name lists. So the edit will at least give you that. –  Audrey Mar 13 '12 at 20:27
Yes, I can confirm that I can follow the link by positioning the mouse at the top. Thanks again for the help! –  ttonelli Mar 13 '12 at 20:35
show 4 more comments

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.