我想画一个自由基反应机制,显然箭头应该从孤电子开始,而不是从相应的原子开始。我该如何实现呢?
这是我的代码:
\documentclass[a4paper,10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{chemfig}
\usepackage{chemmacros}
\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}
\setatomsep{2em}
\setdoublesep{.6ex}
\setbondstyle{semithick}
\usetikzlibrary{arrows}
\usetikzlibrary{calc,arrows.meta}
\tikzset{myedge/.style={->, -{Latex[#1]}}}
\begin{document}
\section{B}
\schemestart
\chemfig{@{r1}\lewis{0.,Rad}}
\+
\chemfig{R^1(-[@{r2a}::125,,,,draw=none])(-[@{r2b}::145,,,,draw=none])-@{r4}C(-[@{r3}::90]H)(-[270]H)-O-R^2}
\schemestop
\chemmove[->,shorten <=2pt]{
\draw[-left to,shorten >=2pt](r3)..controls +(60:5mm)and+(40:5mm)..(r4);
\draw[-right to,shorten >=2pt](r3)..controls +(120:5mm)and+(north:5mm)..(r2a);
\draw[-left to,shorten >=2pt](r1)..controls +(45:15mm)and+(north:5mm)..(r2b);
}
\end{document}
注意:目前,箭头对应于第三个“\draw”命令,从“Rad”的中间开始并指向上方。
答案1
我稍微整理了一下代码。
\documentclass{standalone}
\usepackage{chemfig}
% this is the position of the current electron being drawn with a dot
\makeatletter
\def\electrondotposition%
{\CF@lewis@x pt+\CF@lewis@xoffset*\CF@lewis@current@offset,%
\CF@lewis@y pt+\CF@lewis@yoffset*\CF@lewis@current@offset}
\makeatother
% hijacking the lewis style to insert a coordinate for later reference
\setlewis{0.2ex}{1.5ex}% these are just defaults
{red,insert path={coordinate (lastelectrondot) at (\electrondotposition)}}
\begin{document}
\schemestart
\chemfig{@{r1}\lewis{0.,Rad}} \+
\chemfig%
{R^1(-[@{r2a}::125,,,,draw=none])%
(-[@{r2b}::145,,,,draw=none])-@{r4}%
C(-[@{r3}::90]H)(-[270]H)-O-R^2}
\schemestop
\chemmove[shorten <=4pt]{
\draw (r3) .. controls +( 60:5mm) and +( 40:5mm) .. (r4);
\draw (r3) .. controls +(120:5mm) and +(north:5mm) .. (r2a);
\draw [shorten <=0pt]
(lastelectrondot) .. controls +(45:15mm) and +(north:5mm) .. (r2b);
}
\end{document}
结果如下:
坐标lastelectrondot
总是给出绘制的最后一个电子的准确中心。它只跟踪最后一个电子,因为它会被新的电子覆盖。
此外,这只适用于点语法该\lewis
命令。
可以采用更通用的解决方案,但它并不简单,而且足以解决您的问题。