# Alignment of chemfig molecules in a reaction

I'm using chemfig for my chemistry course this period, and facing problems with the alignment of the molecules, arrows, + signs and also the names. Basically everything is messed up haha.

Can someone explain me how to do it right? I would like to have the molecules' center on one horizontal line, the arrows and + signs aligning that line and the names aligned horizontally just below the biggest molecule.

Thanks in advance, Lisa

    \begin{figure}[width=\textwidth]
\scriptsize
\begin{scheme}
\schemestart
\chemname{\chemfig{OH-[:210,,1]-[:270]=_[:210]-[:150]=_[:90]-[:30](=_[:330])-[:90](-[:30,,,1]OH)=[:150]O}}{salicylic acid}
\+{2em}
\chemname{\chemfig{-[:30](=[:90]O)-[:330]O-[:30](-[:330])=[:90]O}}{acetic anhydride}
\arrow{->}
\chemname{\chemfig{OH-[:210,,1](=[:150]O)-[:270]=_[:330](-[:30]O-[:330](=[:270]O)-[:30])-[:270]=_[:210]-[:150]=_[:90](-[:30])}}{acetylsalicylic acid}
\+{2em}
\chemname{\chemfig{-[:30](-[:330,,,1]OH)=[:90]O}}{acetic acid}
\schemestop
\end{scheme}
\caption{Reaction for synthesizing acetylsalicylic acid} \label{fig:reaction}
\end{figure}


## 1 Answer

The main secret is starting the molecules with the right atom: the first atom of a formula determines the baseline of the corresponding molecule. The rest is only shifting the arrow a bit using its optional argument as described in the manual:

\documentclass{article}
\usepackage{chemfig}

\begin{document}

\begin{center}
\setatomsep{1.8em}
\small
\schemestart
\chemname{%
\chemfig{
OH-[:210,,1]-[:270]=_[:210]-[:150]
=_[:90]-[:30](=_[:330])
-[:90](-[:30,,,1]OH)=[:150]O}%
}{salicylic acid}
\+
\chemname{%
\chemfig{
(-[:-150])(=[:90]O)-[:330]O-[:30](-[:330])=[:90]O}%
}{acetic anhydride}
\arrow{->[][][9pt]}
\chemname{%
\chemfig{
{\vphantom{H}}-[:-150](=[:-90]O)-[:150]
O-[:210,,1]-[:270]=_[:210]-[:150]
=_[:90]-[:30](=_[:330])
-[:90](-[:30,,,1]OH)=[:150]O}%
}{acetylsalicylic acid}
\+
\chemname{%
\chemfig{(-[:-150])(-[:330,,,1]OH)=[:90]O}%
}{acetic acid}
\schemestop
\end{center}

\end{document}


• Thanks clemens, this definitely works out. Can you explain me what the \vphantom part does? How does it work?
– Lisa
Sep 17, 2016 at 18:50
• The \vphantom reserves the vertical space that its argument needs. In this case it ensures that the molecule has the same baseline as the first which starts with an OH group. Sep 17, 2016 at 22:47