# Which chemistry package can be used for Lewis formulae and electron movement arrows?

I wanted to reproduced this set of steps for my thesis but I have no idea what package can do this. I am a newbie to latex I only started a few weeks ago.

• You have tagged it already: chemfig. Search the manual for Representing electron movements and Lewis diagrams. If your question is how to use chemfig for this we'd really appreciate a minimal working example! – clemens Sep 6 '14 at 17:07
• that's the problem I don't know where to start. I am planning to use chemfig but i don't know the syntax. i tried to read the manual yes there it is on the said section of the manual but its to much jargon for me to understand is there a more simpler tutorial for it? – Ricardo Veloz Jr Sep 6 '14 at 18:55

As I said in a comment: chemfig can be used. But there's a downside: there is a learning curve that you can't avoid when trying to master chemfig. This takes practice and time. Thinking about it it's not really a downside: it's the same with every software. :)

Let's try to build the first reaction step by step. The start should be clear:

\begin{center}
\schemestart
\chemfig{Cl-Cl}
\arrow
2\,[Cl]
\schemestop
\end{center}


Now, the next step is to add the electrons using chemfig's commands \lewis and \Lewis. The difference between the two is that with the first the dots don't extend the bounding box of the corresponding atom while they do with the second. Their syntax is the same:

\lewis{<electron spec>,<atom>}


where in <electron spec> you can use the numbers 0 to 7 for determining a counter clockwise angle in multiples of 45°, starting to the right of the atom. Each number can be followed by a : (pair of electrons), a . (single electron), a | (missing electrons) or nothing (pair of electrons represented by a line). Let's try:

\begin{center}
\schemestart
\chemfig{\lewis{2:4:6:,Cl}-\lewis{0:2:6:,Cl}}
\arrow
2\,[\Lewis{0.2:4:6:,Cl}]
\schemestop
\end{center}


Now comes the more difficult part: the arrows representing the electron movements. For this it is necessary to have basic knowledge of TikZ. (One should know the TikZ basics, anyway, when working with chemfig.)

The idea for the electron movement arrows is as follows:

• mark certain nodes in the molecules at the points where the arrows should start or end
• draw a tikzpicture with options remember picture,overlay (they allow to refer to nodes defined earlier which makes it possible to add those arrows to the reaction). To make this more comfortable chemfig provides the \chemmove macro which is nothing more than a wrapper for said tikzpicture.

Marking nodes in chemfig's molecules is done using the @ symbol. Its syntax depends a little bit on whether you want to mark an atom or a bond. For marking an atom it has a mandatory argument which takes the node's name and must be used before the atom in question: \chemfig{@{xxx}A} marks the node containing atom A with the name xxx. For a bond it must be used as first thing in the optional argument of a bond and again has a mandatory argument for the node name: \chemfig{A-[@{xxx}]B}. This places the node xxx in the middle of the bond from A to B. The argument can be extended to vary the position on the bond: \chemfig{A-[@{xxx,.2}]B}: the node is placed after 20% of the bond, i.e., nearer to A.

Let's try this:

\begin{center}
\schemestart
\chemfig{@{Cl1}\lewis{2:4:6:,Cl}-[@{b}]@{Cl2}\lewis{0:2:6:,Cl}}
\arrow
2\,[\Lewis{0.2:4:6:,Cl}]
\schemestop
\end{center}


Now it should be possible to refer to the first chlorine with Cl1, to the second with Cl2, and to the bond with b. If we adapt the example from chemfig's manual we get something like this:

\begin{center}
\schemestart
\chemfig{@{Cl1}\lewis{2:4:6:,Cl}-[@{b}]@{Cl2}\lewis{0:2:6:,Cl}}
\arrow
2\,[\Lewis{0.2:4:6:,Cl}]
\schemestop
\chemmove{
\draw[->]
(b) ..controls +(-90:7mm) and +(-90:7mm) .. (Cl1) ;
\draw[->]
(b) ..controls +(90:7mm) and +(90:7mm) .. (Cl2) ;
}
\end{center}


After two compilations this looks like this:

The ..controls <coord1> and <coord2> .. syntax is described in more detail in the pgf manual. When you use +(<angle>:<radius>) like I did you can think of those two coordinates as two points relative to the starting and ending coordinates of the arrows where the curve will pass “near by”.

What's left? We need half arrow tips (since it's movement of single electrons) and the arrows should not start and end just as close as they do now:

• The first thing is easy with the new TikZ library arrows.meta. After loading it with \usetikzlibrary{arrows.meta} we can for example use -Stealth instead of ->. What's more: Stealth takes an optional argument where you can choose to draw only the left or right half of the tip: -Stealth[left] or -Stealth[right]. Using the optional argument inside the optional argument of \draw requires us to put the whole tip in braces: -{Stealth[left]}.
• for the second point we can use the TikZ syntax shorten >=<dim> to shorten the arrow near the right end and shorten <=<dim> for the left end.

To make us life a bit more comfortable I'd define a TikZ style now:

\tikzset{
elmove/.style={-{Stealth[#1]},shorten >=3pt,shorten <=2pt}
}


This enables us to use elmove=left or elmove=right as TikZ option, the arrows are shortened 3pt at the end and 2pt at the beginning (from the arrow's perspective):

The now complete example

\documentclass{article}
\usepackage{chemfig}
\usetikzlibrary{arrows.meta}
\tikzset{
elmove/.style={-{Stealth[#1]},shorten >=3pt,shorten <=2pt}
}

\begin{document}

\begin{center}
\schemestart
\chemfig{@{Cl1}\lewis{2:4:6:,Cl}-[@{b}]@{Cl2}\lewis{0:2:6:,Cl}}
\arrow
2\,[\Lewis{0.2:4:6:,Cl}]
\schemestop
\chemmove{
\draw[elmove=left]
(b) ..controls +(-90:7mm) and +(-90:7mm) .. (Cl1) ;
\draw[elmove=left]
(b) ..controls +(90:7mm) and +(90:7mm) .. (Cl2) ;
}
\end{center}

\end{document}


gives

I hope this helps to get you started. :)

• thank you so much I'll try my best to finish the rest of it. I wish I could be as good as you when it comes to chemfig but i could only ask questions for now. by the way are you a chemist? or a chemical engineer? – Ricardo Veloz Jr Sep 7 '14 at 2:22
• @cgnieder this has got to be one of the clearest explanations/tutorials on chemfig I have seen, +1! – Leeser Sep 7 '14 at 11:43
• @RicardoVelozJr no, I'm teaching chemistry on a high school level. But I'm a chemfig user from version 0.1 :) – clemens Sep 7 '14 at 12:53
• @RicardoVelozJr, just like cgnieder I teach chemistry ( technical university) and use 'chemfig' in my lectures (and 'beamer') – Leeser Sep 7 '14 at 13:13