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.

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? 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

6
  • 1
    this won't work well in the bookmarks, better use \section[title]{\pdfcomment ...} 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. May 4 at 20:01
  • Is it possible to do this without "polluting" the preamble (i.e. namespace) with defs? My current workaround is to put \usepackage[color={1.0 0 0}]{pdfcomment}, and call \pdfcomment without options, which then compiles successfully. Unfortunately, then the text inside the comment becomes uppercase, so it's only a partial fix.
    – JCGoran
    May 18 at 16:19
  • @JCGoran I imagine that in your real document you have both an actual title and a comment, and the title should stay in upper case while the comment should be left as it is - so \section{a title\pdfcomment{comment about the title}}, for which the first a title should be uppercased. Is that correct? If yes then it is a bit tricky, because the uppercasing should be switched off only partially.
    – Marijn
    May 18 at 17:48

Your Answer

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.