\ce
macro?Math & Science ⇒ Mass of Substances in Reaction Equation
Mass of Substances in Reaction Equation
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Mass of Substances in Reaction Equation
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Mass of Substances in Reaction Equation
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}
Mass of Substances in Reaction Equation
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
\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}
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
- 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
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
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm