\pdfmarkupcomment not working with \cite- or \ref-commands

Issue #6 on hold
Former user created an issue

Hi,

LaTeX(mk) gives me errors when using \cite or \ref-commands in a section I would like to markup using \pdfmarkupcomment.

Any help would be appreciated!

Thanks,

Janosch

Comments (2)

  1. Josef Kleber repo owner

    To calculate the positions, pdfcomment is using soul. Its parser is known for choking on macros. Unfortunately, there will be likely no update to soul. There are just some work-a-rounds, like extra curly braces for \ref. For \cite, there's just an ugly work-a-round:

    \documentclass[10pt]{article}
    \usepackage{xcolor}
    \usepackage[author={John Doe},color=yellow]{pdfcomment}
    % turn off hyperlinks for ref and cite
    %\hypersetup{draft}
    \usepackage{filecontents}
    \usepackage{soul}
    %should work, but does not (soul doc)
    %\soulregister{\ref{1}
    %\soulregister{\cite}{1}
    % work-a-round
    \soulregister{\myref}{0}
    \soulregister{\mycite}{0}
    \def\myref{\ref{x}}
    \def\mycite{\cite{DUMMY:1}}
    %
    \begin{document}
    \setlength\parindent{0pt}
    \begin{filecontents}{test.bib}
    @BOOK{DUMMY:1,
    AUTHOR="John Doe",
    TITLE="The Book without Title",
    PUBLISHER="Dummy Publisher",
    YEAR="2000",
    }
    \end{filecontents}
    \section{x}\label{x}
    \section{y}
    % additional braces work for \ref
    Some text. Section~\pdfmarkupcomment{{\ref{x}}}{my ref}.
    
    % but also the work-a-round
    Some text. Section~\pdfmarkupcomment{\myref}{my ref}.
    
    % additional braces do not work for \cite
    %Random citation \pdfmarkupcomment{{\cite{DUMMY:1}}{my cite} embeddeed in text.
    
    % but the work-a-round works
    Random citation \pdfmarkupcomment{\mycite}{my cite} embeddeed in text.
    
    \bibliography{test} 
    \bibliographystyle{ieeetr}
    \end{document}
    

    minimal.jpg

  2. Log in to comment