# Conflict of chemfig, babel and beamer?

I use the chemfig package with beamer for several years together with czech language set in babel. I am aware of the conflict between the babel shorthand that activates hyphen, and the chemfig reaction scheme environment. I have already solved (or used a solution of someone) the same problem for chemformula and for the simple arrows in the chemfig reaction schemes, but I can’t find the solution for using one particular feature of it:

\documentclass{beamer}
%\documentclass{article}
\usepackage[english,czech]{babel}\shorthandoff{-}
\usepackage{chemfig}
\usetikzlibrary{babel}
\author{TK}
%----- This resolves the problem for the article class ------------------------
\usepackage{etoolbox}
\pretocmd\schemestart{\shorthandoff{-}}{}{}
\apptocmd\schemestop{\shorthandon{-}}{}{}
%-----------------------------------------------------------
\begin{document}
\begin{frame}
%   \begin{tikzpicture}
%       \node{%
\schemestart
\subscheme{E\+S\arrow{<=>}ES\arrow{->}E\+P}
\arrow(@c2.197--){0}[-90,.2] +
\schemestop
%       };
%   \end{tikzpicture}
\end{frame}
\end{document}


The problem is the line \arrow(@c2.197--){0}[-90,.2] +, particularly the arrow argument in parentheses. Without it, everything goes well, except, of course, placing the invisible arrow and its target (the plus sign), which the argument should serve for.

In the article class everything works, in beamer there is an error, different when the scheme is embedded in a tikzpicture node or not.

In the tikzpicture, the error is

! Argument of \CF@arrow@a has an extra }.

<inserted text>

\par

l.22 \end{frame}

?

At the frame base level, the error is

! Paragraph ended before \CF@arrow@a was complete.

<to be read again>

\par

l.24

?

I have been unsuccessfully trying to solve this for a whole day…

Has anyone encountered the same problem?

Tomáš

I suspect the problem might be the @. You can workaround this by using a fragile frame.

\documentclass{beamer}
%\documentclass{article}
\usepackage[english,czech]{babel}\shorthandoff{-}
\usepackage{chemfig}
\usetikzlibrary{babel}
\author{TK}
%----- This resolves the problem for the article class ------------------------
\usepackage{etoolbox}
\pretocmd\schemestart{\shorthandoff{-}}{}{}
\apptocmd\schemestop{\shorthandon{-}}{}{}
%-----------------------------------------------------------
\begin{document}
\begin{frame}[fragile]
%   \begin{tikzpicture}
%       \node{%
\schemestart
\subscheme{E\+S\arrow{<=>}ES\arrow{->}E\+P}
\arrow(@c2.197--){0}[-90,.2] +
\schemestop
%       };
%   \end{tikzpicture}
\end{frame}
\end{document}

• Thank you very much, you were really quick! It works perfectly with my MWO, unfortunately not with the real-life code from which it was extracted. I am going to check dependences on other packages. – arecuk Nov 6 '18 at 8:29
• @arecuk If you can make a MWE that demonstrates your new problem, I could have a look – user36296 Nov 6 '18 at 9:18
• Thanks, it’s no longer necessary. I have just found it! When trying to identify the problem, I put some \shorthandoffs and \shorthandons to some other files that I \input and forgot to remove two of them… Now it perfectly works! – arecuk Nov 6 '18 at 12:32