# Oxidation/reduction arrows, overhead and below, with oxidation numbers also

I want oxidation/reduction arrows, overhead and below, with oxidation numbers also.

Like the one featured in the watermark background on this very page upper left corner.

Unfortunately, chemexec disrupts mhchem and thwarts its smart auto-formatting so you have to manually set superscripts and subscripts - very annoying. So if you can find a less disruptive way of implementing the oxidation state number above the species while you're at it, please do!

\documentclass[a4paper,12pt]{article}

\usepackage[version=3]{mhchem}
\usepackage{chemexec}

\begin{document}

\ce{2 \ox{0}{Na} + \ox{0}{Cl}_2 -> 2 \ox{+1}{Na}^+ + 2 \ox{-1}{Cl}^-}

\end{document}

-
I sense an obligatory TikZ solution. It seems strange that texdoc mhchem doesn't contain a single hit for "oxidation"... –  Seamus May 13 '11 at 13:25
Agreed Seamus - I was a little surprised myself. I hope someone can can come up with a predefined way to do it; I don't want to have to muck about with TikZ if it can be avoided. :| –  ptrcao May 13 '11 at 13:34
Well, the TikZ involved would be pretty trivial, but it would be annoying, I guess... I'm going to experiment... –  Seamus May 13 '11 at 13:47
I thought to use this tikzmark trick but it doesn't work inside mhchem's \ce command. You can have \ce inside tikz nodes so you could let tikz handle the arrows too, but that's suboptimal... –  Seamus May 13 '11 at 14:09

I suggest to take a look to the new package chemmacros that was uploaded yesterday on CTAN and should be in TeX Live in the next update. The examples on pages 9 and 10 seem to be what you need.

Link for chemmacros: http://www.ctan.org/tex-archive/macros/latex/contrib/chemmacros

-
Thanks egreg. How did you get wind of it so quickly? I only knew quicker because I asked the package author personally to include it. Well spotted in any case - my thanks! –  ptrcao May 16 '11 at 4:57
@ptrcao: I just saw the announcement on the TeX Live repository; if I've time I look at the new packages and I happened to remember your question. –  egreg May 16 '11 at 7:49

can also be put into a macro if it is used multiple times with different elements.

\documentclass{article}
\usepackage{pst-node}
\usepackage[version=3]{mhchem}
\usepackage{chemexec}
\begin{document}
\huge
\ce{\rnode{left1}{2\ox{0}{Na}} +
\rnode{left2}{\ox{0}{Cl}_2} ->
\rnode{right1}{2\ox{+1}{Na}^+} +
\rnode{right2}{2\ox{-1}{Cl}^-}}

\psset{arm=7mm,arrowscale=2,nodesep=5pt,shortput=nab}
\ncbar[angle=90,linecolor=red]{->}{left1}{right1}^{\textcolor{red}{Oxidation}}
\ncbar[angle=-90,linecolor=blue]{->}{left2}{right2}_{\textcolor{blue}{Reduction}}

\end{document}


-

OK. Here's a fairly involved way to do this with TikZ that could do with a lot of improvement. I think it could easily be turned into a macro that takes four arguments for the four chunks of the reaction...

\documentclass[border=5em]{standalone}
\usepackage{tikz}
\usepackage[version=3]{mhchem}
\usetikzlibrary{calc,positioning}
\begin{document}
\begin{tikzpicture}
\node (firstleft) {\ce{2Na}};
\node [right =of firstleft] (secondleft) {\ce{Cl2}};
\node [right =of secondleft] (firstright) {\ce{2Na^+}};
\node [right =of firstright] (secondright) {\ce{2Cl^-}};
\node at ($(firstleft)!.5!(secondleft)$) {$+$};
\node at ($(secondleft)!.5!(firstright)$) {\ce{->}};
\node at ($(firstright)!.5!(secondright)$) {$+$};
\node [above =of firstleft] (startox) {};
\node [above =of firstright] (endox) {};
\node [below =of secondleft] (startred) {};
\node [below =of secondright] (endred) {};
\draw [->] (firstleft.north) -- (startox.south) -- node[above] {Oxidation} (endox.south) -- (firstright.north);
\draw [->] (secondleft.south) -- (startred.north) -- node[below] {Reduction} (endred.north) -- (secondright.south);
\end{tikzpicture}
\end{document}


If egreg's chemmacros answer works better, then I won't bother with improving this and turning it into a macro. (I just noticed the top arrow is slightly wonky the node where the top arrow terminates is slightly taller due to the +...

-
Useful tip for making lines horizontal: use the -| and |- syntax. So, for example, your oxidation line could be \draw (firstleft) -- (startox) -| (firstright); –  Loop Space May 17 '11 at 18:23
Huh. That's a neat tip. Thanks! –  Seamus May 17 '11 at 19:22

Guess what I dug out? The gorgeous blueprints for Tex Stack Exchange: Site Design Ideas (updated with mockup)

A bit convoluted but this was how the watermark example in the header of this page was done. It was taken from: http://www.texample.net/tikz/examples/oxidation-and-reduction/

There's got to be an easier way! I'm going to be using this feature a lot on my chemistry website and I don't want to have to micromanage positional coordinates and whatnot... I've got actual work to do; I don't want to get bogged down in the typesetting.

-
I'm still looking for an easier way. Any takers? –  ptrcao May 14 '11 at 4:59
I have some work that needs doing today, but I may get a chance to play around later. I think there's definitely a better tikz solution... –  Seamus May 14 '11 at 11:51
Sure, get back to me when you get the chance, I'd definitely be interested in a less convoluted solution. :) –  ptrcao May 14 '11 at 13:52
I finally got round to doing this, but Herbert and egreg both offered better answers in the mean time... –  Seamus May 18 '11 at 10:23
Thanks, you're most kind. Sorry for the delay in getting back. I'll be keen to try all the suggested solutions to see how they compare. And regardless of which I settle with ultimately, every method is appreciated and worth suggesting. You never know, all methods have comparative strengths and weaknesses, and it's good to bounce ideas of each other. :) –  ptrcao May 19 '11 at 9:12