Math & ScienceMass of Substances in Reaction Equation

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

Mass of Substances in Reaction Equation

Post by drmCA »

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

Re: Mass of Substances in Reaction Equation

Post by localghost »

What is the expected result?


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

Mass of Substances in Reaction Equation

Post by cgnieder »

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:

Code: Select all

\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
chemformula.png (4.1 KiB) Viewed 9287 times
Regards
site moderator & package author
drmCA
Posts: 31
Joined: Mon Aug 13, 2012 12:18 am

Mass of Substances in Reaction Equation

Post by drmCA »

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:

Code: Select all

\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
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Mass of Substances in Reaction Equation

Post by Johannes_B »

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

Code: Select all

\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.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Mass of Substances in Reaction Equation

Post by cgnieder »

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

Code: Select all

\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:

Code: Select all

! 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
molmass.png (6.74 KiB) Viewed 9262 times
Regards
site moderator & package author
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Mass of Substances in Reaction Equation

Post by Johannes_B »

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

Code: Select all

! 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

Code: Select all

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: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Mass of Substances in Reaction Equation

Post by cgnieder »

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

Code: Select all

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:

Code: Select all

\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

Code: Select all

\ProvidesPackage{mhchem}[<versioning and info>]
Maybe someone should tell him...

Regards
site moderator & package author
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Mass of Substances in Reaction Equation

Post by Johannes_B »

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.
Post Reply