LaTeX mini-series coming soon!

In the coming days and weeks, I’ll be sharing more of my favorite tips and tricks to make your LaTeX documents even more functional and beautiful. I hope to focus on aspects of document and macro design and usage, as well as formatting and aesthetic tricks that I like to employ in my own papers. 

Remember, I am not a LaTeX expert! Indeed, most of these tricks have been discovered on internet message boards or in documents shared by others over the years—and many have been modified, tweaked, or re-invented for my own specific use and taste. 

Happy typesetting!

Advertisements

ACS formatting using NatBib in LaTeX

I recently came up with a clean and efficient way of managing references/citations using LaTeX, my favorite typesetting system for scientific writing. In my documents I prefer to use endnote-style references with ACS-style citations. To make things a bit easier, I also use a little macro to automatically format my citations. Here’s what I’m doing:

In your document preamble, invoke the natbib package using the super, comma, and sort&compess options.

\usepackage[super, comma, sort&compress]{natbib}

These settings force superscript numeration and comma separation in the text, and the sort&compress option condenses multiple references. For example:

The world is flat.6,7,10-13,16

Additionally, I tweak the following commands:

\renewcommand{\bibnumfmt}[1]{#1.}
\renewcommand{\bibname}{References}

This uses a standard list for numbering in your endnotes, and titles the bibliography section References.

Finally, I use a macro to automatically format my references.

\providecommand*\myref[6]{\bibitem{#1}#2 \textit{#3} \textbf{#4}, \textit{#5}, #6.}

This macro, called \myref, accepts 6 arguments and encapsulates the standard \bibitem command. The arguments are:

#1 – label
#2 – authors
#3 – journal
#4 – year
#5 – volume
#6 – pages

It is used as such:

\myref{anders2009}{Anders, B.}{J. Am. Chem. Soc.}{2009}{8}{1223--1230}

In the body of your LaTeX document, the text should look like this:

The world is flat. \cite{anders2009, george2001, thompson1999}

Then to create your bibliography section,

\newpage
\bibliographystyle{plainnat}
\begin{thebibliography}{200}
\myref{anders2009}{Anders, B.}{J. Am. Chem. Soc.}{2009}{8}{1223--1230}
\myref{george2001}{George, K. L.}{Nature}{2001}{33}{8774--8775}
\myref{thompson1999}{Thompson, A.}{Science}{1999}{9}{900--954}
\end{thebibliography}

This will produce the following output (note that the citations are completely fictitious):

The world is flat.1-3

References

1. Anders, B. J. Am. Chem. Soc. 2009, 8, 1223-1230.
2. George, K. L. Nature 2001, 33, 8774-8775.
3. Thompson, A. Science 1999, 9, 900-954.

Keep on typesetting!