我知道存在允许 Lewis 结构的软件包,但这不是问题所在。问题是如何说明如下所示的自由基反应。解决方案最好排版为内联文本,而不是图片。解决方案不应涉及 TikZ。
编辑:最好使用预定义宏的解决方案。“基于图片”的解决方案(如 TikZ)太复杂了,因为一切都必须从头开始定义。
答案1
也许,chemfig 包可能会帮到你,尽管它依赖于 tikz?这是第一个反应:
\documentclass{minimal}
\usepackage{chemfig}
\begin{document}
text before
\schemestart
\setlewis{4pt}{}{red}\Lewis{0:,\chemfig{@{a}\textcolor{red}{A}}}\hskip4pt\chemfig{@{b}\textcolor{black!40!green}{B}}%
\arrow
\Lewis{0.,A}%
\+\Lewis{4.,B}%
\chemmove{\draw[red,-stealth]([xshift=9pt]a.90)..controls+(90:10pt) and +(90:10pt)..([yshift=2pt]a.90);
\draw[black!40!green,-stealth]([xshift=9pt]a.-90)..controls+(-90:10pt) and +(-90:10pt)..([yshift=-2pt]b.-90);}%
\schemestop
\end{document}
不幸的是,几分钟前我发现了 chemfig 中的一个错误,因此不可能让电子着色(我认为这是可能的)!
编辑:这是针对 chemfig 命令的快速修复\lewis
:
\documentclass{minimal}
\usepackage{chemfig}
\makeatletter
\def\CF@lewis@ii#1,#2\@nil#3{%
\setbox\CF@lewis@box\hbox{\printatom{#2}}%
\node(CF@lewis@anchor){};
\def\CF@lewis@remainpos{#1}%
\let\CF@lewis@previouspos\@empty
\loop
\unless\ifx\CF@lewis@remainpos\@empty
\edef\CF@lewis@currentpos{\expandafter\@car\CF@lewis@remainpos\@nil}%
\edef\CF@lewis@remainpos{\expandafter\@gobble\CF@lewis@remainpos}%
\pgfmathparse{\wd\CF@lewis@box/2+\ifcase\CF@lewis@currentpos\space1\or1\or0\or-1\or-1\or-1\or0\or1\fi*(\wd\CF@lewis@box/2+\CF@lewis@offset)}%
\let\CF@lewis@x\pgfmathresult
\pgfmathparse{\ht\CF@lewis@box/2+\ifcase\CF@lewis@currentpos\space0\or1\or1\or1\or0\or-1\or-1\or-1\fi*(\ht\CF@lewis@box/2\ifnum\CF@lewis@currentpos>4 +\dp\CF@lewis@box\fi+\CF@lewis@offset)}%
\let\CF@lewis@y\pgfmathresult
\edef\CF@lewis@xoffset{\ifcase\CF@lewis@currentpos\space
0\or0.70711\or1\or0.70711\or0\or-0.70711\or-1\or-0.70711\fi}%
\edef\CF@lewis@yoffset{\ifcase\CF@lewis@currentpos\space
-1\or-0.70711\or0\or0.70711\or1\or0.70711\or0\or-0.70711\fi}%
\pgfmathparse{veclen(\CF@lewis@xoffset,\CF@lewis@yoffset)}\let\CF@len@normvec\pgfmathresult
\edef\CF@lewis@diagmul{\ifcase\CF@lewis@currentpos\space1\or0\or1\or0\or1\or0\or1\or0\fi}% annule l'offset pour les diagonales
\if.\expandafter\@car\CF@lewis@remainpos\relax\@nil
\edef\CF@lewis@remainpos{\expandafter\@gobble\CF@lewis@remainpos}%
\CF@expand@afterfirst{\draw[fill,black,}{\CF@lewis@style,#3]}%
(\CF@lewis@x pt-\CF@lewis@yoffset*\CF@lewis@diagmul*0.1ex,
\CF@lewis@y pt+\CF@lewis@xoffset*\CF@lewis@diagmul*0.1ex)circle(0.15ex);%
\else
\if|\expandafter\@car\CF@lewis@remainpos\relax\@nil
\edef\CF@lewis@remainpos{\expandafter\@gobble\CF@lewis@remainpos}%
\expandafter\draw\expandafter[\CF@lewis@style,#3]%
(\CF@lewis@x-\CF@lewis@length*\CF@lewis@xoffset/2 pt,\CF@lewis@y-\CF@lewis@length*\CF@lewis@yoffset/2 pt)--
([xshift=-\CF@lewis@yoffset*\CF@lewis@widthdouble,yshift=\CF@lewis@xoffset*\CF@lewis@widthdouble]\CF@lewis@x-\CF@lewis@xoffset*\CF@lewis@length/2 pt,\CF@lewis@y-\CF@lewis@yoffset*\CF@lewis@length/2 pt)--
([xshift=-\CF@lewis@yoffset*\CF@lewis@widthdouble,yshift=\CF@lewis@xoffset*\CF@lewis@widthdouble]\CF@lewis@x+\CF@lewis@length*\CF@lewis@xoffset/2 pt,\CF@lewis@y+\CF@lewis@length*\CF@lewis@yoffset/2 pt)--
(\CF@lewis@x+\CF@lewis@length*\CF@lewis@xoffset/2 pt,\CF@lewis@y+\CF@lewis@length*\CF@lewis@yoffset/2 pt)--cycle;%
\else
\if:\expandafter\@car\CF@lewis@remainpos\relax\@nil
\edef\CF@lewis@remainpos{\expandafter\@gobble\CF@lewis@remainpos}%
\CF@expand@afterfirst{\draw[fill,black,}{\CF@lewis@style,#3]}%
(\CF@lewis@x pt-\CF@lewis@yoffset*\CF@lewis@diagmul*0.2ex-.2em*\CF@lewis@xoffset/\CF@len@normvec,\CF@lewis@y pt+\CF@lewis@xoffset*\CF@lewis@diagmul*0.2ex-.2em*\CF@lewis@yoffset/\CF@len@normvec)circle(0.15ex)%
(\CF@lewis@x pt-\CF@lewis@yoffset*\CF@lewis@diagmul*0.2ex+.2em*\CF@lewis@xoffset/\CF@len@normvec,\CF@lewis@y pt+\CF@lewis@xoffset*\CF@lewis@diagmul*0.2ex+.2em*\CF@lewis@yoffset/\CF@len@normvec)circle(0.15ex);%
\else
\expandafter\draw\expandafter[\CF@lewis@style,#3]%
(\CF@lewis@x-\CF@lewis@length*\CF@lewis@xoffset/2 pt,\CF@lewis@y-\CF@lewis@length*\CF@lewis@yoffset/2 pt)--%
(\CF@lewis@x+\CF@lewis@length*\CF@lewis@xoffset/2 pt,\CF@lewis@y+\CF@lewis@length*\CF@lewis@yoffset/2 pt);%
\fi
\fi
\fi
\repeat
\node[anchor=base west]at(CF@lewis@anchor){\box\CF@lewis@box};%
\endtikzpicture
}
\makeatother
\begin{document}
text before
\schemestart
\rlap{\setlewis{4pt}{}{red,yshift=1.5pt}\Lewis{0.,\chemfig{@{a}\textcolor{red}{A}}}}%
\setlewis{4pt}{}{black!40!green,yshift=-1.5pt}\Lewis{0.,\chemfig{@{a}\phantom{A}}}%
\hskip4pt\chemfig{@{b}\textcolor{black!40!green}{B}}%
\arrow
\setlewis{}{}{red}\Lewis{0.,\textcolor{red}{A}}%
\setlewis{}{}{black!40!green}\+\Lewis{4.,\textcolor{black!40!green}{B}}%
\chemmove{\draw[red,-stealth]([xshift=8.5pt]a.90)..controls+(90:10pt) and +(90:10pt)..([yshift=2pt]a.90);
\draw[black!40!green,-stealth]([xshift=8.5pt]a.-90)..controls+(-90:10pt) and +(-90:10pt)..([yshift=-2pt]b.-90);}%
\schemestop
\vspace{1cm}
text before
\schemestart
\setlewis{4pt}{}{blue}\Lewis{0:,\chemfig{\textcolor{red}{A}}}\hskip4pt\chemfig{@{bb}\textcolor{blue}{B}}%
\arrow
\chemfig[red]{A^+}\+\chemfig[blue]{\setlewis{}{}{blue}\Lewis{4:,B^{-}}}%
\chemmove{\draw[blue,-stealth]([xshift=-8.5pt]bb.90)..controls+(90:10pt) and +(90:10pt)..([yshift=2pt]bb.90);}%
\schemestop
\end{document}
输出为: