When writing any kind of longer Manuscript containing chemical formulas, for example a thesis or a scientific paper, you will typically want to number your compounds in the included schemes and refer to those numbers in the text. For very short documents, it may be appropriate to perform this numbering by hand, first drawing all schemes, then including the numbers in the text as 'just numbers'. The downside of this is, that in case you want to make any kind of changes to the document that changes the order of your numbering scheme, you usually have to rewrite most of or all numbers in the text. For large documents this is not feasible, therefore one should use some kind of auto-numbering tool.
Two common programs to write a manuscript with are LaTeX and of course Microsoft Word. While I wrote some reports for my studies in LaTeX, recently I switched to Word, because I feel I can focus more on the actual content of the manuscript and worry less about the specific formatting. Just preparing the examples for this post reminded me of how time-consuming working with LaTeX can be. On the other hand, LaTeX has many advantages, especially when it comes to documents with long running text, i.e. books, and also for inputting mathematical formulas, but for writing reports in chemistry, Word can have advantages.
LaTeX
In LaTeX there are certain packages that you can include, which take care of numbering your compounds for you, the one I used and can recommend is the chemnum package. After including it in the header, you then can go on inserting placeholders in your LaTeX documents in the style of /cmpd{ID}. The package will replace each new unique ID with subsequent numbers and use the same numbers for identical IDs, just as you would expect.
The real magic happens, when you combine this with the package chemstyle, which enables you to also use the compound numbering to automatically label your compounds in schemes. For this you need to export your schemes as encapsulated PostScript files .eps and include temporary labels under your compounds. By default chemstyle will use TMPX (inwhich X is a consecutive number) as the temporary label. Chemdraw, which many people use to draw chemical formulas can export .eps files. Unfortunately .eps-files exported by Chemdoodle, which is another popular chemical drawing software (and the one currently adopted by my university) curiously do not work.
Here is 'example1.eps' used in the following code:
And the corresponding LaTeX code:
documentclass[a4paper, 11pt]{report}
usepackage{chemnum}
usepackage{chemstyle}
usepackage{graphicx}
usepackage[crop=off, runs=2]{auto-pst-pdf}
egin{document}
egin{scheme}
schemeref[TMP1]{SM1}
schemeref[TMP2]{SM2}
schemeref[TMP3]{P1}
includegraphics[width=10cm]{example1.eps} \
caption{An example.}
end{scheme}
In this reaction the starting materials cmpd{SM1} and cmpd{SM2} will react to form the product cmpd{P1}. To iterate, compound cmpd{P1} is the product of this reaction.
end{document}
The graphicx
package is needed to display any kind of in-text graphics via includegraphics{}
and the auto-pst-pdf
package is necessary to let LaTeX deal with .eps files. In my case I needed to add the [crop=off]
flag to get the document to render, but depending on your environment, this might not be the case.
This combination will generate the following output in the rendered PDF-file:
It has to be noted, that for this to work you need to use the PDFLatex rendering engine with LaTeX.
Obviously, for larger documents you should give your compounds more unique names in cmpd{}
, for example quasi-IUPAC names or unique trivial names, to avoid giving the same name to compounds in different parts of the text.
Word
Unfortunately, in Microsoft Word, there is no elegant way to automatically number the compounds in your schemes automatically, so you will have to do it manually in each included scheme - what a bummer! For this reason, I suggest drawing your schemes in Chemdraw or any other drawing software with unique temporary placeholder names and only exchanging these placeholder as the final step in your writing process. Luckily, on Windows at least for Chemdraw as well as ChemDoodle, drawn schemes are embedded into the Word-document as so called OLE-elements. Double-clicking on these elements in Word will open the appropiate drawing software and you can quickly exchange the temporary labels for the final ones. Collegues of me that use MacOS told me that this often does not work for them, so the process can be more tedious (Just a friendly reminder, that for a long thesis formating your final labels can take quiet some time, so plan ahead if you need to meet a deadline).
There is, however, a way to automatically number your compounds in Word that can deliver similar results as the chemnum
package in LaTeX, which is to use Sequence-fields and Bookmarks, so here is my way of doing it:
While writing your document, whenever a new unique compound comes along in the text, add a new sequence-field. You can do this by navigating to the 'Insert' tab in Word and adding a field under 'Quick Parts'.
In the upcoming dialog under 'Field names' select the 'Seq' option to make the field a sequence-field. Then click on the 'Options...' button on the bottom of the dialog to format the sequence. Here you have the option to select from a list of different enumeration styles. In most cases using arabic-style numerals will be the best choice, but also roman numerals could for example be suitable.
Click on 'Add to field', and you will see a change in the 'Field codes' box. '* Arabic' will be added to the field code. Now insert a keyword before this enummeration style identifier. This keyword can be anything, but needs to be identical for all fields that should be numbered in the following way. In the example I chose 'cmpd' to keep it similar to the LaTeX example.
When you close both dialogs by clicking 'OK', you now see that the field has been inserted into your document with the appropriate number.
This was just the first part. Whenever you write about a compound in your text for the first time, insert a sequence field like this and use the same keyword in the sequence-code as before.
Next we need to define a bookmark for this sequence-field to be able to refer to the compound later in the text. For this, select the text inserted by the sequence-field and add a bookmark under 'Insert', then 'Bookmark'.
In the upcoming dialog you need to give the compound a unique name, in this case I chose 'benzene'. Click 'Add' to add the bookmark.
Now you can continue writing your document. When you want to refer to a compound previously numbered in this way, insert a cross-reference to the bookmark by navigating to 'References' in the Word toolbar and clicking 'Cross-reference'.
A dialog will appear, in which you need to select 'Bookmark' as the reference type. All of your bookmarks will then appear in the list below. Select the appropriate one, in this case 'benzene' and click 'insert'. The reference to your compound will now appear in your document.
When you hover over the bookmark, the chosen name will also appear as a tooltip and you can control-click on the bookmark to lead you to the original sequence-field.
Just finish your document and then replace all the temporary labels in your schemes according to the bookmarks and sequence labels in the text. It is a good idea to give your temporary labels in the schemes the same name as the bookmarks, to eliminate any confusion.
That's pretty much it. Happy numbering!