# Aligning atoms with arrows in chemfig

I am writing a reaction scheme and tried to use Clemens recommendation (aligment...) i.e. "starting with the right atom", but I did not succeed to get what I wanted.

\documentclass[border = 0.5cm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{chemfig}

\renewcommand\familydefault{\sfdefault}
\setarrowdefault{0,1.5,black,thick}
\setdoublesep{0.35700 em}  % 'Bond Spacing'
\setatomsep{1.78500 em}    % 'Fixed Length'
\setbondoffset{0.18265 em} % 'Margin Width'
\newcommand{\bondwidth}{0.06642 em} % 'Line Width'
\setbondstyle{line width = \bondwidth}
\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}

\begin{document}
\schemedebug{true}
\schemestart
\chemname{%
\chemfig{
(-[:90]OH)-[:-30](-[:-90]OH)-[:30](-[:-30]H)=[:90]O}%
}{\large{D,L-Glyceraldehyde}}
\arrow{<<->[aldolase]}
\chemname{%
\chemfig{
(-[:-150]H)(-[:-30]H)=[:90]O}%
}{\large{Formaldehyde}}
\+
\chemname{%
\chemfig{
(-[:-90]OH)-[:30](-[:-30]H)=[:90]O}%
}{\large{Glycolaldehyde}}
\schemestop
\end{document}


I would like to have the top carbon atoms aligned vertically with the arrow and the '+' sign also, but with this code this is not the case although I took care to start with them. The following picture shows what I would like to get:

• if possible, could you also show what you desire your output to be (if possible, in a form of a picture)? Aug 13, 2018 at 9:00
• @Raaja, I added a picture.
– DRi
Aug 13, 2018 at 12:23
• does \arrow(.mid east--.mid west){<<->[aldolase]} work?
– Troy
Aug 13, 2018 at 13:07
• @Troy, yes, but only for clyceraldehyde and formaldehyde, The plus sign and glycoladehyde remaining above the line.
– DRi
Aug 13, 2018 at 13:26
• @DRi I just tested, this is my output: imgur.com/a/7MK2jJ2. The plus sign looks aligned with the arrow to me. For Glycolaldehyde, you need to start with the aldehyde carbon. Right now you're starting with the alcohol-side carbon
– Troy
Aug 13, 2018 at 13:31

The main thing to do is to set the anchor points that the arrow connects to (visible with scheme debug on.) with \arrow(.mid east--.mid west){<<->[aldolase]}.

Other notes:

• \setchemfig and the key-value syntax should be used instead starting from chemfig version 1.3 onwards. The individual \set... commands are deprecated.

• For the last molecule, to achieve what you want, you should start drawing the aldehyde carbon first (instead of the alcohol carbon).

• I added a little spacing around the \+ to fix the overlapping of chemnames.

• \large does not take an argument, do remove the braces after it.

MWE:

\documentclass[border = 1cm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{chemfig}

\renewcommand\familydefault{\sfdefault}
\newcommand{\bondwidth}{0.06642 em} % 'Line Width'
\setchemfig{
scheme debug = true,
double bond sep = 0.35700 em,
atom sep = 1.78500 em,
bond offset = 0.18265 em,
bond style = {line width=\bondwidth},
arrow coeff = 1.5,
arrow style = thick,
}
\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}

\begin{document}
\schemestart
\chemname{%
\chemfig{
(-[:90]OH)-[:-30](-[:-90]OH)-[:30](-[:-30]H)=[:90]O}%
}{\large D,L-Glyceraldehyde}
\arrow(.mid east--.mid west){<<->[aldolase]}
\chemname{%
\chemfig{
(-[:-150]H)(-[:-30]H)=[:90]O}%
}{\large Formaldehyde}
\+{1.2em,1.2em}
\chemname{%
\chemfig{%
(-[:210]-[6]OH)(=[2]O)-[:-30]H}%
}{\large Glycolaldehyde}
\schemestop
\end{document}

• Thanks for your answer. I will add your recommendation to the "Chemfig Scheme Golden Rules" ;-) 1) start with the right atom; 2) set the anchor points that the arrow connects to. By the way I am still with version 1.2 but when I will upgrade I will use \setchemfig
– DRi
Aug 14, 2018 at 7:03