LaTeX forum ⇒ Math & ScienceCross-referencing with mhchem package

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Sonntag
Posts: 13
Joined: Sun May 24, 2015 3:37 pm

Cross-referencing with mhchem package

Postby Sonntag » Sun May 24, 2015 3:43 pm

Hi!
  1. \reaction{H2 + OH* <=> H2O + H*}


I want to cross-reference an equation that I've introduced with the reaction-environment from the mhchem package. How can I do it? Hope for your answers. :)

Sonntag

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun May 24, 2015 3:49 pm

Hi and welcome,

undefined control sequence reaction. Please give us more information.
  1. \documentclass{article}
  2. \usepackage[version=3]{mhchem}
  3. \begin{document}
  4. \reaction{H2 + OH* <=> H2O + H*} \label{Water}
  5.  
  6. See reaction~\ref{Water}
  7. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Sonntag
Posts: 13
Joined: Sun May 24, 2015 3:37 pm

Postby Sonntag » Sun May 24, 2015 5:26 pm

Here is a short mini-example:

  1. \documentclass{article}
  2.  
  3. \usepackage { chemexec }
  4. \usepackage[version=4,arrows=pgf-filled]{mhchem}
  5.  
  6. \begin{document}
  7. \reaction{O2 + H* <=> OH* + O*}
  8. \end{document}

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun May 24, 2015 6:57 pm

Hm, interesting. I just poked the author to have a look at this. Clemens is a very active developer, maintining multiple packages like exsheets for exam sheets and chemmacros for a whole bundle of chemistry stuff, more customizable than mhchem.

As it stands now, the package is from 2011, but not declared obsolete. Currently, your code is giving an option clash, that should be fixed within chemexec. I recommend to use the above mentioned and more up-to-date packages.

  1. \documentclass{article}
  2. \usepackage { chemexec }
  3. \usepackage[version=4,arrows=pgf-filled]{mhchem}
  4. \begin{document}
  5. \reaction{H2 + OH* <=> H2O + H* \label{Water}}
  6. See reaction~\ref{Water}
  7. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Sonntag
Posts: 13
Joined: Sun May 24, 2015 3:37 pm

Postby Sonntag » Sun May 24, 2015 7:09 pm

Thanks for your answer! :)

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue May 26, 2015 7:21 pm

This might be an interesting read, thanks Clemens for sending me that link.
myChemistry
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

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

Postby cgnieder » Wed May 27, 2015 11:10 am

chemexec has been my first attempt of writing a package ever. I knew little to nothing about writing a package and it is an obsolete package. Don't use it but use mhchem or chemmacros or chemformula instead. Using chemexec is at your own risk and I won't provide any support to any conflicts due to its usage.

Best regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

Sonntag
Posts: 13
Joined: Sun May 24, 2015 3:37 pm

Postby Sonntag » Sun May 31, 2015 12:25 pm

Thank your help!

In the other packages I couldn't find a command that numbers my reaction equations independantly from the math mode like chemexec does with the \reaction command. (It numbers reaction equations with "R1", "R2" etc.) There's a possibility to do this with the other packages that I haven't seen yet?

Sonntag

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun May 31, 2015 12:55 pm

Sure, an up to date version needed.
  1. \documentclass{article}
  2. \usepackage{chemmacros}
  3. \usepackage{showframe}
  4. \begin{document}
  5. \listofreactions
  6. \begin{reaction}
  7. H2 + O* <=> OH* + H*
  8. \end{reaction}
  9. \renewtagform{reaction}[R ]{\{}{\}}
  10. \begin{reactions}
  11. Ca + O &-> CaO \\
  12. H2 + O* &<=> OH* + H*
  13. \end{reactions}
  14. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 3 guests