Added section on «chemfig»
This commit is contained in:
parent
26696c7b5c
commit
d7ed5f3311
@ -52,6 +52,9 @@
|
||||
% Make things neater. Thanks /u/-LeopardShark-
|
||||
\usepackage{microtype}
|
||||
|
||||
% Easy tables
|
||||
\usepackage{tabularray}
|
||||
|
||||
% Make a nice border and box for the tops of our examples
|
||||
\newcommand\klab[3]{\vspace{#1}\noindent{}\hrulefill\fbox{\texttt{~#2~}}\hrulefill\vspace{#3}}
|
||||
|
||||
@ -615,17 +618,134 @@ Like I said, this one operates a lot like \texttt{mhchem}. If \texttt{mhchem} wo
|
||||
|
||||
\section{Package \texttt{chemfig}}
|
||||
|
||||
For drawing molecules:
|
||||
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.
|
||||
|
||||
Glucose:
|
||||
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:
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{H_3C-C(=[:30]O)(-[:-30]OH)}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
which is created using this code:
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{H_3C-C(=[:30]O)(-[:-30]OH)}
|
||||
\end{Verbatim}
|
||||
|
||||
It's pretty easy to see what's happening inside the \texttt{chemfig} enivronment.
|
||||
|
||||
\begin{enumerate}[left=0pt, noitemsep]
|
||||
\item First we create the \chemfig{H_3C-} using \verb|H_3C-|.
|
||||
\item We then add the second carbon atom \texttt{C}.
|
||||
\item From this atom, we branch by placing each branch inside parentheses.
|
||||
\item We then angle those branches relative to the \textit{x}-axis by placing the angle inside square brackets after a colon. In this case, we are specifying 30\textdegree{} angles.
|
||||
\end{enumerate}
|
||||
|
||||
We can also predefined angles of angles of 45\textdegree{} by omitting the colon, so that this code:
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{H_3C-C(=[1]O)(-[7]OH)}
|
||||
\end{Verbatim}
|
||||
|
||||
produces this figure:
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\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.
|
||||
|
||||
\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.)
|
||||
|
||||
\paragraph{Benzene with double and single bonds:}
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{*6(-=-=-=)}
|
||||
\end{Verbatim}
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{*6(-=-=-=)}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
\paragraph{Benzene with a ring inside:}
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{**6(------)}
|
||||
\end{Verbatim}
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{**6(------)}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
\paragraph{Phenol with double and single bonds:}
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{*6(-=-=(-[,0.75]OH)-=)}
|
||||
\end{Verbatim}
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{*6(-=-=(-[,0.75]OH)-=)}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
\paragraph{Phenol with a ring inside:}
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{**6(----(-[,0.75]OH)--)}
|
||||
\end{Verbatim}
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{**6(----(-[,0.75]OH)--)}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
\paragraph{Cumene with a ring inside:}
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{**6(----(-[:150,0.75]H_3C)(-[:30,0.75]CH3)--)}
|
||||
\end{Verbatim}
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{**6(----(-[:150,0.75]H_3C)(-[:30,0.75]CH3)--)}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
\subsection{More complicated structures}
|
||||
|
||||
Once you understand the basics, it's fairly straightforward to construct even more complicated structures. Here are some examples.
|
||||
|
||||
\paragraph{Glucose:}
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{?(-[:190]OH)-[:-50](-[:170]OH)-[:10](-[:-55,0.7]OH)
|
||||
-[:-10](-[6,0.7]OH)-[:130]O-[:190]?(-[:150,0.7]-[2,0.7]OH)}
|
||||
\end{Verbatim}
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{?(-[:190]OH)-[:-50](-[:170]OH)-[:10](-[:-55,0.7]OH)
|
||||
-[:-10](-[6,0.7]OH)-[:130]O-[:190]?(-[:150,0.7]-[2,0.7]OH)}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
\paragraph{Xylene:} (Or as IUPAC would say: 1,3-dimethylbenzene.)
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{*6(-=(-OH)-=(-OH)-=)}
|
||||
\chemfig{**6(---(-OH)---)}
|
||||
\chemfig{HO-*6(-=-=-=)}
|
||||
\end{Verbatim}
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{*6(-=(-OH)-=(-OH)-=)}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
\paragraph{Guanine:}
|
||||
|
||||
\begin{Verbatim}[]
|
||||
\chemfig{*6((-H_2N)=N-*5(-\chembelow{N}{H}-=N-)=-(=O)-HN-[,,2])}
|
||||
\end{Verbatim}
|
||||
|
||||
\vspace{\baselineskip}
|
||||
\noindent{}\chemfig{*6((-H_2N)=N-*5(-\chembelow{N}{H}-=N-)=-(=O)-HN-[,,2])}
|
||||
\vspace{\baselineskip}
|
||||
|
||||
|
||||
|
||||
\chapter{A \texttt{git} Workflow}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user