LaTeX forum ⇒ Math & ScienceMass of Substances in Reaction Equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
drmCA
Posts: 31
Joined: Mon Aug 13, 2012 12:18 am

Mass of Substances in Reaction Equation

Postby drmCA » Wed Jul 31, 2013 10:06 pm

What is the best practice to include molar mass of reagents in \ce macro?

Tags:

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Wed Jul 31, 2013 10:16 pm

What is the expected result?


Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

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

Postby cgnieder » Thu Aug 01, 2013 12:40 am

It is not common at all to include molar masses into chemical equations. This means there cannot be a best-practice for it. Just for fun here is a possible way with my chemmacros package or rather its sub-package chemformula:

  1. \documentclass{article}
  2. \usepackage{chemformula}
  3. \usepackage{siunitx}
  4. \sisetup{per-mode=symbol}
  5. \begin{document}
  6. \ch{!(\SI{18}{\gram\per\mole})( H2O ) + !(\SI{23}{\gram\per\mole})( 4 Na ) -> ??}
  7. \end{document}


chemformula.png
chemformula.png (4.1 KiB) Viewed 5389 times


Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

drmCA
Posts: 31
Joined: Mon Aug 13, 2012 12:18 am

Postby drmCA » Thu Aug 01, 2013 2:22 am

This is the desired result. Is the same possible with mhchem?

cgnieder wrote:It is not common at all to include molar masses into chemical equations. This means there cannot be a best-practice for it. Just for fun here is a possible way with my chemmacros package or rather its sub-package chemformula:

  1. \documentclass{article}
  2. \usepackage{chemformula}
  3. \usepackage{siunitx}
  4. \sisetup{per-mode=symbol}
  5. \begin{document}
  6. \ch{!(\SI{18}{\gram\per\mole})( H2O ) + !(\SI{23}{\gram\per\mole})( 4 Na ) -> ??}
  7. \end{document}


chemformula.png


Regards

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

Postby Johannes_B » Thu Aug 01, 2013 8:01 am

The documentation shows an example with \underset. But in comparison, chemformula makes it more easy to handle.

  1. \documentclass{article}
  2. \usepackage{chemformula}
  3. \usepackage{mhchem}
  4. \usepackage{siunitx}
  5. \sisetup{per-mode=symbol}
  6. \DeclareSIUnit\molmass{\gram\per\mole}
  7. \begin{document}
  8. \ch{!(\SI{18}{\gram\per\mole})( H2O ) + !(\SI{23}{\gram\per\mole})( 4 Na ) -> ??}
  9.  
  10. \vspace{1em}
  11.  
  12. \ce{$\underset{\SI{18}{\molmass}}{\ce{H2O}}$ + $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}
  13. \end{document}


Best regards
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 » Thu Aug 01, 2013 1:20 pm

Johannes_B wrote:The documentation shows an example with \underset. But in comparison, chemformula makes it more easy to handle.

  1. \documentclass{article}
  2. \usepackage{chemformula}
  3. \usepackage{mhchem}
  4. \usepackage{siunitx}
  5. \sisetup{per-mode=symbol}
  6. \DeclareSIUnit\molmass{\gram\per\mole}
  7. \begin{document}
  8. \ch{!(\SI{18}{\gram\per\mole})( H2O ) + !(\SI{23}{\gram\per\mole})( 4 Na ) -> ??}
  9.  
  10. \vspace{1em}
  11.  
  12. \ce{$\underset{\SI{18}{\molmass}}{\ce{H2O}}$ + $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}
  13. \end{document}


Best regards


While the mhchem solution works v3.11 it doesn't with v3.12:

  1. ! Missing $ inserted.
  2. <inserted text>
  3. $
  4. l.12 ... $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}


It works on writeLaTeX with following versions ...
  • pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012)
  • mhchem.sty 2011/06/03 v3.11
  • chemformula.sty 2012/07/24 v3.3d

... while I get the above mentioned error with following versions:
  • pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
  • mhchem.sty 2013/06/17 v3.12
  • chemformula.sty 2013/07/06 v4.0

Also, I think the \underset solution is visually not ideal:

molmass.png
molmass.png (6.74 KiB) Viewed 5364 times


Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

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

Postby Johannes_B » Thu Aug 01, 2013 3:30 pm

cgnieder wrote:While the mhchem solution works v3.11 it doesn't with v3.12:

  1. ! Missing $ inserted.
  2. <inserted text>
  3. $
  4. l.12 ... $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}


It works on writeLaTeX with following versions ...
  • pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012)
  • mhchem.sty 2011/06/03 v3.11
  • chemformula.sty 2012/07/24 v3.3d

... while I get the above mentioned error with following versions:
  • pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
  • mhchem.sty 2013/06/17 v3.12
  • chemformula.sty 2013/07/06 v4.0


Hi Clemens,

you are right. I forgot to check on my system. I didn't even took a close enough look to notice the bad spacing.
Strange tough, that the underset-example still is in the recent version 3.13 (2013/07/02) of the manual. And more strange, that the file list shows
  1. mhchem.sty 2013/06/17 v3.12 for typesetting chemical formulae


To put it in a nutshell, while mhchem still got the status maintained, using chemmacros is highly recommended.
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 » Thu Aug 01, 2013 3:40 pm

Johannes_B wrote:Strange tough, that the underset-example is still in the recent version 3.13 (2013/07/02) of the manual. And more strange, that the file list shows
  1. mhchem.sty 2013/06/17 v3.12 for typesetting chemical formulae


I think I might have an explanation for both points (without having checked the files in question, though): it's only the second \underset that causes an error, the following compiles fine:
  1. \documentclass{article}
  2. \usepackage{mhchem}
  3. \usepackage{siunitx}
  4. \sisetup{per-mode=symbol}
  5. \DeclareSIUnit\molmass{\gram\per\mole}
  6. \begin{document}
  7. \ce{$\underset{\SI{18}{\molmass}}{\ce{H2O}}$}% + $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}
  8. \end{document}

So Martin probably hasn't noticed the issue.

As for the version number: Martin probably forgot to update the package info in the line
  1. \ProvidesPackage{mhchem}[<versioning and info>]


Maybe someone should tell him...

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

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

Postby Johannes_B » Thu Aug 01, 2013 4:28 pm

I guess you have been in contact with him in the past. Could you do that?
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 4 guests