1

I tried to hide some text into a pdftooltip, which was working fine up to now (when I used TeXLive 2011).

I now upgraded to MacTeX 2014 and now I get an error, if there is a chemical formula in this hidden Text.

Minimal example:

\documentclass[11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage{hyperref} 
\usepackage[pdftex]{graphicx} 
\usepackage{color} 

\usepackage[T1]{fontenc} 
\usepackage[version=3]{mhchem} 
\usepackage{pdfcomment}

\newcommand{\weg}[1]{\pdftooltip{\textcolor{red}{\tiny\bfseries{}w}}{#1}}


\begin{document}

\ce{CO2}

the following text is hidden: \weg{hidden text \ce{CO2}}

\end{document}

I'm using MacTeX 2014 and I get the following error:

   ./MinimalExample.tex:19: Undefined control sequence. \mhchem@ce ...ate
   {s}\chardef \mhchem@ce@substate 
   =0\relax \mhchem@ce@result... l.19   ...text is hidden: \weg{hidden text
   \ce{CO2}}

How can I solve that?


EDIT: with TeXLive 2011, there was no error message, but the chemical formula was not correctly written in the pdftooltip, e. g. \ce{ZrO2} became *"3222378 * . Now with Josef's solution, at least the characters of the formula seem to be printed correctly in the tooltip.

1
  • This is Martin Hensel, the author of mhchem. Oh dear, that looks complicated. Unfortunately, I cannot offer a solution immediately. (I am about to rewrite some core parts completely, BTW.) I did not use pdfcomment before. It's kind of surprising that it worked before, because \pdfcomment cannot hande any math and \ce is using math mode internally. What was the output with your TeXLive 2011?
    – user65640
    Nov 5, 2014 at 6:50

1 Answer 1

3

It might be a good idea to contact Martin Hensel, the maintainer of mhchem! pdfcomment was not updated for quite a while. So, I guess the problem was introduced with an update of mhchem!

As a workaround for the moment, simply add \pdfstringdefDisableCommands{\let\ce\relax} to your preamble. That's not a solution but your document will compile at least.

enter image description here

1
  • thanks, good idea! The workaround lets the document compile and I've contacted Martin Hensel Nov 4, 2014 at 14:12

You must log in to answer this question.

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