[Tex/LaTex] Text and figure alignment in chemfig reaction scheme

chemfig

I am new to chemfig, and I am trying to illustrate a reaction using the code:

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\schemestart
\chemname
{\chemfig{-[7]N(-[5])-*6(=-=(-C^{+}(-[6]*6(-=-(-N(-[5])-[7])=-=))-[2]*6(-=-(-N(-[3])-[1])=-=))-=-=)}}
{Crystal Violet Carbonium Ion}
\chemsign{+} 
\chemname
{\chemfig{OH^{-}}}
{Hydroxide}
\arrow{->}
\chemname
{\chemfig{-[7]N(-[5])-*6(=-=(-COH(-[6]*6(-=-(-N(-[5])-[7])=-=))-[2]*6(-=-(-N(-[3])-[1])=-=))-=-=)}}
{Crystal Violet Base}
\schemestop
\end{document}

The output is this:
crystalviolet

I'm not sure how to go about correcting the alignment issues. Any help is greatly appreciated.

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 the N which in this case suffices for the wanted alignment. The baseline of the OH- is then the same as baseline of the N of the first formula.

The rest in the code below is just indentation. I also added | in one place to get the bonds to the C^+ ending at the C alone. The smaller bondlength is to make the scheme fit on the page without protruding into the right margin.

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

\begin{center}
\setatomsep{1.8em}
\schemestart
  \chemname
    {%
      \chemfig{
        N(-[5])(-[3])-
        *6(
          =-=(
            -C|^{+} % <<<< added |
            (-[6]*6(-=-(-N(-[5])-[7])=-=))
            -[2]
            *6(-=-(-N(-[3])-[1])=-=)
          )
          -=-=
        )
      }%
    }{Crystal Violet Carbonium Ion}
  \+{2em} % <<<< more space around the +
  \chemname
    {\chemfig{OH^{-}}}
    {Hydroxide}
  \arrow{->[][][7pt]}
  \chemname
    {%
      \chemfig{
        -[7]N(-[5])-
        *6(
          =-=(
            -COH
            (-[6]*6(-=-(-N(-[5])-[7])=-=))
            -[2]
            *6(-=-(-N(-[3])-[1])=-=)
          )
          -=-=
        )
      }%
    }
    {Crystal Violet Base}
\schemestop
\end{center}

\end{document}

enter image description here

Related Question