\ce
macro?Math & Science ⇒ Mass of Substances in Reaction Equation
Mass of Substances in Reaction Equation
What is the best practice to include molar mass of reagents in
NEW: TikZ book now 40% off at Amazon.com for a short time.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Mass of Substances in Reaction Equation
What is the expected result?
Thorsten
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Mass of Substances in Reaction Equation
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:
Regards
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}
site moderator & package author
Mass of Substances in Reaction Equation
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:
RegardsCode: 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}
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Mass of Substances in Reaction Equation
The documentation shows an example with
Best regards
\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}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Mass of Substances in Reaction Equation
While the mhchem solution works v3.11 it doesn't with v3.12:Johannes_B wrote:The documentation shows an example with\underset
. But in comparison, chemformula makes it more easy to handle.
Best regardsCode: 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}
Code: Select all
! Missing $ inserted.
<inserted text>
$
l.12 ... $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}
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
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
\underset
solution is visually not ideal:Regards
site moderator & package author
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Mass of Substances in Reaction Equation
Hi Clemens,cgnieder wrote: While the mhchem solution works v3.11 it doesn't with v3.12:
It works on writeLaTeX with following versions ...Code: Select all
! Missing $ inserted. <inserted text> $ l.12 ... $\underset{\SI{23}{\molmass}}{\ce{4Na}}$}
... while I get the above mentioned error 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
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
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
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Mass of Substances in Reaction Equation
I think I might have an explanation for both points (without having checked the files in question, though): it's only the secondJohannes_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 showsCode: Select all
mhchem.sty 2013/06/17 v3.12 for typesetting chemical formulae
\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}
As for the version number: Martin probably forgot to update the package info in the line
Code: Select all
\ProvidesPackage{mhchem}[<versioning and info>]
Regards
site moderator & package author
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: Mass of Substances in Reaction Equation
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.