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


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.

| improve this answer | |

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




enter image description here

| 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
  • 1
    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} – cgnieder Oct 20 '12 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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