我正在使用该chemfig
包进行一些化学反应,我需要绘制如下所示的箭头:
本质上是\arrow{-U>}
,但弯曲的箭头位于直箭头下方。我找到了一个解决方案这篇先前的文章当我在 Overleaf 上尝试时,它运行良好,但在我自己的 TeX 安装(TeXLive 2019,Windows 10)上却无法运行。每次我尝试时,都会收到几个“未定义的控制序列”错误。
知道为什么这不起作用以及如何修复它吗?除此之外,还有其他方法可以得到我想要的箭头吗?
这是一个 MWE(从上面的链接复制):
\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
如果你查看chemfig
手册,你会发现在第 1.3 节中 private char 已从 更改为@
,_
第 10 节中指定了更多详细信息。按照那里的说明,可以得到
\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}