# How can I get Lewis-like structures + illustrate electron transfer

I know about the existence of packages that allow Lewis structures but that is not the question. The question is how to illustrate radical reactions as depicted below. The solution would ideally be typeset as inline text, not a picture. The solution should not involve TikZ.

Edit: A solution which uses a pre-defined macro is preferred. "Picture-based" solutions like TikZ are just too involved because everything has to be defined from scratch.

-
I'm not sure how you can draw the curly arrows without either using specials (either PostScript or PDF) or creating a suitable font. The specials route suggests a picture, which you've ruled out, so this is a bit of a poser. – Joseph Wright Jul 1 '11 at 5:14
@Joseph Wright: The reason for my ruling out of "picture-based" approaches was because I wanted to avoid heavy-handed solutions like TikZ, which generate things from scratch and really take clutter in your latex document to a whole new level. I was hopeful an existing chemistry package would allow radical reactions to be depicted. I'd be surprised if this wasn't possible...? What do you think? Ultimately, if no package does this to your knowledge, feel free to suggest a solution that isn't too elaborate, so a novice like me can follow. – ptrcao Jul 1 '11 at 5:24
I'm realy not sure how you can do that without something special. The suitable font is perhaps a solution but I do not believe. Inline solutiob with Tikz is not a problem but I think in this case you need to have a good baseline (see your picture) Now if you want on another domain, see example of what you can do without heavy-handed solutions, looks at elishapeterson.wikidot.com/tikz:diagrams Tikz can avoid heavy-handed solutions. – Alain Matthes Jul 1 '11 at 5:50
It seems to me that you wouldn't mind using TikZ as such, but would like an already finished package utilizing it. – ipavlic Jul 1 '11 at 7:36
Yes, that's correct. Thanks for following. :) – ptrcao Jul 1 '11 at 7:46

Pershaps, the chemfig package may help you though it relies on tikz? Here is the first reaction:

\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}


Unfortunately, it is impossible to have electrons colored (which I thought it was possible) because of a bug in chemfig I discovered a few minutes ago!

EDIT: here is a quick fix for chemfig about the \lewis command:

\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}


The output is:

-
:) A bug? Could you please report it to the package author/maintainer, as I wouldn't know what to say? Maybe they'll be willing to fix it. I got the impression the maintainer of chemfig was reasonably active. – ptrcao Jul 1 '11 at 7:48
Did it compile for you? I got an error: ! Undefined control sequence. l.5 \schemestart – ptrcao Jul 1 '11 at 7:57
@ptrcao I am the author and maintainer of chemfig. If you cannot compile the code, plase, update your latex distribution to works with the latest version 1.0 of chemfig, uploaded in then CTAN the 2011/06/15. – unbonpetit Jul 1 '11 at 9:46
My TL2010 manager says there is no update available? Local ver=0.4b, remote ver=0.4b. tlmgr: no updates available – ptrcao Jul 1 '11 at 9:47
@ptrcao Just add \usetikzlibrary{arrows} in the preamble after \usepackage{chemfig} and replace the arrow stealth by left to or right to. – unbonpetit Jul 1 '11 at 14:34