2

I created two molecules in chemfig and would like to place a + mark vertically aligned in the middle between the two molecules. There is an example of this demonstrated in the manual (see the code), but i'm unable to reproduce it using my own alignment.

How can I achieve the result I wanted (also tikz hacks are welcome, althought I prefer to stay within chemfig)

\documentclass{article}
\usepackage{chemfig}
\begin{document}
%my molecules, the + sign should be alligned in middle just as the manual example
\schemedebug{true}
\schemestart[][west]
\chemname{\chemfig{C(=O)(-[4]H)-[6]C(-H)(-[4]OH)-[6]CHOH}}{\footnotesize{L-glyceraldehyde}}
\arrow{0}[,0]\+
\chemname{\chemfig{COO\textsuperscript{-}-[6]C(=O)-[6]CH}}{\footnotesize{pyruvate}}
\schemestop

\bigskip
%example taken from the chemfig manual (page 67)
% + sign is correctly aligned to the middle.
\schemedebug{true}
\schemestart[][west]
\chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
\arrow{0}[,0]\+
\chemfig{\lewis{246,Br}-\lewis{026,Br}}
\schemestop
\end{document}
7
  • 1
    The code does not compile. – egreg Nov 17 '12 at 21:26
  • For me it does, althought I do get quite some missing } errors. – Timtico Nov 17 '12 at 21:29
  • chemfig atoms already are in math mode so remove the $. – cgnieder Nov 17 '12 at 21:33
  • 1
    @Timtico That's what I said: if the LaTeX run throws up errors, then the file doesn't compile. – egreg Nov 17 '12 at 21:39
  • You're also going to need a class like article instead of minimal to make the code compilable – cgnieder Nov 17 '12 at 21:39
3

You could simply insert a second invisible arrow and maybe use the optional arguments of \+{<dim1>,<dim2>,<dim3>} (where <dim1> is a horizontal space before the plus <dim2> a horizontal space after the plus and <dim3> a vertical shift) to adjust the plus vertically

\documentclass{article}
\usepackage{chemfig}
\begin{document}

\schemestart
\chemname{\chemfig{C(=O)(-[4]H)-[6]C(-H)(-[4]HO)-[6]CH_2OH}}{\footnotesize{L-glyceraldehyde}}
\arrow{0}[,0]\+{,,1.5em}\arrow{0}[2,0]
\chemname{\chemfig{COO^{-}-[6]C(=O)-[6]CH_3}}{\footnotesize{pyruvate}}
\schemestop

\end{document}

enter image description here

2
  • amazing! thanks you for that super fast answer! – Timtico Nov 17 '12 at 21:34
  • and now I understand the trick aswell, debug view shows me the + sign is now properly turned into it's own compound. – Timtico Nov 17 '12 at 21:44
3

A better solution is to start the chemfig code of L-glyceraldehyde with the middle "H" and to start the one of pyruvate with the middle "C". Then, you don't need the \arrow{0} trick and you don't need to adjust the vertical position of \+.

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\schemestart
\chemname{\chemfig{H-[4]C(-[6]CH_2OH)(-[4]HO)-[2]C(-[4]H)=O}}{\footnotesize{L-glyceraldehyde}}
\+
\chemname{\chemfig{C(=O)(-[6]CH_3)-[2]COO^{-}}}{\footnotesize pyruvate}
\schemestop
\end{document}

chemfig

1
  • thanks for the tip. Yes that indeed works fine, it's abit less intuitive (especially when building sugars starting from glyceraldehyde) but I will give it a try. – Timtico Nov 19 '12 at 8:25

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.