4

I'm using the chemfig package for some chemical reactions and I need to draw an arrow like the one below:

enter image description here

It's essentially \arrow{-U>} but with the curved arrow positioned below the straight one. I found a solution in this previous post which works perfectly when I try it on Overleaf, but it does not work on my own TeX installation (TeXLive 2019, Windows 10). Every time I try it I get several "undefined control sequence" errors.

Any idea on why this isn't working and how to fix it? Barring that, is there any other way I can get the kind of arrow I want?

Here's an MWE (copied from the link above):

\documentclass{article}
\usepackage{chemfig}

\makeatletter
\definearrow5{-u>}{%
    \CF@arrow@shift@nodes{#3}%
    \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node)--(\CF@arrow@end@node)node[midway](uarrow@arctangent){};%
    \CF@ifempty{#4}
    {\def\CF@uarrow@radius{0.333}}
    {\def\CF@uarrow@radius{#4}}%
    \CF@ifempty{#5}%
    {\def\CF@uarrow@absangle{60}}
    {\pgfmathsetmacro\CF@uarrow@absangle{abs(#5)}}
    %
    \edef\CF@tmp@str{[\CF@ifempty{#1}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-]}%
    \expandafter\draw\CF@tmp@str (uarrow@arctangent)%
    arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@uarrow@radius,start angle=\CF@arrow@current@angle+90,delta angle=\CF@uarrow@absangle]node(uarrow@start){};
    %
    \edef\CF@tmp@str{[\CF@ifempty{#2}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-CF]}%
    \expandafter\draw\CF@tmp@str (uarrow@arctangent)%
    arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@uarrow@radius,%
    start angle=\CF@arrow@current@angle+90,%
    delta angle=-\CF@uarrow@absangle]%
    node(uarrow@end){};
    \pgfmathsetmacro\CF@tmp@str{\CF@uarrow@radius*cos(\CF@arrow@current@angle)<0?"+":"-"}%
    \ifdim\CF@uarrow@radius pt>\z@
    \CF@arrow@display@label{#1}{0}\CF@tmp@str{uarrow@start}{#2}{1}\CF@tmp@str{uarrow@end}%
    \else
    \CF@arrow@display@label{#2}{0}\CF@tmp@str{uarrow@start}{#1}{1}\CF@tmp@str{uarrow@end}%
    \fi
}
\makeatother

\begin{document}
    \begin{center}
%       \schemedebug{true} % Activate if you want to see the nodes etc.
        \schemestart
        \arrow{-u>[$x$][$y$][][.5][]}
        \schemestop
    \end{center}
\end{document}

1 Answer 1

4

If you look into the chemfig manual, then you will find on in section 1.3 that the private char has changed from @ to _, with more details specified in section 10. Following the instructions there, one gets

\documentclass{article}
\usepackage{chemfig}

\makeatletter\catcode`\_=11
\definearrow5{-u>}{%
    \CF_arrowshiftnodes{#3}%
    \expandafter\draw\expandafter[\CF_arrowcurrentstyle](\CF_arrowstartnode)
    --(\CF_arrowendnode)node[midway](uarrow@arctangent){};%
    \CF_ifempty{#4}
    {\def\CF_uarrowradius{0.333}}
    {\def\CF_uarrowradius{#4}}%
    \CF_ifempty{#5}%
    {\def\CF_uarrowabsangle{60}}
    {\pgfmathsetmacro\CF_uarrowabsangle{abs(#5)}}
    %
    \edef\CF_tmpstr{[\CF_ifempty{#1}{draw=none}{\unexpanded\expandafter{\CF_arrowcurrentstyle}},-]}%
    \expandafter\draw\CF_tmpstr (uarrow@arctangent)%
    arc[radius=\CF_compoundsep*\CF_currentarrowlength*\CF_uarrowradius,start angle=\CF_arrowcurrentangle+90,delta angle=\CF_uarrowabsangle]node(uarrowstart){};
    %
    \edef\CF_tmpstr{[\CF_ifempty{#2}{draw=none}{\unexpanded\expandafter{\CF_arrowcurrentstyle}},-CF]}%
    \expandafter\draw\CF_tmpstr (uarrow@arctangent)%
    arc[radius=\CF_compoundsep*\CF_currentarrowlength*\CF_uarrowradius,%
    start angle=\CF_arrowcurrentangle+90,%
    delta angle=-\CF_uarrowabsangle]%
    node(uarrowend){};
    \pgfmathsetmacro\CF_tmpstr{\CF_uarrowradius*cos(\CF_arrowcurrentangle)<0?"+":"-"}%
    \ifdim\CF_uarrowradius pt>\z@
    \CF_arrowdisplaylabel{#1}{0}\CF_tmpstr{uarrowstart}{#2}{1}\CF_tmpstr{uarrowend}%
    \else
    \CF_arrowdisplaylabel{#2}{0}\CF_tmpstr{uarrowstart}{#1}{1}\CF_tmpstr{uarrowend}%
    \fi
}
\catcode`\_=8
\makeatother

\begin{document}
    \begin{center}
%       \schemedebug{true} % Activate if you want to see the nodes etc.
        \schemestart
        \arrow{-u>[$x$][$y$][][.5][]}
        \schemestop
    \end{center}
\end{document}

enter image description here

1
  • Yep that's it! It should have occurred to me that something must have changed in the definitions in between updates, but I guess it didn't. Thank you so much.
    – johnymm
    Sep 8, 2019 at 5:23

You must log in to answer this question.

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