1

When trying to use \listoftodos with colorinlistoftodos and ocgcolorlinks, text disappears from the list of todos. To be precise, the text is still there, I can copy it, but cannot see it – it becomes transparent. Without the colorinlistoftodos option or without ocgcolorlinks, everything works fine.

Why is this happening? Is there any workaround?

MWE:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[colorlinks]{hyperref}
\usepackage[ocgcolorlinks]{ocgx2}
\usepackage[colorinlistoftodos]{todonotes}

\begin{document}

Testing \todo{This is a todonote.}

\listoftodos

\end{document}

1 Answer 1

1

This is an edge case for ocgx2 with the ocgcolorlinks option, see https://gitlab.com/agrahn/ocgx2#package-option-ocgcolorlinks

Graphical objects in the link text need to be protected with command \ocglinkprotect{...}.

In the code below, the corresponding command from the todonotes is patched accordingly:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage[ocgcolorlinks]{ocgx2}
\usepackage[colorinlistoftodos]{todonotes}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\renewcommand{\@todonotes@addElementToListOfTodos}{%
    \if@todonotes@colorinlistoftodos%
        \addcontentsline{tdo}{todo}{%
            \ocglinkprotect{\fcolorbox{\@todonotes@currentbordercolor}%
                {\@todonotes@currentbackgroundcolor}%
                {\textcolor{\@todonotes@currentbackgroundcolor}{o}}}%
            \ \@todonotes@caption}%
    \else%
        \addcontentsline{tdo}{todo}{\@todonotes@caption}%
    \fi}%
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

Testing \todo{This is a todonote.}

\listoftodos

\end{document}

Another option could be hyperref option linktocpage, which turns only the page numbers into hyperlinks.

1
  • Thank you, that's exactly what I needed.
    – tomasmcz
    Commented Mar 9, 2021 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .