I have used TikZ to define an extensible arrow interrupted by symbols similar to \xrightarrow.
\documentclass{article}
\usepackage{tikz}
\newcommand{\oprightarrow}[1]{%
\mathbin{%
\tikz[baseline=-3pt]{%
\node[text depth=0,inner sep=1.5pt] (n) {\ensuremath{\scriptstyle #1}};%
\draw (n.west) -- +(-.7em,0);%
\draw[->] (n.east) -- +(.7em,0);%
}}}
\begin{document}
\begin{figure}
\caption{$P\oprightarrow{\varphi}Q$}
\end{figure}
$P\oprightarrow{\varphi} Q$
\end{document}
While this works fine in normal situations, I encounter an error while using it in a figure's caption:
./test_mwe.tex:16: Undefined control sequence.
\tikz@deactivatthings ->\def ;
{\tikz@nonactivesemicolon }\def :{\tikz@nonact...
l.16 \caption{$P\oprightarrow{\varphi}Q$}
./test_mwe.tex:16: Undefined control sequence.
\tikz@deactivatthings ...onactivesemicolon }\def :
{\tikz@nonactivecolon }\de...
l.16 \caption{$P\oprightarrow{\varphi}Q$}
./test_mwe.tex:16: Undefined control sequence.
\tikz@deactivatthings ...kz@nonactivecolon }\def |
{\tikz@nonactivebar }\def ...
l.16 \caption{$P\oprightarrow{\varphi}Q$}
./test_mwe.tex:16: Undefined control sequence.
\tikz@deactivatthings ...tikz@nonactivebar }\def !
{\tikz@nonactiveexlmark }
l.16 \caption{$P\oprightarrow{\varphi}Q$}
I know that there can be trouble mixing babel and tikz, e.g. with french language making the colon and semi-colon become active characters. But this seems to be something different.
FWIW, the caption is typeset correctly.
Any ideas?


\DeclareRobustCommand{\oprightarrow}[1]{...}– egreg Aug 06 '15 at 09:34