Math & Sciencechemfig | Equation Alignment Problem

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
mosschopps
Posts: 1
Joined: Sun Jul 24, 2011 12:25 pm

chemfig | Equation Alignment Problem

Post by mosschopps »

Hi,

I am trying to draw AIBN with the chemfig package:

Code: Select all

\chemfig{N~[7]C-[7](-[7]CH_3)(-[5]CH_3)-[1]N=[7]N-[1](-[1]CH_3)(-[3]CH_3)-[7]C~[7]N}
\hspace{.5cm} $\xrightarrow{60 ^{\circ}\mathrm{C}}$ \hspace{.5cm} 2 \hspace{.5cm}
\chemfig{N~[7]\lewis{0.,C}-[7](-[7]CH_3)(-[5]CH_3)} \hspace{.5cm} + \hspace{.5cm} \chemfig{N~[6]N}
Can anybody tell me how to control the alignment of the equation produced?

Many Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

chemfig | Equation Alignment Problem

Post by localghost »

A (perhaps quick and dirty) solution would be to embed each \chemfig in a tikzpicture environment for better alignment control.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{siunitx}
\usepackage{chemfig}

\begin{document}
  \begin{tikzpicture}[baseline=(current bounding box.center)]
    \chemfig{N~[7]C-[7](-[7]CH_3)(-[5]CH_3)-[1]N=[7]N-[1](-[1]CH_3)(-[3]CH_3)-[7]C~[7]N}
  \end{tikzpicture}
  \chemrel[\small\SI{60}{\celsius}]{->}
  \begin{tikzpicture}[baseline=(current bounding box.center)]
    \chemfig{N~[7]\lewis{0.,C}-[7](-[7]CH_3)(-[5]CH_3)}
  \end{tikzpicture}
  \chemsign{+}
  \begin{tikzpicture}[baseline=(current bounding box.center)]
    \chemfig{N~[6]N}
  \end{tikzpicture}
\end{document}
I guess alignment depends on the starting point for drawing a molecule. In your case you always started in the upper left corner, thus this is the hook for placing the equations symbols.

Note that the package offers according commands for equation symbols like arrows (see code above). Not related to the problem is the addition of the siunitx package for physical units.


Best regards and welcome to the board
Thorsten
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

chemfig | Equation Alignment Problem

Post by cgnieder »

Since version 1.0 of chemfig the package provides macros to create schemes.

Code: Select all

\documentclass{article}
\usepackage{chemfig}
\usepackage{siunitx}

\begin{document}
\schemestart
\chemfig{N~[7]C-[7](-[7]CH_3)(-[5]H_3C)-[1]N=[7]N-[1](-[1]CH_3)(-[3]H_3C)-[7]C~[7]N}
\arrow{->[\SI{60}{\celsius}]}
\chemfig{N~[7]\lewis{0.,C}-[7](-[7]CH_3)(-[5]H_3C)}
\arrow{0}[,0]\+\arrow{0}[,0] % the invisible \arrow{0} is used to center the different compounds here
\chemfig{N~[6]N}
\schemestop
\end{document}
The version 1.0 is not yet in TeXlive, as far as I know, though.
Also notice that I used siunitx as well.
scheme.jpg
scheme.jpg (11.58 KiB) Viewed 3535 times
Regards
site moderator & package author
Post Reply