# Incompatiblity between pdfcomment options and MNRAS sections

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.
• 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

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}


• 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