Graphics, Figures & TablesBaseline of a chemical Structure

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
MatthiasN
Posts: 41
Joined: Sun Mar 11, 2012 1:21 pm

Baseline of a chemical Structure

Post by MatthiasN »

Hi everyone,

Recently I had some problems with captions that won't align when I use subfigure. I found out that this is because I am using pictures made with chemfig. The baseline is not where it is expected to be. So my question is: how can I move the baseline of the molecule to the bottom without drawing it in another way.

For example: I've drawn this chemical structure of diazinon

Code: Select all

\documentclass{article}

\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{chemfig}
\begin{document}
\chemfig{[2]N*6(-(-O-P(=[::90]S)(-[::30]OCH_2CH_3)-[::-30]OCH_2CH_3)=-(-CH_3)=N-(-CH(-[::30]CH_3)-[::-60]CH_3)=)}
\end{document}
The output is attached. The tertiary butyl on the benzene ring is underneath the baseline. Is there a way to put the baseline at the bottom of this molecule?

Thanks for reading.
Matthias
Attachments
Diazinon.pdf
(20.63 KiB) Downloaded 616 times

Recommended reading 2024:

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

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

User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Baseline of a chemical Structure

Post by cgnieder »

As you can see in a slightly modified version of your MWE the baseline of the molecule is determined by the first atom that is written by the corresponding \chemfig command:

Code: Select all

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

x\hrulefill \chemfig{[2]N*6(-(-O-P(=[::90]S)(-[::30]OCH_2CH_3)-[::-30]OCH_2CH_3)=-(-CH_3)=N-(-[,,,1]CH(-[::30]CH_3)-[::-60]CH_3)=)} \hrulefill x

\end{document}
The relevant part in the documentation (=> chemfig) is section 2 (»Presenting ChemFig«) where it reads:
ChemFig always places the first atom of the molecule on the baseline of the preceding code.
So the solution is basically: start the molecule with what you called tBu but actually seems to be iPr.

Regards
site moderator & package author
MatthiasN
Posts: 41
Joined: Sun Mar 11, 2012 1:21 pm

Re: Baseline of a chemical Structure

Post by MatthiasN »

My mistake, it's isopropyl indeed. My question was if there's a way to move the baseline without rewriting the molecule. But nevermind, I'll just redo it.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Baseline of a chemical Structure

Post by cgnieder »

MatthiasN wrote:My question was if there's a way to move the baseline without rewriting the molecule.
Oh, yes, I missed that one. I only read
The baseline is not where it is expected to be.
and thought: that's wrong. It's exactly where it's supposed to be.

The answer to your actual question is: yes. Since you can insert labels to nodes inside \chemfig using its @{<nodename>} syntax and since you can pass TikZ options to the tikzpicture within which the molecule is drawn it is quite easy, actually:

Code: Select all

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

x\hrulefill \chemfig[baseline=(mybase.south)]{
  [2]N*6(
    -(
      -O-P(=[::90]S)(-[::30]OCH_2CH_3)-[::-30]OCH_2CH_3
    )
    =-(-CH_3)=N-(
      -[,,,1]CH(-[::30]@{mybase}CH_3)-[::-60]CH_3
    )=
  )
} \hrulefill x

\end{document}
Regards
site moderator & package author
MatthiasN
Posts: 41
Joined: Sun Mar 11, 2012 1:21 pm

Baseline of a chemical Structure

Post by MatthiasN »

I meant that it is not where subfig would expect it to be. That was the reason why my captions didn't align. Thanks for the help.
Post Reply