## LaTeX forum ⇒ Math & Science ⇒ Mass 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

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

Tags:

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
What is the expected result?

Thorsten
LaTeX Community Moderator

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

cgnieder
Site Moderator
Posts: 1990
Joined: Sat Apr 16, 2011 7:27 pm
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:

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

chemformula.png (4.1 KiB) Viewed 5748 times

Regards
site moderator & package author

drmCA
Posts: 31
Joined: Mon Aug 13, 2012 12:18 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:

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

chemformula.png

Regards

Johannes_B
Site Moderator
Posts: 4141
Joined: Thu Nov 01, 2012 4:08 pm
The documentation shows an example with \underset. But in comparison, chemformula makes it more easy to handle.

\documentclass{article}\usepackage{chemformula}\usepackage{mhchem}\usepackage{siunitx}\sisetup{per-mode=symbol}\DeclareSIUnit\molmass{\gram\per\mole}\begin{document}\ch{!(\SI{18}{\gram\per\mole})( H2O ) + !(\SI{23}{\gram\per\mole})( 4 Na ) -> ??} \vspace{1em} \ce{$\underset{\SI{18}{\molmass}}{\ce{H2O}}$ + $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}\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.

cgnieder
Site Moderator
Posts: 1990
Joined: Sat Apr 16, 2011 7:27 pm
Johannes_B wrote:The documentation shows an example with \underset. But in comparison, chemformula makes it more easy to handle.

\documentclass{article}\usepackage{chemformula}\usepackage{mhchem}\usepackage{siunitx}\sisetup{per-mode=symbol}\DeclareSIUnit\molmass{\gram\per\mole}\begin{document}\ch{!(\SI{18}{\gram\per\mole})( H2O ) + !(\SI{23}{\gram\per\mole})( 4 Na ) -> ??} \vspace{1em} \ce{$\underset{\SI{18}{\molmass}}{\ce{H2O}}$ + $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}\end{document}

Best regards

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

! Missing $inserted.<inserted text>$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 (6.74 KiB) Viewed 5723 times

Regards
site moderator & package author

Johannes_B
Site Moderator
Posts: 4141
Joined: Thu Nov 01, 2012 4:08 pm
cgnieder wrote:While the mhchem solution works v3.11 it doesn't with v3.12:

! Missing $inserted.<inserted text>$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
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.

cgnieder
Site Moderator
Posts: 1990
Joined: Sat Apr 16, 2011 7:27 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
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:
\documentclass{article}\usepackage{mhchem}\usepackage{siunitx}\sisetup{per-mode=symbol}\DeclareSIUnit\molmass{\gram\per\mole}\begin{document}\ce{$\underset{\SI{18}{\molmass}}{\ce{H2O}}$}% + $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}\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
\ProvidesPackage{mhchem}[<versioning and info>]

Maybe someone should tell him...

Regards
site moderator & package author

Johannes_B
Site Moderator
Posts: 4141
Joined: Thu Nov 01, 2012 4:08 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.