Math & Sciencechemfig | Alignment of Atoms

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
ac10
Posts: 13
Joined: Wed Dec 29, 2010 3:01 pm

chemfig | Alignment of Atoms

Post by ac10 »

Hello,

I've found that when putting a charged atom on position [6] the atom is not in line with the bond. It's slightly to the left. (Like the O- below the P).

Is there anything I can do about this? \hspace doesn't work. It puts the atom too far to the right.

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}                
\usepackage{wrapfig}
\usepackage{chemfig}

\begin{document}
\Large{\chemfig{R-O-P(=[2]O)(-[6]O^{-})-O^{-}}}
\end{document}

Thank you
Attachments
phos.png
phos.png (8.43 KiB) Viewed 3266 times
Last edited by ac10 on Sun Nov 27, 2011 6:33 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

chemfig | Alignment of Atoms

Post by Stefan Kottwitz »

Hi,

very good minimal working example!

You can fix it by adding the superscript with \rlap:

Code: Select all

\Large{\chemfig{R-O-P(=[2]O)(-[6]O\rlap{${}^{-}$})-O^{-}}}

Stefan
Attachments
chemfig.png
chemfig.png (2.88 KiB) Viewed 3263 times
LaTeX.org admin
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

chemfig | Alignment of Atoms

Post by cgnieder »

There is an easier fix using chemfig's "|" syntax, see section "Separating Atoms", page 28 of the manual:

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}               
\usepackage{wrapfig}
\usepackage{chemfig}

\begin{document}
\Large{\chemfig{R-O-P(=[2]O)(-[6]O|^{-})-O^{-}}}
\end{document}
site moderator & package author
ac10
Posts: 13
Joined: Wed Dec 29, 2010 3:01 pm

Re: chemfig | Alignment of Atoms

Post by ac10 »

Thank you... That's great!
Post Reply