You could place the arrow's label's contents in a \parbox
:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\schemestart
A \arrow{->[\parbox{5cm}{\centering a\\b}][c]} B
\schemestop
\end{document}
or for convenience define a command:
\documentclass{article}
\usepackage{chemfig}
\makeatletter
\newcommand\stack[2][5cm]{\parbox{#1}{\centering#2}}
\makeatother
\begin{document}
\schemestart
A \arrow{->[\stack{a\\b}][c]} B
\schemestop
\end{document}
The arrow's labels are tikz nodes. If we were able to set add align=center
to their properties we would not need the \parbox
. Unfortunately chemfig
doesn't provide an interface to access their properties directly. The nodes are placed by a command \CF@arrow@display@label@i
which we could redefine:
\documentclass{article}
\usepackage{chemfig}
\makeatletter
\def\CF@arrow@display@label@i#1#2#3{%
\ifx\@empty#1\@empty\else
\if*\expandafter\@car\detokenize{#1}\@nil
\ifCF@reac@debug
node[pos=#2,sloped,yshift=#3\CF@arrow@labelsep,draw,fill,cyan](shifted@node){}%
node[
draw,rotate=\CF@rotate@node#1\@nil,anchor=\CF@anchor@node#1\@nil#3,at=(shifted@node),
align=center% <= this is new
]{\expandafter\@gobble\@gobble#1}%
\else
node[pos=#2,sloped,yshift=#3\CF@arrow@labelsep](shifted@node){}%
node[
rotate=\CF@rotate@node#1\@nil,anchor=\CF@anchor@node#1\@nil#3,at=(shifted@node),
align=center% <= this is new
]{\expandafter\@gobble\@gobble#1}%
\fi
\else
\ifCF@reac@debug
node[pos=#2,sloped,yshift=#3\CF@arrow@labelsep,draw,fill,cyan](shifted@node){}%
node[
draw,pos=#2,anchor=-#390,sloped,yshift=#3\CF@arrow@labelsep,
align=center% <= this is new
]{#1}%
\else
node[
pos=#2,anchor=-#390,sloped,yshift=#3\CF@arrow@labelsep,
align=center% <= this is new
]{#1}%
\fi
\fi
\fi
}
\makeatother
\begin{document}
\schemestart
A \arrow{->[a\\b][c]} B
\schemestop
\end{document}
The last manual redefinition can be done easier with @egreg's regexpatch
package:
\documentclass{article}
\usepackage{chemfig}
\usepackage{regexpatch}
\makeatletter
% \xpatchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
% the starred variant replaces all occurrences of <search>
\xpatchcmd*\CF@arrow@display@label@i{node[}{node[align=center,}{}{}
\makeatother
\begin{document}
\schemestart
A \arrow{->[a\\b][c]} B
\schemestop
\end{document}
As I understand the question, the problem is in the "label" of the arrow and how to do the "circle" with arrows. One way to do this is to play with the properties of chemmove
and the arrows.
For example:
\schemestart
\chemfig{First molecule}
\arrow{->[
\chemname[24pt]{\chemfig{N@{st1}ADH}}{\scriptsize \parbox[c]{40pt}{\centering ammonium formate}}
\hspace{0.5cm}
\chemname[24pt]{\chemfig{N@{en1}AD}}{\chemfig{CO_2}}
\chemmove{\draw[->,shorten <=5pt, shorten >=5pt](st1) .. controls +(+50:8mm) and +(+130:8mm)..(en1);}
\chemmove{\draw[->,shorten <=5pt, shorten >=5pt](en1) .. controls +(-130:8mm) and +(-50:8mm)..(st1);}
\chemmove{\draw[->,shorten <=5pt, shorten >=5pt,transform canvas={yshift=-32pt}](st1) .. controls +(+50:8mm) and +(+130:8mm)..(en1);}
]}[,2.4]
\chemfig{second molecule}
\schemestop
Note that maybe further adjusting of the spaces is required.
Best Answer
If you change
\chemfig{-[7]N(-[5])...
in your first formula into\chemfig{N(-[5])(-[3])...
the baseline of said formula will be determined by theN
which in this case suffices for the wanted alignment. The baseline of theOH-
is then the same as baseline of theN
of the first formula.The rest in the code below is just indentation. I also added
|
in one place to get the bonds to theC^+
ending at theC
alone. The smaller bondlength is to make the scheme fit on the page without protruding into the right margin.