The answer is: yes. There is actually more than one package to do that:
I have used all but XyMTeX
and PPCHTeX
myself but nowadays only use chemfig
any more.
XyMTeX
is in my opinion far from being intuitive so I never bothered learning it. It also is not regularly updated to CTAN and not part of TeX Live. CTAN has v4.06 but the newest version is v5.00.
ochem
nearly offers all one needs but 1) is not available from either major free distribution and 2) the work is done by a Perl script that translates formulae and reaction schemes into PostScript, which means it doesn't work with pdflatex.
streeTeX
is just too limited in its capabilities besides the fact that it is rather old, is not available from either major free distribution and also doesn't work with pdflatex.
chemfig
is a rather new and actively maintained package that not only allows to draw skeletal formulae but also has commands for creating whole reaction schemes. It uses TikZ for the drawing.
PPCHTeX
is ConTeXt's chemistry module but it can actually be used with LaTeX, too. I have never used it before and trying to typeset the examples below with it has proven to be more complicated than I thought. That's why I simply copied an example from the conTeXtgarden.
So if you want to draw your formulas and schemes with LaTeX rather than an external program like ChemDraw
I can only recommend chemfig
.
A chemfig
example:
\documentclass{article}
\usepackage{chemfig}
\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}
\begin{document}
\setcrambond{2pt}{}{}
\chemfig{
HO-[2,.5,2]?<[7,.7](-[2,.5]OH)-[,,,,line width=2.4pt](-[6,.5]OH)>[1,.7]
(-[:-65,.7]O-[:65,.7]?[b](-[2,.7]CH_2OH)<[:-60,.707](-[6,.5]OH)
-[,,,,line width=2.4pt](-[2,.5,,2]HO)>[:60,.707](-[6,.5]CH_2OH)-[:162,.9]O?[b])
-[3,.7]O-[4]?(-[2,.3]-[3,.5]HO)}
\setatomsep{2em}
\chemfig{
H_3C-[:72]{\color{blue}N}
*5(-
*6(-(={\color{red}O})-{\color{blue}N}(-CH_3)-(={\color{red}O})-{\color{blue}N}(-CH_3)-=)
--{\color{blue}N}=-)}
\end{document}
An ochem
example:
\documentclass{article}
\usepackage{ochem}
\begin{document}
\begin{chemistry}
set("rLenN",20)
formula(L,R)
{
ring(,,H1=)
{
0: bond(r,=C) atom("O") ;
3: atom("N") bond(r) atom("C",C,R) atom("H$_3$",L) ;
4: bond(r,=C) atom("O") ;
5: atom("N") bond(r) atom("CH$_3$",L) ;
vertex(,1,4,H2=,5)
{
1: atom("N") bond(r) atom("C",C,L) atom("H$_3$",R) ;
3: atom("N") ;
} ;
}
}
\end{chemistry}
\end{document}
A streetex
example:
\documentclass{article}
\usepackage{stree}
\begin{document}
\sffamily
\stree{0[2N[0{CH$_3$}]4[=2O]6N[4{CH$_3$}]8[=6O]10]/10N=75N[/7{H$_3$C}]/2}
\end{document}
A XyMTeX
example:
\documentclass{article}
\usepackage{xymtex}
\let\substfont\sffamily
\begin{document}
\sixheterovi[{f\fivefusev[d]{1==N;4==N}{1S==CH$_3$}{b}}e]
{2==N;4==N}
{1D==O;3D==O;4S==CH$_3$}
\end{document}
A PPCHTeX
example
\documentclass{article}
\usepackage{m-pictex}
\usepackage{m-ch-en}% or `m-ch-de' if you like a German interface
\begin{document}
\startchemical
\chemical[FIVE,FRONT,BB125,+SB3,-SB4,Z4][O]
\chemical[FIVE,FRONT,+R1235,+RZ1235][H,H,\SR{HOH_2C},OH]
\chemical[FIVE,FRONT,-R1235,-RZ1235][H,OH,H,H]
\stopchemical
\end{document}
I adapted the solution from the attached link, to draw an \fbox
instead of \underline
. In addition, I had to add \mathord
to make the \fbox
-es across the definitions to have equal widths. (not sure if I did this right though)
\documentclass[border=2mm]{standalone}
\usepackage{amssymb} % for harpoons
\newcommand{\electron}[2]{{%
\newcommand*\up{\fbox{$\mathord\upharpoonleft\phantom{\downharpoonright}$}}%
\newcommand*\dwn{\fbox{$\mathord\downharpoonleft\phantom{\upharpoonright}$}}%
\newcommand*\updwn{\fbox{$\upharpoonleft\downharpoonright$}}%
\newcommand*\emp{\fbox{$\phantom{\downharpoonright}\phantom{\downharpoonright}$}}%
\setlength\tabcolsep{0pt}% remove extra horizontal space from tabular
\begin{tabular}{c}#2\\[2pt]#1\end{tabular}%
}}
\begin{document}
\electron{2s}{\updwn}\quad \electron{2p}{\up\ \dwn\ \emp}
\end{document}
The commands:
\up
: up spin electron only
\dwn
: down spin electron only
\updwn
: up and down spin electrons (filled)
\emp
: no electrons (unfilled)
Edit:
Updated code for the boxes to be attached to each other, with equal line widths. Usage is still the same as above. The lines are thicker now because two fbox
-es are being drawn. If you want to stick to the old fbox
line width, uncomment the \setlength\fboxrule{0.2pt}
line.
\documentclass[border=2mm]{standalone}
\usepackage{amssymb} % for harpoons
\newcommand*\up{\fbox{$\mathord\upharpoonleft\phantom{\downharpoonright}$}}%
\newcommand*\dwn{\fbox{$\mathord\downharpoonleft\phantom{\upharpoonright}$}}%
\newcommand*\updwn{\fbox{$\upharpoonleft\downharpoonright$}}%
\newcommand*\emp{\fbox{$\phantom{\downharpoonright}\phantom{\downharpoonright}$}}%
\newcommand{\electron}[2]{{%
\setlength\tabcolsep{0pt}% remove extra horizontal space from tabular
% \setlength\fboxrule{0.2pt}% uncomment for original line width
\begin{tabular}{c}
\fboxsep=0pt\fbox{\fboxsep=3pt#2}\\[2pt]
#1
\end{tabular}%
}}
\begin{document}
\electron{2s}{\updwn}\quad \electron{2p}{\up\dwn\emp}
\end{document}
Best Answer
Just draw it yourself using TikZ. I extracted the drawing options from the
bohr
package to match the looks.