# Easy chemical reactions

I'm trying to convert some of my lecture slides to LaTeX. What's the best way to convert a number of slides (similar to the one below) into nice notes? I am aware of mhchem and chemstyle, but I don't think either does what I want.

I also have ChemDraw, but creating each of these seems like an extremely slow process unless I'm just missing some features. Is ChemFig a good alternative?

-
Joseph Wright's chemstyle documentation, section 8, has some thoughts on this. He ends up on ChemDraw, but your situation and needs may differ. –  Mike Renfro Mar 6 '12 at 16:51

ChemFig is a great package but I don't believe that you'll gain much in time if you create your schemes with it rather than with ChemDraw.

Once you know you're way around ChemFig you're just as fast or slow with it than with ChemDraw (supposing you know your way around that, too), at least that's my experience.

There are other points you should consider:

• In order to produce really nice schemes with ChemFig one has to master several steps, though:
• the syntax for the creation of the formulae; this is both very intuitive and easy to learn and difficult to read for larger compounds
• the scheme creating part; that's basically the knowledge of the \arrow command which has a rather complex syntax but thus is a very flexible command
• it helps a lot if one has basic skills in TikZ
• ChemFig is great as long as your formulae stay 2-dimensional and organic. Trying to set something like Ferrocene is possible but tedious, let alone larger 3-dimensional substances like Fe6(CO)12.

If you have many descriptions to your schemes one property of ChemFig could come in handy, though: in its schemes each compound is a TikZ node with a name that you can refer to, which easily allows you to add arrows between a compound in the scheme and some descriptive text, for instance:

\documentclass{scrartcl}
\usepackage{chemfig}
\usepackage{chemstyle} % provides the scheme environment
\usepackage{chemmacros} % for the small formulae

\newcommand*\referto[2][ref]{%
\tikz[
inner sep=0,
baseline=(#1.base),
remember picture]{\node (#1) at (0,0) {#2};}}

\begin{document}
\schemedebug{false}% set this to true' to get information about node names ...
\begin{scheme}
\schemestart
\ch{H2O} \arrow{<<->} \ch{H+} \+ \subscheme{\ch{OH-}}
\schemestop
% the \subscheme creates an extra node
\end{scheme}
Look, I refer to the \referto{hydroxide}!
\chemmove{
\draw[red,thick,->,shorten >= 3pt]
(ref.90) .. controls +(0,1) and +(0,-1) .. (c3.-90);
}

\end{document}


At last I'd like to give an example of how you could use ChemFig and its scheming commands to set the scheme of your example. These commands (\schemestart, \schemestop, \arrow) are more powerful than the \chemrel command with respect of relative positioning of compounds, the length of the arrows etc.

I also use \chemup. and \chemdown\} for the braces. (There is \chemleft and \chemright, too.) These commands serve the same purpose as \left and \right do for maths.

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{chemfig,chemmacros}

\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}} % the style of the atom groups
\setcompoundsep{7em} % (not quite) the length of the arrows
\setatomsep{2em} % (not quite) the bond length

\chemsetup[chemformula]{subscript-vshift=.4ex}
\begin{document}
\schemedebug{false}
\frame{\tiny
\schemestart
\chemup.
\subscheme{
\chemfig{H_3C-[:60]C(-[:120]H_3C)=C(-[:60]H)-[:-60]CH_3}
\arrow(--snd){->[\ch{H2O}][\ch{Hg(OAc)2}]}
\chemfig{CH_3-C(-[6]OH)(-[2]CH_3)-C(-[6]CH_3)(-[2]Hg|OAc)-H}
}
\chemdown\}
% that was the first reaction step, we now can refer to the
% second compound named snd
\arrow(--[blue]){0}[-90,0] % invisible arrow of length 0 to the text below
Oxymercuration
% skip back to the second compound and add next reaction step:
\arrow(@snd--thrd){->[\ch{NaBH4}]}
\chemfig{CH_3-C(-[6]OH)(-[2]CH_3)-C(-[6]CH_3)(-[2]H)-H}
\arrow(--[blue]){0}[-90,.1] MORE substituted alcohol
\arrow(@snd.180--){0}[,0]
\chemup.
% empty compounds to get the right spacing for the second brace:
\subscheme{\arrow(@snd.180--@thrd.0){0}\arrow{0}[-90,1.5]}
\chemdown\}
\arrow(--[blue]){0}[-90,0]
demercuration
\arrow(--[blue]){0}[-60,.2]
\schemestop

\begin{center}
\schemestart
\chemfig{-[:60](-[:120])=-[:-60]}
\arrow{->[1) \ch{H2O}, \ch{Hg(OAc)2}][2) \ch{NaBH4}]}[,2]
\chemfig{HO-(-[:120])(-[:-120])--[:-60]}
\schemestop
\end{center}
}

\end{document}


-

Yes chemifg is a great tool. But as well as almost every code to picture system the syntax is not trival. Please consider the following example. You can easily see, that chemfig syntax follows a logical and human readable syntax, but will become extremely complex for larger structures. And so far as i can see chemfig is the easiest system for chemical structures build (somehow) on TeX. I remember my early days when xymtex made me cry several times.

\documentclass{beamer}
\usepackage{chemfig}
\usepackage{amsmath}
\begin{document}
\frame{\begin{minipage}{\textwidth}
\tiny
\chemname{\chemfig{C((-[:210]H_3C)-[:-210]H_3C)=C(-[:30]H)-[:-30]CH_3}
\chemrel[\chemfig{H_2O}][\chemfig{Hg{(OAc)}_2}]{->}\chemfig{C(-[2]CH_3)(-[4]H_3C)(-[6]OH)-C(-[2]HgOAc)(-[6]CH_3)-H}}{$\underbrace{\hspace{.6\textwidth}}_{\text{oxymercuration}}$}%
\chemrel[\chemfig{NaBH_4}][]{->}\chemname{\chemfig{C(-[2]CH_3)(-[4]H_3C)(-[6]OH)-C(-[2]H)(-[6]CH_3)-H}}{MORE substituted alcohol} \hspace*{.5\textwidth}$\underbrace{\hspace{.4\textwidth}}_{\text{demercuration}}$
\end{minipage}}
\end{document}


Please forgive me that i improvised the brackets. I think there must be a better way to do that.

As it had been said, ChemDraw is the standard all over the chemical world. For me who has to draw a few structures per document chemfig fits perfect. So it won´t fit for me if i had to draw very much of this structures (if i were a real chemist)

-

I haven't had to typeset a lot of chemicals, but perhaps the following may be useful. I have used TikZ to typeset the first formula in the slide to give you a feel for how it works.

\documentclass{standalone}
\usepackage{amsmath,tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[thick]
% First chemical.
\node (CarbonL) {C};
\node[right of=CarbonL] (CarbonR) {C};
\node[above left of=CarbonL] (TopL) {CH$_3$};
\node[below left of=CarbonL] (BotL) {CH$_3$};
\node[above right of=CarbonR] (TopR) {H};
\node[below right of=CarbonR] (BotR) {CH$_3$};
\draw[double] (CarbonL) -- (CarbonR);
\draw (CarbonL) -- (TopL);
\draw (CarbonL) -- (BotL);
\draw (CarbonR) -- (TopR);
\draw (CarbonR) -- (BotR);
\end{tikzpicture}

\end{document}
`

I used relative positioning in this example, but absolute positioning, positioning in matrices and positioning on chains are also possible. This is an easy approach for simple formulae like those in your example, but for anything more elaborate I wouldn't recommend it.

-