4

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.

1 Answer 1

4

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

1
  • This may be a bit late, but if it were a larger molecule and it was too difficult to rearrange the code so the baseline is set at the correct atom, is there another way?
    – sab hoque
    Mar 29, 2019 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .