Math & Science ⇒ tikZ | Drawing Molecules
-
- Posts: 402
- Joined: Fri May 20, 2011 9:41 am
tikZ | Drawing Molecules
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
tikZ | Drawing Molecules
It is exactly the other way round.ghostanime2001 wrote:I want to draw molecules with tikZ not with chemfig because tikZ has more flexibility of tweaking bond lengths and atomic spacing. […]
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.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?
Code: Select all
\documentclass[11pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{chemfig}
\setatomsep{2em}
\begin{document}
\chemfig{N=[:30]N}
\end{document}
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
tikZ | Drawing Molecules
Of course you can but IMHO you will soon notice that it's also a lot more work.ghostanime2001 wrote:I want to draw molecules with tikZ not with chemfig because tikZ has more flexibility of tweaking bond lengths and atomic spacing.
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 tried to change these parameters with chemfig but there were lots of intricacies that I didn't like (for example really really short bonds).
See section 2 Different kinds of bonds.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 3 Bond angle.ghostanime2001 wrote:Also, how do you orient bonds at different angles?
Regards
-
- Posts: 402
- Joined: Fri May 20, 2011 9:41 am
Re: tikZ | Drawing Molecules
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.
tikZ | Drawing Molecules
Regards
-
- Posts: 402
- Joined: Fri May 20, 2011 9:41 am
Re: tikZ | Drawing Molecules
Re: tikZ | Drawing Molecules
Regards
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
tikZ | Drawing Molecules
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?
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 402
- Joined: Fri May 20, 2011 9:41 am
tikZ | Drawing Molecules
Code: Select all
\documentclass[fleqn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{chemmacros}
\usepackage{chemfig}
\usepackage{mhchem}
\usepackage{tikz}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\setlength{\mathindent}{0pt}
\newcommand{\s}{\par\medskip}
\newcommand{\sm}{\par\smallskip}
\newcommand{\bs}{\par\bigskip}
\pagestyle{empty}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,matrix}
\begin{document}
\begin{tikzpicture}
\node (a) {C};
\node (b) [above=of a] {H};
\node (c) [below=of a] {H};
\node (d) [left=of a] {H};
\node (e) [right=of a] {C};
\node (f) [below right=of e] {O};
\node (g) [right=of f] {H};
\node at (a.north east) {+};
\draw (a.north) to (b.south);
\draw (a.south) to (c.north);
\draw (d.east) to (a.west);
\draw (e.west) to (a.east);
\draw (f.west) to (e.east);
\draw (f.east) to (g.west);
\end{tikzpicture}
\end{document}
- Attachments
-
- chemfig-bond-length.png (18.22 KiB) Viewed 11713 times
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
tikZ | Drawing Molecules
Isn't this exactly what chemfig does?ghostanime2001 wrote:[…] How do I set the bond length to be the same length for example 1cm? […]
Code: Select all
\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 11712 times
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10