1

The following minimal example does not compile:

\documentclass{mnras}

\usepackage{pdfcomment}

\begin{document}
\section{\pdfcomment[color={1.0 0 0}]{title}}
\end{document}

That is, pdflatex shows the following error:

! Package xkeyval Error: `COLOR' undefined in families `pdfcomment'.

See the xkeyval package documentation for explanation.

Considering that MNRAS makes all text inside of the \section uppercase, I assume this is the source of the problem, i.e. the section macro parses the text and makes it uppercase before it gets parsed by pdfcomment.

Is there any way to get around this without redefining \section (or some related macro)?

For reference, I'm using TeXLive 2020.20210202-3 on Debian Unstable.

New contributor
JCGoran is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • 1
    I am not entirely convinced it is a good idea to put a pdf annotation inside the \section. I don't know about the MNRAS class, but sometimes the section title is also used in the table of contents and the header of the resulting document. Can you say what you hope to achieve? – Willie Wong May 4 at 19:11
1

You can put the comment in a command that you define first:

\documentclass{mnras}
\usepackage{pdfcomment}
\begin{document}
\def\seccomment{\pdfcomment[color={1.0 0 0}]{title}}
\section{\seccomment}
abc
\section{regular section}
def
\end{document}

enter image description here

3
  • 1
    this won't work well in the bookmarks, better use \section[title]{\pdfcomment ...} – Ulrike Fischer May 4 at 19:45
  • @UlrikeFischer that gives the same error as in the question. – Marijn May 4 at 19:49
  • yes, you are right, combine both ideas: use the optional argument and the command. – Ulrike Fischer May 4 at 20:01

Your Answer

JCGoran is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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