This is a short description of how to use the XymTeX package for LaTeX to generate chemical structural formulas. XyMTex is written by Shinsaku Fujita and is unfortunately no longer submitted to CTAN. I think the most recent version can be found here: http://homepage3.nifty.com/xymtex/. The pages also contains useful manuals.
XyMTeX to pdf, jpg or png
If you just want a nice pdf-, jpg- or png-version of the XyMTeX drawing, there is no need to go through the following steps - it is much faster using the eps2pdf, eps2jpg, or eps2png tools, written by Wouter Kager. Briefly:
You probable want to put \pagestyle{empty} in the preamble.
XyMTeX to SVG
You need
An alternative could be to use Skensil and skconvert, but I have not been able to make Skensil run on my computer.
Lets get to work
- Create the compound or reaction using the xymtexps package
- Run the folowing commands:
The resulting svg file is not perfect, a 8x8inch box needs to be removed, the page rescaled, and the bonds transformed from 'lines' to paths.
Get the proper page size
- Open the svg file in Inkscape
- Copy the group with the chemical compounds
- Open a new Inkscape document
- Draw a rectangle, and paste the size of the copied group
- Go to document properties (Shift+Ctrl+D) and do 'Fit page to current selection'
- Delete the rectangle
- Paste the copied XyMTex drawing
- Set the x,y origin to 0
- Save the document
Why deleting the 8x8 inch rectangle and resizing to the XymTex drawing doesn't work is beyond me.
Get the bonds to scale properly
The bonds must be converted from lines to paths:
- Select the bond
- Select 'Stroke to path' from the 'Path' menu or use the shortcut 'Shift+Ctrl+C
Note: As you will no doubt find out, not all lines and shapes needs to be converted. The easiest way is to scale the drawing - all lines which do not scale properly needs to be converted - just undo afterwards.
Bob's ya uncle! You should now have a very nice, fully scalable svg version of the XyMTeX drawing.
A few examples
All these examples are randomly chosen from Shinsaku's manuals, and put into this latex file:
\documentclass[a4paper,10pt]{article}
\usepackage{carom,xymtexps,chmst-ps}
\pagestyle{empty}
\begin{document}
\cyclohexanev{2SA==H;2SB==OH;3Sd==OH;3Su==H}
\newpage\decaheterov{}{9A==OH;{10}B==OH}
\newpage\fivesugarh{5==O;1s==\WedgeAsSubst(0,0)(-3,-5){120};%
4s==\WedgeAsSubst(0,0)(3,-5){120};%
3s==\psline[linewidth=2.8pt,linestyle=solid,%
linecolor=black](-17,0)(307,0)%
}{1Sa==H;2Sb==H;2Sa==OH;3Sb==H;3Sa==OH;4Sa==H;%
4Sb==HOC\rlap{H$_{2}$};%
1Sb==\fiveheterov[bd]{1==N;2==N;4==N}{1==(yl);%
3==CONH$_{2}$}%
}[abc]\newpage\sixheterov[{e\fourfuse{}{4Sa==;4Sb==}{b}}]{}
{4D==O;3SU==Me;3SV==COOMe;5FB==H;6GB==H}\newpage\cyclohexanev{1D==O}
\reactrarrow{40pt}{2cm}{Br$_{2}$}{\strut}
\cyclohexanev{1D==O;2==Br}
\end{document}
I went through the above steps, did inkscape -d 120 -f file.svg -e file.png to convert the svg to a 120 dpi png. For some reason, the files refused to be nothing but black squares when uploaded to this page, so I did convert file.png file.png
Here are the results of the described steps on the latex file above, the svg file is linked to the images:
\cyclohexanev{2SA==H;2SB==OH;3Sd==OH;3Su==H}:
\decaheterov{}{9A==OH;{10}B==OH}:
\fivesugarh{5==O;1s==\WedgeAsSubst(0,0)(-3,-5){120};...:
\sixheterov[{e\fourfuse{}{4Sa==;4Sb==}{b}}]{}...:
Bromination of cyclohexanone:




