TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was tinkering with chemfig package. I created the macros


I thought I would be able to create the code of methane using this. I know the macros are all run at the same time and hence creates the following. enter image description here

share|improve this question
up vote 4 down vote accepted

What you're looking for is the \definesubmol{name}{code} command. You can insert a sub-molecule inside a chemfig command with !{name}.


There are some other things you can do with that command, such as defining different code depending on what direction the bond comes from (so H_3C and CH_3 can be handled by one sumbol).

For more details, see section 4.7 of the chemfig manual.

share|improve this answer

You should use chemfig's \definesubmol instead of \newcommand:




enter image description here

share|improve this answer
Thats what I wanted! Just one more question, what does the ! do in \chemfig{!\lmethyl-!\rmethyl} – nichas Oct 20 '12 at 7:40
The ! is the operator that tells chemfig to insert a submol. You may also define a submol without backslash: \definesubmol{Et}{CH_3-CH_2}. Then you need to use it like \chemfig{!{Et}-H} – clemens Oct 20 '12 at 10:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.