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.

  • 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 '14 at 6:50
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

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

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.