Wrote «chemformula» section

This commit is contained in:
Kenneth John Odle 2024-06-05 18:52:59 -04:00
parent 8d754cbf10
commit e9be3083b1

View File

@ -506,7 +506,7 @@ As it turns out, people have written a number of different packages over the yea
\section{Package \texttt{mhchem}}
This package is useful for typesetting chemical equations and reactions and has a fairly intuitive interface. For example, to typeset this equation:
The \texttt{mhchem} package is useful for typesetting chemical equations and reactions and has a fairly intuitive interface, making use of a \texttt{ce} environment. For example, to typeset this equation:
\vspace{\baselineskip}
\noindent{}\ce{CO2 + C -> 2 CO}
@ -553,15 +553,46 @@ which will give us:
\section{Package \texttt{chemformula}}
For typesetting chemical compounds and reactions:
the \texttt{chemformula} package is similar to \texttt{mhchem} in many respects, but is stricter about how certain items are input. In return, it has more options to customize the output.
\ch{KCr(SO4)2 * 12 H2O}
Again, it's pretty intuitive. To write the chemical formula for copper(II) sulfate pentahydrate, we would use code like this:
\ch{[Cu(NH3)4]^2+}
\begin{Verbatim}[]
\ch{CuSO4 * 5 H20}
\end{Verbatim}
\ch{$2n$ Na + $n$ Cl2 -> $2n$ NaCl} \par
which produces
\vspace{\baselineskip}
\noindent{}\ch{CuSO4 * 5 H2O}
\vspace{\baselineskip}
The most notable difference between \texttt{chemformula} and \texttt{mhchem} is that \texttt{chemformula} can distinguish between different types of input, which are separated by a space. That means that in our example above, there are four parts: the copper sulfate part, the asterisk part (which \texttt{chemformula} renders as a dot), the ``5'' part, and the H2O part. \texttt{chemformula} can then detect whether each input is a formula, a stoichiometric factor, an arrow, etc.
You can also use math mode in \texttt{chemformula}. For example, this code:
\begin{Verbatim}[]
\ch{$2n$ Na + $n$ Cl2 -> $2n$ NaCl}
\end{Verbatim}
will give us this reaction:
\vspace{\baselineskip}
\noindent{}\ch{$2n$ Na + $n$ Cl2 -> $2n$ NaCl}
\vspace{\baselineskip}
Again, there are lots of options to customize the output. Here's one with fractions:
\begin{Verbatim}[]
\ch{3/2}
\ch[frac-style=xfrac]{3/2}
\end{Verbatim}
\vspace{\baselineskip}
\noindent{}\ch{3/2} \par
\noindent{}\ch[frac-style=xfrac]{3/2}
\vspace{\baselineskip}
\ch{\{[CH2=CH-CH2]- <-> {}[CH2-CH=CH2]- \}} \par
\section{Package \texttt{chemfig}}