Ceci est une ancienne révision du document !
I was motivated to write this issue's column by Harold McGee's latest tome Nose Dive: A field guide to the world's smells (New York. Penguin Press: 2020. ISBN 978-0-14-311089-7). This book has 653 pages full of fascinating and enthusiastic information about scents, aromas, smells. Any of you who are cooks or chefs probably are familiar with McGee's other works about cooking. This field guide to the world of smells contains an enormous amount of organic chemistry including many structural diagrams. These diagrams are small line drawings of organic molecules. There is probably more than enough detail in them to satisfy an ordinary reader but not enough for someone with more in-depth knowledge of these molecules. I thought I would find out how Latex handles chemistry formulae.
If you are interested or required to use Latex to make chemical diagrams, please download the chemfig manual available at ctan.org. Simply search for chemfig and you will find it. Since chemfig is part of a standard Latex installation on Linux, you do not need to install it. The manual will be very helpful as you get used to the commands for this powerful set of chemical structure macros.
This column is not an introduction to organic chemistry. I am using a personal interest to show off more of the capabilities of Tex / Latex. If you have a personal interest that needs or uses printed or electronic PDF files, let me know. Perhaps Tex / Latex can make generating the files you need easier.
Let's start with a simple organic compound we are all familiar with: ethanol, more commonly known as ``alcohol'', even though it is only one of the family of alcohols. It is also the only alcohol that is safe for us to consume. Ethanol's formula is normally written as C2H5OH, although it can be written as C2H6O. The straight-line formula does not show how the atoms are joined together (the structure), it also does not show why this combination of atoms is an alcohol.
In order to show the complexities of molecules in a word processor, one has to use chemistry software to draw a compound, then export the drawing as an image (bmp, gif, jpeg, etc). Then import the image into the word processing document. In Latex, one simply uses the chemfig package and then uses the macros - syntax built into that package. (Note: There are other packages which are available for building chemical structures.)
C2H5OH becomes:
\chemfig{C_2H_5OH}
The Latex code using chemfig is much simpler than the Latex code using regular text commands. In the generated PDF, you will see no difference.
Now I will use chemfig to draw the structure that reveals the bonding.
\chemfig{H_3C-[:30]CH_2-[:-30]O-H}
Note: The [:30] and [:-30] indicate the degrees the angle of the next bond will deviate from the previous bond. Without the angling of bonds, the image would be a straight line with -OH stuck on the end. That would not be informative.
Now a conventional organic chemistry structural diagram for ethanol:
\chemfig{-[:30]-[:-30]OH}
For those not familiar with these diagrams, here is an explanation:
Every empty end point or where two lines meet indicates a carbon atom.
Carbon always has four bonds so any “invisible” (or “missing”) bonds are always to hydrogen.
With these two conventions, I hope you can see this diagram is a simplified version of the previous one.
Chemical formulae which have only superscripts, subscripts, and basic symbols (equals, arrows, etc.) can usually be written using the tools in a word processor. Writing anything more complex requires a word processor and some specialized software, or Latex and the appropriate package. I used chemfig but there are others available.
Let's take a look at another simple organic compound we are all familiar with: acetic acid, which is the active component in vinegar. Its formula is CH3COOH which does not tell you much about its structure unless you are familiar with organic acids. The -OH bonded to an end carbon is the distinguishing mark of the family of alcohols. Organic acids also have the -OH group on one end. Next to it, on the same carbon, is an oxygen atom with two bonds to that same carbon. The left-hand carbon is bonded to 3 hydrogen atoms. Its last bond links it to the second carbon. The second carbon has one bond to the first carbon, two bonds to one oxygen, and one bond to another oxygen. The second bond on the second oxygen is linked to a hydrogen. (Clear? If not, look at the acetic acid molecule in figure 1)
\chemfig{H_3C-[:30]C(=[:30]O)(-[:-30]OH)}
This could be simplified as I did with ethanol. I leave that up to you.
A slightly larger acid is butanoic acid with four carbons. It is common in some cheeses. Its smell also reminds some people of sweat.
\chemfig{H_3C-[:30]CH_2-[:-30]CH_2-[:30]C(=[:30]O)(-[:-30]OH)}
Or in the conventional structural form:
\chemfig{-[:30]-[:-30]-[:30](=[:30]O)(-[:-30]OH)}
Even to me this article is starting to sound like a lecture in organic chemistry. So only one more brief example. Phenol is a chemical used in many disinfectants and cleaners. It is also part of the formula for a famous brand of mouthwash. If you had dental work done during COVID, your dentist or hygienist probably asked you to rinse your mouth carefully with something that had phenol in it. Phenol is a six-carbon ring, a benzene ring, with an OH group attached to one carbon. It is not easy to draw quickly or accurately - except in Latex.
\chemfig{HO-[:180]**6(——)}
I hope this article has convinced you of the flexibility and adaptability of Latex. To call it a typesetting system implies it was designed for text. It is very useful for many other kinds of information than just text. I think of Latex as document production software. Granted it does not have the fancy, cluttered GUI that word processors have. However Latex is far more flexible and uses far fewer computer resources than word processors.
The chemfig package relies on the tikz package for drawing. The tikz package is automatically called whenever chemfig is used. There is no need to set up a usepackage for tikz, you can if you wish, but it is not necessary. Both chemfig and tikz are part of a standard Latex install in Linux.
Next time, I will return to processing text and start a project to make a cookbook. Now I have to figure out how to get all these chemical structures into LibreOffice so I can submit this article to the FCM editing team.