Math & ScienceDrawing Chemical structures with PPCHTEX package

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Drawing Chemical structures with PPCHTEX package

Post by localghost »

GianlucaT wrote:[…] Now, how can I draw the molecule and save it as a TIFF? I mean can I save only the image in the tiff format and not all the page? […]
Why do you want to abandon the advantages of the vector format in favour of a picture in a pixel format?

Nevertheless you can produce a PDF document that only contains the actual image and convert it subsequently with your favourite image manipulation software.

Code: Select all

\documentclass{minimal}
\usepackage{chemfig}
\usepackage[active,tightpage]{preview}

\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{1pt}
\setatomsep{2em}

\begin{document}
  \chemfig{%
    H_2C=[:-30]
    (-[:-90]CH_3)
    -[:30]
    (=[:90]O)
    -[:-30]\chembelow[1.2em]{O}{\hspace{4em}Cl^-}
    -[:30]
    -[:-30]
    -\chemabove[3pt]{N}{\hspace{-20pt}+}
    (-[2]CH_3)
    (-[6]CH_3)
    -CH_3
  }
\end{document}

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

episanty
Posts: 26
Joined: Tue Mar 24, 2009 2:24 am

Re: Drawing Chemical structures with PPCHTEX package

Post by episanty »

For any newcomers wondering what Gianluca did to solve his problem, here's how:

Once you have downloaded the package, it will probably have a .dtx and a .ins file. Put both in a folder both you and MikTeX will be able to find (I usually put it in MikTeX 2.x/tex/latex/ in a folder Packages/, which has all the packages I install, and then in package_name/). Open the .ins file in TeXnicCenter and run it. This will create a .sty file there. if you already have one, start from here.

If it's a package you're just trying out for a single use, you can simply put the .sty file in the same folder as the file you're running and you can skip the rest.

In the start menu, find MikTeX and run settings. Then click on 'Refresh FNDB' (File-Name DataBase), and wait for the dialogue to close.

Then run your file on TeXnicCenter. It should run without a problem (at least, from that particular package).
Post Reply