5

I am using showkeys and unicode-math packages but got the following error

! Missing $ inserted.

This is a minimal example:

\documentclass{article}
\usepackage{showkeys}
\usepackage{unicode-math}
%\setmathfont{texgyrepagella-math.otf}
\begin{document}
\begin{figure}
\caption{something}\label{fig}
\end{figure}
\ref{fig}
\end{document}
6

showkeys relies on the fact that \underbar can be used also in text, which is not true any more for \underbar as redefined by unicode-math.

Workaround: save the original meaning of \underbar and make showkeys use it instead of the redefined \underbar.

\documentclass{article}
\usepackage{showkeys,etoolbox}
\makeatletter
\let\latex@underbar\underbar
\patchcmd{\SK@@ref}{\underbar}{\latex@underbar}{}{}
\makeatother

\usepackage{unicode-math}
%\setmathfont{texgyrepagella-math.otf}
\begin{document}
\begin{figure}
\caption{something}\label{fig}
\end{figure}
\ref{fig}
\end{document}

enter image description here

Who's at fault? I point to showkeys that uses the undocumented \underbar command, which is present in the LaTeX kernel just because it is in Plain and in the olden times users frequently transferred documents from Plain TeX to LaTeX.

  • 2
    Surely it must be the other guy's fault! (anyway showkeys is older than latex2e:-) – David Carlisle Oct 22 '14 at 12:07

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.