Additions to «chemistry» section

This commit is contained in:
Kenneth John Odle 2024-06-09 11:53:17 -04:00
parent 38e3ba742b
commit 20444a83bd

View File

@ -9,6 +9,7 @@
\raggedbottom
\usepackage{array}
\usepackage{multirow}
\usepackage{gensymb} % Just for the degree symbol
% Where are our images?
\graphicspath{{images/}}
@ -595,9 +596,9 @@ At some point, I realized that most manuals are available in convenient pdf form
\chapter{Chemistry in \LaTeX{}}
I used to be a science teacher, and back in the day, typesetting anything chemistry was not all that easy. Well, it would have been if I had known anything at all about \LaTeX{}, but alas, I did not. I do now, though.
I used to be a science teacher, and back in the day, typesetting anything for chemistry was not all that easy. Well, it would have been if I had known anything at all about \LaTeX{}, but alas, I did not. I do now, though.
As it turns out, people have written a number of different packages over the years to help with this. Let's take a look at some of them.
As it turns out, people have written a number of different packages over the years to help with this. Let's take a look at three of them.
\section{Package \texttt{mhchem}}
@ -645,10 +646,11 @@ which will give us:
\noindent{}\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}
\vspace{\baselineskip}
If you need something fairly straightforward, the \texttt{mhchem} package is for you. It has a simple, intuitive interface and it does a great job.
\section{Package \texttt{chemformula}}
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.
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.
Again, it's pretty intuitive. To write the chemical formula for copper(II) sulfate pentahydrate, we would use code like this:
@ -662,7 +664,7 @@ which produces
\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.
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., and format them accordingly.
You can also use math mode in \texttt{chemformula}. For example, this code:
@ -707,10 +709,14 @@ which gives us:
Like I said, this one operates a lot like \texttt{mhchem}. If \texttt{mhchem} works for you, there's no need to look further. But if you need more control over the appearance of your formulas and equations, \texttt{chemformula} will give you a lot of that control.
Like I said earlier, if your needs are simple, \texttt{mhchem} is a good choice. But if you need more control over your output, then \texttt{chemformula} will do a great job for you. It's slightly less intuitive, but it is well-documented, and the trade-off is a much higher degree of control.
\section{Package \texttt{chemfig}}
If you need to draw chemical structures, then \texttt{chemfig} is the package for you. I t uses a \texttt{chemfig} environment, and loads \texttt{tikz} if it hasn't already been loaded. You can pass a set of parameters to that environment to change the appearance of individual molecules.
If you need to draw chemical structures, then \texttt{chemfig} is the package for you. It uses a \texttt{chemfig} environment, and loads \texttt{tikz} if it hasn't already been loaded.\footnote{See issue \#2, \S{} 7.2 for some basics about drawing with \texttt{tikz}.} You can pass a set of parameters to that environment to change the appearance of individual molecules.
\subsection{Basic Syntax}
The syntax is remarkably simple. You start with the first atom in a molecule and work outwards from there. For example, take a look at this at this drawing of acetic acid:
@ -745,12 +751,17 @@ produces this figure:
\noindent{}\chemfig{H_3C-C(=[1]O)(-[7]OH)}
\vspace{\baselineskip}
Notice that angles are always specified with regard to the horizontal, regardless of where they start.
Notice that angles are always specified with regard to the horizontal, regardless of where they start. In other words, [1] = $1 * 45\degree = 45\degree$ and [7] = $7 * 45\degree = 315\degree$.
\subsection{Ring Structures }
We can also create ring structures pretty easily by using an asterisk at the beginning of our definition. I've created some examples below, where the syntax should be fairly easy to understand. (And notice the use of \texttt{[,0.75]} to change the length of the line of the bond to the functional groups.)
Note that rings always begin with the atom in the southwest corner, which I've labeled here:
\vspace{\baselineskip}
\chemfig{SW*6(-=-=-=)}
\paragraph{Benzene with double and single bonds:}
\begin{Verbatim}[]
@ -837,8 +848,36 @@ Once you understand the basics, it's fairly straightforward to construct even mo
\noindent{}\chemfig{*6((-H_2N)=N-*5(-\chembelow{N}{H}-=N-)=-(=O)-HN-[,,2])}
\vspace{\baselineskip}
Note the use of \texttt{chembelow} to place the third hydrogen atom directly below the nitrogen atom, as we typically don't show the single bonds to hydrogen atoms in cases like this.
You can even use \texttt{chemfigure} to show reactions, using a \texttt{scheme}. Here's the Fischer indole synthesis that I took right from the gallery in the manual:
\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, framesep=3mm, breaklines=true, label=\fbox{Fischer indole synthesis:}]
\setchemfig{atom style={scale=0.75}}
\schemestart
\chemfig{*6(=-*6(-\chembelow{N}{H}-NH_2)=-=-)}
\+
\chemfig{(=[:-150]O)(-[:-30]R_2)-[2]-[:150]R_1}
\arrow(.mid east--.mid west){->[\chemfig{H^+}]}
\chemfig{*6(-=*5(-\chembelow{N}{H}-(-R_2)=(-R_1)-)-=-=)}
\schemestop
\setchemfig{atom style={scale=1}}
\end{Verbatim}
\vspace{\baselineskip}
\noindent{}\setchemfig{atom style={scale=0.75}}
\schemestart
\chemfig{*6(=-*6(-\chembelow{N}{H}-NH_2)=-=-)}
\+
\chemfig{(=[:-150]O)(-[:-30]R_2)-[2]-[:150]R_1}
\arrow(.mid east--.mid west){->[\chemfig{H^+}]}
\chemfig{*6(-=*5(-\chembelow{N}{H}-(-R_2)=(-R_1)-)-=-=)}
\schemestop
\setchemfig{atom style={scale=1}}
\vspace{\baselineskip}
\vspace{\baselineskip}
Notice the use of \texttt{setchemfig} to scale the reaction to 75\% so it would fit on the page, and then its use again to reset the scale back to 100\%. (Although the latter is a moot point, as we are done now.)
\chapter{Coda}