trouble making simple chemical formula using chemfig, MikTeX 2.9, dvipng 1.13, Mnemosyne v 2.0 Beta 6, Windows 7, TeXworks

593 views
Skip to first unread message

John Terex

unread,
Oct 4, 2011, 4:29:46 PM10/4/11
to mnemosyne-proj-users
Hello,
I'm trying to write chemical formula using the LaTeX package chemfig.
I have added the //usepackage{chemfig} to my config.py preamble. I
have added the chemfig package using the MikTeX package manager. I
have rebooted my machine. I have removed all existing .png files.
Here's my problem. I am attempting to write a very simple chemical
formula: H-C~N, where the ~ represents a triple bond. I write the
following formula on the front of the card: <latex>\chemfig{H-C~N}</
latex>, and press the preview button.
The resulting preview superimposes the H,C, and N all on top of one
another, with none of the chemical bonds (see image).

Troubleshooting:

the cmd.exe releases the following error multiple times: < raw
PostScriptdvipng warning: PostScript environment contains DVI commands
dvipngwarning: PostScript environment contains DVI comands
dvipngwarning: No image output from inclusion of raw PostScript >

the tmp.dvi file does not render the molecule correctly either. It
also superimposes the atoms, but also includes some super-streched
bonds going off in a diagonal. (see image)


the tmp.tex file outputs normally (see image):
\documentclass[12pt]{article}
\usepackage{chemfig}
\pagestyle{empty}
\begin{document}
\chemfig{H-C~N}
\end{document}

The tmp.tex file compiles and outputs the correct file in .pdf format.
(see image)

image: https://picasaweb.google.com/lh/photo/caK51waIx0sO6jkT3ebAaw?feat=directlink

I am a new user to both LaTeX and Mnemosyne, and I've exhausted my
ability to solve the problem with Google searching. Any idea why
TeXworks will generate the correct .pdf, yet Mnemosyne does not
generate the correct .png?

Thanks!
-John.

Peter Bienstman

unread,
Oct 5, 2011, 9:31:20 AM10/5/11
to mnemosyne-...@googlegroups.com
Hi John,

I would try to debug this outside of Mnemosyne, as this really seems like a
latex issue.

Don't use Texworks (as this is not used by Mnemosyne), but rather from the
command line, try typing the following two command in the correct directory:

latex -interaction=nonstopmode tmp.tex
dvipng -D 200 -T tight tmp.dvi

These are exactly the same commands that Mnemosyne uses as well.

If these commands generate a correct png image, then it's a mnemosyne problem.

If these commands don't work, then it's a problem with your latex/chemfig
install, and you're better off asking on their mailing list for help.

Hope this helps,

Peter

--
Peter Bienstman
Ghent University, Dept. of Information Technology
Sint-Pietersnieuwstraat 41, B-9000 Gent, Belgium
tel: +32 9 264 34 46, fax: +32 9 264 35 93
WWW: http://photonics.intec.UGent.be
email: Peter.B...@UGent.be

John Terex

unread,
Oct 5, 2011, 1:53:19 PM10/5/11
to mnemosyne-proj-users
Thanks Peter,
dvipng from the command line yeilds the same results, so the problem
is in LaTeX. Indeed, the LaTeX-community.org group agrees (link below)
that dvi is not a good format for this file output, and that pdflatex
is a better solution.

In fact, the command pdflatex tmp.tex produces the correct output pdf
file, while latex tmp.tex, produces the goofy dvi, seen in the image
in my original thread.

So I have a new question: is there a workaround within the framework
of Mnemosyne that can run pdflatex to produce a pdf file, and then
convert the pdf file to a .png that will be immediately available, as
in dvipng?

I was thinking of modifying the dvipng command or the latex command
in config.py to run pdflatex, then pipe the output pdf to imagemagick
to convert the pdf file to png, but the details far elude my ability.
Ideas?

By the way, this workaround might make a useful plug-in for folks who
create images using latex that aren't suited to dvipng.

the referenced link:
http://www.latex-community.org/forum/viewtopic.php?f=46&t=12881

Regards,
-John.
> >https://picasaweb.google.com/lh/photo/caK51waIx0sO6jkT3ebAaw?feat=dir...
> > nk
>
> > I am a new user to both LaTeX and Mnemosyne, and I've exhausted my
> > ability to solve the problem with Google searching. Any idea why
> > TeXworks will generate the correct .pdf, yet Mnemosyne does not
> > generate the correct .png?
>
> > Thanks!
> > -John.
>
> --
> Peter Bienstman
> Ghent University, Dept. of Information Technology
> Sint-Pietersnieuwstraat 41, B-9000 Gent, Belgium
> tel: +32 9 264 34 46, fax: +32 9 264 35 93
> WWW:http://photonics.intec.UGent.be
> email: Peter.Bienst...@UGent.be

Peter Bienstman

unread,
Oct 6, 2011, 5:51:28 AM10/6/11
to mnemosyne-...@googlegroups.com
On Wednesday, October 05, 2011 07:53:19 PM John Terex wrote:

> I was thinking of modifying the dvipng command or the latex command
> in config.py to run pdflatex, then pipe the output pdf to imagemagick
> to convert the pdf file to png, but the details far elude my ability.

First, you need to figure out how to invoke the programs from the command line.
Say e.g. the correct commands turn out to be

pdflatex tmp.tex
imagemagick tmp.pdf tmp tmp1.png

Then you edit config.py to read

latex = "pdflatex"
dvipng = "imagemagick tmp.pdf tmp tmp1.png"

Note that mnemosyne will automatically add tmp.tex to the latex command, and
expects the output of dvipng to be the file 'tmp1.png'.

Cheers,

Peter

John Terex

unread,
Oct 7, 2011, 11:28:59 AM10/7/11
to mnemosyne-proj-users
Thanks Peter,
That will solve the problem, methinks. I'm currently debugging a
problem with imagemagick, but when I have the full solution, I'll
repost it here, and I'll start a new thread with instructions on using
chemfig in mnemosyne 2.0.
-John

john.smith...@gmail.com

unread,
Oct 18, 2015, 11:02:06 AM10/18/15
to mnemosyne-proj-users
So you never got it working, I guess?

Peter Bienstman

unread,
Oct 18, 2015, 11:04:07 AM10/18/15
to mnemosyne-...@googlegroups.com
Hi,

You're replying to a really old thread.

Please upgrade to the latest version of Mnemosyne, and if you have concrete problems, feel free to make a new thread.

Cheers,

Peter
Reply all
Reply to author
Forward
0 new messages