## LaTeX forum ⇒ Math & Science ⇒ tikZ | Drawing Molecules

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

### tikZ | Drawing Molecules

I want to draw molecules with tikZ not with chemfig because tikZ has more flexibility of tweaking bond lengths and atomic spacing. I tried to change these parameters with chemfig but there were lots of intricacies that I didn't like (for example really really short bonds). I can create single bonds between atoms, but how do you create double bonds/triple bonds for example between a carbon and oxygen atom or between two nitrogen atoms? Also, how do you orient bonds at different angles?

Tags:

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
ghostanime2001 wrote:I want to draw molecules with tikZ not with chemfig because tikZ has more flexibility of tweaking bond lengths and atomic spacing. […]

It is exactly the other way round.
ghostanime2001 wrote:[…] I tried to change these parameters with chemfig but there were lots of intricacies that I didn't like (for example really really short bonds). I can create single bonds between atoms, but how do you create double bonds/triple bonds for example between a carbon and oxygen atom or between two nitrogen atoms? Also, how do you orient bonds at different angles?

And the chemfig manual didn't help? I'm sure that all your question are answered by just reading a bit in the package manual.
\documentclass[11pt]{standalone}\usepackage[T1]{fontenc}\usepackage{chemfig} \setatomsep{2em} \begin{document}   \chemfig{N=[:30]N}\end{document}

If you expect specific help, a proper, self-contained and minimal example along with an adequate problem description is essential. That is something you should have learned by now.

Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
ghostanime2001 wrote:I want to draw molecules with tikZ not with chemfig because tikZ has more flexibility of tweaking bond lengths and atomic spacing.

Of course you can but IMHO you will soon notice that it's also a lot more work.

ghostanime2001 wrote:I tried to change these parameters with chemfig but there were lots of intricacies that I didn't like (for example really really short bonds).

If I had to guess (and apparently I have to) you probably set chemfig's atom sep to a short value but haven't read section 4 Length of a bond of the manual where the impacts are explained.

ghostanime2001 wrote:I can create single bonds between atoms, but how do you create double bonds/triple bonds for example between a carbon and oxygen atom or between two nitrogen atoms

See section 2 Different kinds of bonds.

ghostanime2001 wrote:Also, how do you orient bonds at different angles?

See section 3 Bond angle.

Regards
site moderator & package author

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am
Thank for all your help. But I already know what you were talking about. In my post I was wondering weather similar effects (bonds, angles, bond length) can be done with tikz. I already know how to do it with chemfig.

Also, I know that between "slimmer" and "thicker" atoms the bond length varies that is why I am trying to change to tikz so that the bond length remains exactly the same length regardless of how thick or thin the width of atoms are.

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
Well, of course you can draw molecules with TikZ. The proof: chemfig uses TikZ. There is no chemistry library for TikZ if that's what you mean. You'd have to draw everything “by hand”, i.e., program it yourself.

Regards
site moderator & package author

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am
That's exactly what I'm after but I how do you draw double bonds and triple bonds with TIKZ ?

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
I'm unsure what you want really... Do you already have code and are struggling with adding a second line (or third, resp.)? If so, please show what you already have so far.

Regards
site moderator & package author

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
ghostanime2001 wrote:That's exactly what I'm after but I how do you draw double bonds and triple bonds with TIKZ ?

• Why are you so stubborn in this matter?
• Why do you insist on this more difficult and more complicated method?
• Are there any really good reasons against the package?

m(
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am
I guess this could work as a MWE example. How do I set the bond length to be the same length for example 1cm?

Attachments
chemfig-bond-length.png (18.22 KiB) Viewed 7816 times

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
ghostanime2001 wrote:[…] How do I set the bond length to be the same length for example 1cm? […]

Isn't this exactly what chemfig does?
\documentclass[11pt]{article}\usepackage[T1]{fontenc}\usepackage{chemfig} \setatomsep{1cm} \begin{document}   \chemfig{\chemabove{C}{\hspace{1pc}\scriptstyle +}(-[2]H)(-[4]H)(-[6]H)-C-[:-60]O-H}\end{document}
Attachments
tmp.png (2.74 KiB) Viewed 7815 times
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1