I use the chemmacros packages to write chemical reactions in LaTeX, like this:

\ch{CH4 + 2 O2 -> CO2 + 2 H2O}

But now, I want to annotate the stoichiometric numbers below chemical reaction, as the following picture.

I know that tikz can do that, but I don't know how. I appreciate your help.

Chemical equation with annotated stoichiometric number


One could exploit the fact that chemformula allows relative arbitrary code inside \ch between single or double quotes. Although the manual says the escaped code cannot contain spaces, it seems you can get around this by placing the code between braces, which is what I have done below (even though it wasn't actually required in this case).

The annotate macro is a bit basic/crude but it should be fairly easy to see how it could be improved. The main problem is how to position the picture nicely relative to the rest of the text and also ignore most of the picture (i.e., the annotation bit).

Below I show a PGF/TikZ way of doing this by using the baseline and trim left/trim right keys.

\tikz[baseline=0pt,trim left=(@.west), trim right=(@.east)]{%
  \node [draw=orange!50, top color=white, bottom color=orange!25, rounded corners=2pt, inner xsep=1pt,anchor=base](@){#2};
  \node [font=\footnotesize, align=center,inner ysep=2pt, #1=1cm/2 of @] (@') {#3};
\ch{CH4 + "{\annotate{2}{Coeficiente\\estequiom\'etrico}}" O2 -> CO2 + 2 H2O}

enter image description here

| improve this answer | |
  • "\annotate{2}{Coeficiente\\estequiom\'etrico}" does not contain spaces so an extra pair of braces is not necessary. – cgnieder Nov 16 '14 at 13:02
  • @cgnierder perhaps that is why the last sentence of the first paragraph of my answer ends in the way it does? – Mark Wibrow Nov 16 '14 at 13:42
  • Ah, maybe! :) I'm actually a bit surprised that braces work for hiding spaces. I know that once upon a time they didn't. I remember a change I made which explains it, though. I should probably update the manual... – cgnieder Nov 16 '14 at 13:52

You can do that with the psmatrix environment, from pst-node:

\documentclass[pdf, x11names]{article}
\usepackage{pst-node, pst-grad, pst-blur}


\[ \psset{linewidth=0.5pt, arrows = ->, nodesepA=0pt, nodesepB=2pt, arrowinset=.25, framearc=0.15}
\psset{fillstyle=gradient, gradbegin=white, gradend=LightSalmon1!40! white}
\ce{CH4 + \Rnode{coeff}{\psframebox[linecolor=LightSalmon1!80! white, shadow=true, blur=true, shadowsize =.6pt, blurradius=0.3pt, ]{2}} O2 ―――→ CO2 + 2 H2O}%\\
\uput{7ex}[d](coeff){\Rnode{annot}{\textsf{\footnotesize Coeficiente estequiométrico}}}%


enter image description here

| improve this answer | |
  • Can't this be combined with chemmacros (or rather chemformula)? If the document contains other formulas they will look typographically very different otherwise... – cgnieder Nov 16 '14 at 7:33
  • @cgnieder: I suppose it can. I simply could not test since I do not have chemmacros installed. Looking at chemmacros documentation in the TeX Catalogue, the syntax looked very similar. – Bernard Nov 16 '14 at 10:02

Another PSTricks solution:

\documentclass[pdf, x11names]{article}
\usepackage{pst-node, pst-grad, pst-blur}
 \psset{linewidth=0.5pt, arrows = ->, arrowinset=.25, framearc=0.15, 
  fillstyle=gradient, gradbegin=white, gradend=LightSalmon1!40! white}
\def\Annote#1#2{\rnode[b]{coeff}{\psframebox[linecolor=LightSalmon1!80! white, 
  shadow, blur, shadowsize =.6pt, blurradius=0.3pt]{#1}%

 \ch{CH4 + "{\Annote{2}{Coeficiente\\estequiométrico}}" O2 -> CO2 + 2 H2O}


enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.