Math & Sciencechemfig | Compilation fails

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

chemfig | Compilation fails

Post by niteshs »

Hi!

I just discovered the awesome chemfig package but am having trouble getting it to work.

Here is an MWE:

Code: Select all

\documentclass{article}
\usepackage{chemfig}
\begin{document}
This is a test chem structure.
\chemfig{*6(-=*6(-(-Br)-(-Br))-=-=)}
And this is a test chem scheme.
\schemestart
A\hspace{0.5cm}+\hspace{0.5cm}B\arrow{<=>} AB
\schemestop
\end{document}
And here is the output:
chemfig.png
chemfig.png (15.74 KiB) Viewed 5543 times
These are the errors:
  • Two \documentclass or \documentstyle commands.
    Undefined control sequence \chemfig
    Undefined control sequence \schemestart
    Undefined control sequence A\hspace{0.5cm}+\hspace{0.5cm}B\arrow
    Undefined control sequence \schemestop
And here is the log file:
chemfig.log
(16.97 KiB) Downloaded 329 times
What is going wrong here?

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

chemfig | Compilation fails

Post by cgnieder »

It seems that chemfig was never loaded. The only reason I can think of that would also explain the first error
! LaTeX Error: Two \documentclass or \documentstyle commands.
You have named your file chemfig.tex but the chemfig package loads an internal file called chemfig.tex, too. It seems your file is loaded again instead of chemfig's own.

Try it with test.tex or something.

There's no need for the \hspace in the scheme, by the way:

Code: Select all

\schemestart
 A \+{.5cm,.5cm} B \arrow{<=>} AB
\schemestop
Regards
site moderator & package author
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

chemfig | Compilation fails

Post by localghost »

Never ever give a source file for your document the same name as a package.


Thorsten
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Re: chemfig | Compilation fails

Post by niteshs »

Thank you cgnieder and localghost!
It all makes sense now!
Post Reply