<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <atom:link href="http://kitchingroup.cheme.cmu.edu/blog/feed/index.xml" rel="self" type="application/rss+xml" />
    <title>The Kitchin Research Group</title>
    <link>https://kitchingroup.cheme.cmu.edu/blog</link>
    <description>Chemical Engineering at Carnegie Mellon University</description>
    <pubDate>Sat, 01 Nov 2025 13:47:46 GMT</pubDate>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    
    <item>
      <title>Finding similar bibtex entries</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2017/09/16/Finding-similar-bibtex-entries</link>
      <pubDate>Sat, 16 Sep 2017 10:00:47 EDT</pubDate>
      <category><![CDATA[bibtex]]></category>
      <category><![CDATA[similarity]]></category>
      <guid isPermaLink="false">urp5XIGFmBc6uCiOb266MS_edbI=</guid>
      <description>Finding similar bibtex entries</description>
      <content:encoded><![CDATA[


&lt;p&gt;
A common task while writing scientific papers is citing previous research. I use org-ref extensively for that, and it makes it pretty easy to find similar references, e.g. that have common authors, or common keywords. It also lets me find similar articles in Web of Science or Scopus. Suppose that I have cited a particular paper, e.g. e &lt;a class='org-ref-reference' href="#boes-2016-neural-networ"&gt;boes-2016-neural-networ&lt;/a&gt;, and I want to find similar references to it that are &lt;i&gt;already&lt;/i&gt; in my bibtex file, and similar by &lt;i&gt;my definition&lt;/i&gt;. With org-ref I can easily search by keyword or author to find similar entries, but these are limited by what I search for, and they are not sorted. Today, I will explore the first step in a recommender system that calculates similarity, and provides a sorted list of candidates with the most relevant ones first.
&lt;/p&gt;

&lt;p&gt;
The idea is to calculate some measure of similarity between the title of that reference, and the titles of other references in my bibtex file, and then sort them by similarity. This is the reference I want to find similar entries for:
&lt;/p&gt;

&lt;p&gt;
Boes, J. R., Groenenboom, M. C., Keith, J. A., &amp;amp; Kitchin, J. R., Neural network and Reaxff comparison for Au properties, Int. J. Quantum Chem., 116(13), 979–987 (2016).  &lt;a href="https://doi.org/10.1002/qua.25115"&gt;https://doi.org/10.1002/qua.25115&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
The first thing we do is read in our bibtex file, and print a representative entry.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;
&lt;pre class="src src-ipython"&gt;&lt;span style="color: #0000FF;"&gt;import&lt;/span&gt; bibtexparser
&lt;span style="color: #0000FF;"&gt;from&lt;/span&gt; bibtexparser.bparser &lt;span style="color: #0000FF;"&gt;import&lt;/span&gt; BibTexParser

&lt;span style="color: #0000FF;"&gt;with&lt;/span&gt; &lt;span style="color: #006FE0;"&gt;open&lt;/span&gt;(&lt;span style="color: #008000;"&gt;'/Users/jkitchin/Dropbox/bibliography/references.bib'&lt;/span&gt;) &lt;span style="color: #0000FF;"&gt;as&lt;/span&gt; bibtex_file:
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #BA36A5;"&gt;parser&lt;/span&gt; = BibTexParser()
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #BA36A5;"&gt;bib_database&lt;/span&gt; = bibtexparser.load(bibtex_file, parser=parser)
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #BA36A5;"&gt;entries&lt;/span&gt; = bib_database.entries

&lt;span style="color: #0000FF;"&gt;print&lt;/span&gt;(entries[10])
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
{'author': 'Jaan Aarik and Aleks Aidla and V{\\"a}ino Sammelselg and Teet\nUustare', 'title': 'Effect of Growth Conditions on Formation of \\ce{TiO_2}-{II}\nThin Films in Atomic Layer Deposition Process', 'journal': 'Journal of Crystal Growth', 'volume': '181', 'number': '3', 'pages': '259 - 264', 'year': '1997', 'doi': '10.1016/S0022-0248(97)00279-0', 'link': 'http://www.sciencedirect.com/science/article/pii/S0022024897002790', 'issn': '0022-0248', 'ENTRYTYPE': 'article', 'ID': 'aarik-1997-effec-growt'}
&lt;/p&gt;

&lt;p&gt;
Each entry is a dictionary containing the fields and their values. For this exploration, I will only consider similarities between titles. The next step is we find which entry corresponds to the reference we want to find similarities to.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;
&lt;pre class="src src-ipython"&gt;&lt;span style="color: #BA36A5;"&gt;ids&lt;/span&gt; = [e[&lt;span style="color: #008000;"&gt;'ID'&lt;/span&gt;] &lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; e &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; entries]
&lt;span style="color: #BA36A5;"&gt;i&lt;/span&gt; = ids.index(&lt;span style="color: #008000;"&gt;'boes-2016-neural-networ'&lt;/span&gt;)
&lt;span style="color: #0000FF;"&gt;print&lt;/span&gt;(entries[i])
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
{'author': 'Jacob R. Boes and Mitchell C. Groenenboom and John A. Keith\nand John R. Kitchin', 'title': 'Neural Network and {Reaxff} Comparison for {Au} Properties', 'journal': 'Int. J. Quantum Chem.', 'volume': '116', 'number': '13', 'pages': '979-987', 'year': '2016', 'doi': '10.1002/qua.25115', 'link': 'https://doi.org/10.1002/qua.25115', 'issn': '1097-461X', 'keyword': 'Kohn-Sham density functional theory, neural networks, reactive\nforce fields, potential energy surfaces, machine learning', 'ENTRYTYPE': 'article', 'ID': 'boes-2016-neural-networ'}
&lt;/p&gt;

&lt;p&gt;
It is best if we make the entry we want to find similarities to the first one, so here we swap the first and i&lt;sup&gt;th&lt;/sup&gt; entries.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;
&lt;pre class="src src-ipython"&gt;entries[0], &lt;span style="color: #BA36A5;"&gt;entries&lt;/span&gt;[i] = entries[i], entries[0]
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Now, we prepare the list of strings to get similarities for.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;
&lt;pre class="src src-ipython"&gt;&lt;span style="color: #BA36A5;"&gt;titles&lt;/span&gt; = [e.get(&lt;span style="color: #008000;"&gt;'title'&lt;/span&gt;, &lt;span style="color: #008000;"&gt;''&lt;/span&gt;) &lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; e &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; entries]
&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;
We will use &lt;a href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf"&gt;term frequency–inverse document frequency&lt;/a&gt; to get a vector that represents each title, and then use &lt;a href="https://en.wikipedia.org/wiki/Cosine_similarity"&gt;cosine similarity&lt;/a&gt; as a measure of similarity. Here is the place to note that &lt;i&gt;I chose&lt;/i&gt; these, and could choose other ones too. Also, it is worth noting that in this measure of similarity I did &lt;i&gt;not&lt;/i&gt; choose which keywords to measure similarity on.
&lt;/p&gt;

&lt;p&gt;
The functionality for this is provided by &lt;a href="http://scikit-learn.org/stable/"&gt;sklearn&lt;/a&gt;. It has implemented functions for the algorithms above, and in just a few lines of code you get an array of tf-idf features to analyze. The array we get from our vectorizer contains normalized vectors, so we can get the cosine similarity just from a dot product of the vectors. The first row corresponds to the similarity of the first string to all the others. I want them sorted in descending order. The argsort function returns ascending order, so we use a trick to sort the negative of the similarity score which achieves that. There are certainly more advanced treatments of the text we could use by &lt;a href="http://scikit-learn.org/stable/modules/feature_extraction.html#customizing-the-vectorizer-classes"&gt;customizing the vectorizer&lt;/a&gt;, e.g. word stemming, but for now we neglect that.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;
&lt;pre class="src src-ipython"&gt;&lt;span style="color: #0000FF;"&gt;from&lt;/span&gt; sklearn.feature_extraction.text &lt;span style="color: #0000FF;"&gt;import&lt;/span&gt; TfidfVectorizer

&lt;span style="color: #BA36A5;"&gt;vectorizer&lt;/span&gt; = TfidfVectorizer(stop_words=&lt;span style="color: #008000;"&gt;'english'&lt;/span&gt;)
&lt;span style="color: #BA36A5;"&gt;X&lt;/span&gt; = vectorizer.fit_transform(titles)

&lt;span style="color: #BA36A5;"&gt;cosine_similarities&lt;/span&gt; = (X * X.T).A[0]

&lt;span style="color: #BA36A5;"&gt;related_docs_indices&lt;/span&gt; = (-cosine_similarities).argsort()

&lt;span style="color: #0000FF;"&gt;print&lt;/span&gt;(&lt;span style="color: #008000;"&gt;'The top 10 recommendations for {} are:\n'&lt;/span&gt;.&lt;span style="color: #006FE0;"&gt;format&lt;/span&gt;(S[0]))
&lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; i, j &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; &lt;span style="color: #006FE0;"&gt;enumerate&lt;/span&gt;(related_docs_indices[1:11]):
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;print&lt;/span&gt;(&lt;span style="color: #008000;"&gt;'{i}. {ID}: {title}, {author}\n'&lt;/span&gt;.&lt;span style="color: #006FE0;"&gt;format&lt;/span&gt;(i=i + 1, **entries[j]))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
The top 10 recommendations for Neural Network and {Reaxff} Comparison for {Au} Properties are:
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;behler-2010-neural: Neural network potential-energy surfaces for atomistic&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
simulations, J{\"o}rg Behler
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;boes-2017-neural-networ: Neural Network Predictions of Oxygen Interactions on a Dynamic&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
{Pd} Surface, Jacob R. Boes and John R. Kitchin
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;eshet-2010-ab: Ab Initio Quality Neural-Network Potential for Sodium, Hagai Eshet and Rustam Z. Khaliullin and Thomas D. K{\"u}hne&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
and J{\"o}rg Behler and Michele Parrinello
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;behler-2014-repres-poten: Representing Potential Energy Surfaces By High-Dimensional&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Neural Network Potentials, J Behler
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;behler-2007-gener-neural: Generalized Neural-Network Representation of High-Dimensional&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Potential-Energy Surfaces, J{\"o}rg Behler and Michele Parrinello
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;artrith-2012-high: High-Dimensional Neural Network Potentials for Metal Surfaces:&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
A Prototype Study for Copper, Nongnuch Artrith and J{\"o}rg Behler
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;behler-2015-const: Constructing High-Dimensional Neural Network Potentials: A&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Tutorial Review, J{\"o}rg Behler
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;artrith-2011-high: High-Dimensional Neural-Network Potentials for Multicomponent&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Systems: Applications To Zinc Oxide, Nongnuch Artrith and Tobias Morawietz and J{\"o}rg Behler
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;sosso-2012-neural-gete: Neural Network Interatomic Potential for the Phase Change&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Material \ce{GeTe}, Gabriele C. Sosso and Giacomo Miceli and Sebastiano Caravati
and J{\"o}rg Behler and Marco Bernasconi
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;lorenz-2006-descr: Descriptions of Surface Chemical Reactions Using a Neural&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Network Representation of the Potential-Energy Surface, S{\"o}nke Lorenz and Matthias Scheffler and Axel Gross
&lt;/p&gt;

&lt;p&gt;
It is evident that this is showing other references containing the words "neural network"! I guess that is a little disappointing, since these would just as easily been narrowed down in org-ref. On the other hand, they are sorted and grouped, which would not happen in org-ref. This is a comparison of pretty short strings (just the titles), so maybe this would be much more interesting if abstracts were also included. Including authors would give a different set as well (I tried it, and got a bunch of my own references!).
&lt;/p&gt;

&lt;p&gt;
I don't think it would be very difficult to get this into an Emacs selection tool, e.g. helm/ivy. Check this out:
&lt;/p&gt;

&lt;div class="org-src-container"&gt;
&lt;pre class="src src-ipython"&gt;&lt;span style="color: #0000FF;"&gt;import&lt;/span&gt; pycse.lisp

related_docs_indices[1:6].lisp
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;

&lt;/p&gt;

&lt;p&gt;
'(1592 1650 299 1751 103)'
&lt;/p&gt;


&lt;p&gt;
That is a result that can be read directly by lisp, so we could simply write the code above as a shell script that takes an argument, and returns a list of indices to sort the candidates on. The alternative is to implement this in elisp, perhaps via a dynamic module if there is already a good C library for this. My sense is the Python libraries are more advanced in functionality.
&lt;/p&gt;

&lt;p&gt;
This could have a number of other applications. Given some reference content, you could imagine finding emails that are similar to it, finding RSS entries that are similar to it, finding org headlines that are related, similar files, or similarity with any other set of strings that can be gathered, e.g. from Crossref or some other search, etc. I predict there will be more on these topics in the future!
&lt;/p&gt;
&lt;p&gt;Copyright (C) 2017 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;
&lt;p&gt;&lt;a href="/org/2017/09/16/Finding-similar-bibtex-entries.org"&gt;org-mode source&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Org-mode version = 9.0.7&lt;/p&gt;
]]></content:encoded>
    </item>
    <item>
      <title>Automated bibtex entry tweeting</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2016/08/25/Automated-bibtex-entry-tweeting</link>
      <pubDate>Thu, 25 Aug 2016 12:14:31 EDT</pubDate>
      <category><![CDATA[bibtex]]></category>
      <category><![CDATA[twitter]]></category>
      <guid isPermaLink="false">R6USBJFutUqhJvSjdPHsX83Gtjo=</guid>
      <description>Automated bibtex entry tweeting</description>
      <content:encoded><![CDATA[


&lt;p&gt;
The goal in this post is to develop an elisp function that will tweet a bibtex entry. What I want is to be on a bibtex entry, and run a command that will generate a tweet and tweet it. Here is an example bibtex entry I will use in this post. Clearly, I couldn't simply tweet the entry, it is too long. What I want instead is to generate a picture of a formatted citation, to make a gist out of the bibtex entry so we can link to it, and then to provide links in the tweet to the doi, and the bibtex entry gist.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt; (find-file-noselect &lt;span style="color: #008000;"&gt;"~/Dropbox/bibliography/references.bib"&lt;/span&gt;)
  (goto-char (point-min))
  (re-search-forward &lt;span style="color: #008000;"&gt;"kitchin-2016-autom-data,"&lt;/span&gt;)
  (bibtex-copy-entry-as-kill)
  (&lt;span style="color: #0000FF;"&gt;with-temp-buffer&lt;/span&gt;
    (bibtex-yank 1)
    (buffer-string)))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
First, we tackle making an image. Emacs has some capability to generate svg, and we can readily convert that to png for the tweet. Here we just go to the entry, and then generate a png. I build off the citation capability of org-ref to generate a pretty reasonably formatted entry. It isn't perfect; the volume is missing in the entry, so there is a blank space between two commas, but this is good enough for me. Note we need a png for twitter. It appears you cannot upload svg yet.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;let*&lt;/span&gt; ((entry (&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt; (find-file-noselect &lt;span style="color: #008000;"&gt;"~/Dropbox/bibliography/references.bib"&lt;/span&gt;)
                (goto-char (point-min))
                (re-search-forward &lt;span style="color: #008000;"&gt;"kitchin-2016-autom-data,"&lt;/span&gt;)
                (bibtex-beginning-of-entry)
                (bibtex-parse-entry t)))
       (formatted-entry (orhc-formatted-citation entry))
       (lines (&lt;span style="color: #0000FF;"&gt;with-temp-buffer&lt;/span&gt;
                (insert formatted-entry)
                (fill-paragraph)
                (split-string  (buffer-string) &lt;span style="color: #008000;"&gt;"\n"&lt;/span&gt;)))
       (svg (svg-create 500 (* 20 (length lines)))))

  (&lt;span style="color: #0000FF;"&gt;loop&lt;/span&gt; for i from 0
        for line in lines
        do
        (svg-text svg line
                  &lt;span style="color: #006FE0;"&gt;:font-size&lt;/span&gt; &lt;span style="color: #008000;"&gt;"12"&lt;/span&gt;
                  &lt;span style="color: #006FE0;"&gt;:stroke&lt;/span&gt; &lt;span style="color: #008000;"&gt;"black"&lt;/span&gt;
                  &lt;span style="color: #006FE0;"&gt;:x&lt;/span&gt; 0
                  &lt;span style="color: #006FE0;"&gt;:y&lt;/span&gt; (+ 15 (* i 15))
                  &lt;span style="color: #006FE0;"&gt;:stroke-width&lt;/span&gt; 0.3))

  (&lt;span style="color: #0000FF;"&gt;with-temp-file&lt;/span&gt; &lt;span style="color: #008000;"&gt;"authoring.svg"&lt;/span&gt;
    (svg-print svg)))

(shell-command &lt;span style="color: #008000;"&gt;"convert authoring.svg authoring.png"&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
&lt;img src="/media/authoring.png"&gt;
&lt;/p&gt;

&lt;p&gt;
It is easy enough to get the doi, and generate the url to it.
&lt;/p&gt;
&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;let*&lt;/span&gt; ((entry (&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt; (find-file-noselect &lt;span style="color: #008000;"&gt;"~/Dropbox/bibliography/references.bib"&lt;/span&gt;)
                (goto-char (point-min))
                (re-search-forward &lt;span style="color: #008000;"&gt;"kitchin-2016-autom-data,"&lt;/span&gt;)
                (bibtex-beginning-of-entry)
                (bibtex-parse-entry t))))
  (format &lt;span style="color: #008000;"&gt;"https://doi.org/%s"&lt;/span&gt; (cdr (assoc &lt;span style="color: #008000;"&gt;"doi"&lt;/span&gt; entry ))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Next, we will put the entry as a gist on Github, so we can provide a link to it. I use the gist.el package, and here just do some trickery to put the entry in a temp-file named by the key so that the gist has a nice name. This returns the url to the gist, which we would want to incorporate into a tweet.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt; (find-file-noselect &lt;span style="color: #008000;"&gt;"~/Dropbox/bibliography/references.bib"&lt;/span&gt;)
  (goto-char (point-min))
  (re-search-forward &lt;span style="color: #008000;"&gt;"kitchin-2016-autom-data,"&lt;/span&gt;)
  (&lt;span style="color: #0000FF;"&gt;save-restriction&lt;/span&gt;
    (bibtex-narrow-to-entry)
    (bibtex-beginning-of-entry)
    (&lt;span style="color: #0000FF;"&gt;let*&lt;/span&gt; ((entry-string (buffer-string))
           (entry (bibtex-parse-entry))
           (key (cdr (assoc &lt;span style="color: #008000;"&gt;"=key="&lt;/span&gt; entry)))
           (tfile (expand-file-name (format &lt;span style="color: #008000;"&gt;"%s.bib"&lt;/span&gt; key) temporary-file-directory)))
      (&lt;span style="color: #0000FF;"&gt;with-temp-file&lt;/span&gt; tfile
        (insert entry-string))
      (&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt; (find-file-noselect tfile)
        (gist-buffer)))
    (&lt;span style="color: #0000FF;"&gt;with-temp-buffer&lt;/span&gt;
      (yank)
      (buffer-string))))
&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;
Ok, All the pieces are in place. The only piece left is creating the tweet, and tweeting it. I couldn't see an obvious way to do this with twittering mode, since I didn't see where to add an image. There is a &lt;a href="https://pypi.python.org/pypi/TwitterAPI/2.4.2"&gt;Python library&lt;/a&gt; for this though, and it looks pretty easy to use. Here is an example usage.
&lt;/p&gt;


&lt;div class="org-src-container"&gt;

&lt;pre class="src src-python"&gt;&lt;span style="color: #0000FF;"&gt;from&lt;/span&gt; TwitterAPI &lt;span style="color: #0000FF;"&gt;import&lt;/span&gt; TwitterAPI
&lt;span style="color: #0000FF;"&gt;from&lt;/span&gt; twitter_secrets &lt;span style="color: #0000FF;"&gt;import&lt;/span&gt; CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET

&lt;span style="color: #BA36A5;"&gt;api&lt;/span&gt; = TwitterAPI(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)
&lt;span style="color: #006FE0;"&gt;file&lt;/span&gt; = &lt;span style="color: #006FE0;"&gt;open&lt;/span&gt;(&lt;span style="color: #008000;"&gt;'authoring.png'&lt;/span&gt;, &lt;span style="color: #008000;"&gt;'rb'&lt;/span&gt;)
&lt;span style="color: #BA36A5;"&gt;data&lt;/span&gt; = &lt;span style="color: #006FE0;"&gt;file&lt;/span&gt;.read()
&lt;span style="color: #BA36A5;"&gt;r&lt;/span&gt; = api.request(&lt;span style="color: #008000;"&gt;'statuses/update_with_media'&lt;/span&gt;, {&lt;span style="color: #008000;"&gt;'status'&lt;/span&gt;:&lt;span style="color: #008000;"&gt;'A test tweet using the TwitterAPI with an image.'&lt;/span&gt;}, {&lt;span style="color: #008000;"&gt;'media[]'&lt;/span&gt;:data})
&lt;span style="color: #0000FF;"&gt;print&lt;/span&gt;(r.status_code)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
200
&lt;/p&gt;

&lt;p&gt;
It will be a tad hacky, but the script is so simple we can just make a template, and run it. We need to do these things: 1) make the image, 2) make the gist 3) format and send the tweet. Here is the elisp function to do that.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;defun&lt;/span&gt; &lt;span style="color: #006699;"&gt;tweet-bibtex&lt;/span&gt; ()
  &lt;span style="color: #036A07;"&gt;"Tweet the bibtex entry at point."&lt;/span&gt;
  (&lt;span style="color: #0000FF;"&gt;interactive&lt;/span&gt;)
  (bibtex-beginning-of-entry)
  (bibtex-set-field &lt;span style="color: #008000;"&gt;"tweeted"&lt;/span&gt; (current-time-string))

  (&lt;span style="color: #0000FF;"&gt;let*&lt;/span&gt; ((entry-string (&lt;span style="color: #0000FF;"&gt;save-restriction&lt;/span&gt;
                         (bibtex-beginning-of-entry)
                         (bibtex-narrow-to-entry)
                         (buffer-substring-no-properties (point-min) (point-max))))
         (entry (bibtex-parse-entry t))
         (key (cdr (assoc &lt;span style="color: #008000;"&gt;"=key="&lt;/span&gt; entry)))
         (doi (cdr (assoc &lt;span style="color: #008000;"&gt;"doi"&lt;/span&gt; entry)))
         (svg-file (expand-file-name (format &lt;span style="color: #008000;"&gt;"%s.svg"&lt;/span&gt; key) temporary-file-directory))
         (png-file (expand-file-name (format &lt;span style="color: #008000;"&gt;"%s.png"&lt;/span&gt; key) temporary-file-directory))
         (bib-file (expand-file-name (format &lt;span style="color: #008000;"&gt;"%s.bib"&lt;/span&gt; key) temporary-file-directory))
         (py-file (expand-file-name (format &lt;span style="color: #008000;"&gt;"%s.py"&lt;/span&gt; key) temporary-file-directory))
         (formatted-entry (orhc-formatted-citation entry))
         (lines (&lt;span style="color: #0000FF;"&gt;with-temp-buffer&lt;/span&gt;
                  (insert formatted-entry)
                  (fill-paragraph)
                  (split-string  (buffer-string) &lt;span style="color: #008000;"&gt;"\n"&lt;/span&gt;)))
         (svg (svg-create 500 (* 20 (length lines))))
         (tweet (read-string &lt;span style="color: #008000;"&gt;"Tweet: "&lt;/span&gt;))
         gist-url
         full-tweet)

    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;delete buffers and files&lt;/span&gt;
    (&lt;span style="color: #0000FF;"&gt;loop&lt;/span&gt; for buf in (list (concat key &lt;span style="color: #008000;"&gt;".bib"&lt;/span&gt;)
                           (concat key &lt;span style="color: #008000;"&gt;".png"&lt;/span&gt;)
                           (concat key &lt;span style="color: #008000;"&gt;".svg"&lt;/span&gt;)
                           (concat key &lt;span style="color: #008000;"&gt;".py"&lt;/span&gt;))
          do
          (&lt;span style="color: #0000FF;"&gt;when&lt;/span&gt; (get-buffer buf)
            (kill-buffer (get-buffer buf))))

    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;Step 1 make the image&lt;/span&gt;
    (&lt;span style="color: #0000FF;"&gt;loop&lt;/span&gt; for i from 0
          for line in lines
          do
          (svg-text svg line
                    &lt;span style="color: #006FE0;"&gt;:font-size&lt;/span&gt; &lt;span style="color: #008000;"&gt;"12"&lt;/span&gt;
                    &lt;span style="color: #006FE0;"&gt;:stroke&lt;/span&gt; &lt;span style="color: #008000;"&gt;"black"&lt;/span&gt;
                    &lt;span style="color: #006FE0;"&gt;:x&lt;/span&gt; 0
                    &lt;span style="color: #006FE0;"&gt;:y&lt;/span&gt; (+ 15 (* i 15))
                    &lt;span style="color: #006FE0;"&gt;:stroke-width&lt;/span&gt; 0.3))

    (&lt;span style="color: #0000FF;"&gt;with-temp-file&lt;/span&gt; svg-file
      (svg-print svg))

    (shell-command (format &lt;span style="color: #008000;"&gt;"convert %s %s"&lt;/span&gt; svg-file png-file))

    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;Step 2, make the gist. Make a temp-file so the gist has a reasonable name&lt;/span&gt;
    (&lt;span style="color: #0000FF;"&gt;with-temp-file&lt;/span&gt; bib-file
      (insert entry-string))

    (&lt;span style="color: #0000FF;"&gt;let&lt;/span&gt; ((bib-buffer (find-file-noselect bib-file)))
      (&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt; bib-buffer
        (gist-buffer))
      (kill-buffer bib-buffer))

    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;get url off clipboard&lt;/span&gt;
    (&lt;span style="color: #0000FF;"&gt;setq&lt;/span&gt; gist-url (&lt;span style="color: #0000FF;"&gt;with-temp-buffer&lt;/span&gt;
                     (yank)
                     (buffer-string)))

    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;Format and send the tweet:&lt;/span&gt;
    (&lt;span style="color: #0000FF;"&gt;setq&lt;/span&gt; full-tweet (format &lt;span style="color: #008000;"&gt;"#publication %s\nhttps://doi.org/%s\nbibtex: %s"&lt;/span&gt; tweet doi gist-url))

    (&lt;span style="color: #0000FF;"&gt;with-temp-file&lt;/span&gt; py-file
      (insert (format &lt;span style="color: #008000;"&gt;"from TwitterAPI import TwitterAPI&lt;/span&gt;
&lt;span style="color: #008000;"&gt;from twitter_secrets import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET&lt;/span&gt;

&lt;span style="color: #008000;"&gt;api = TwitterAPI(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)&lt;/span&gt;
&lt;span style="color: #008000;"&gt;file = open('%s', 'rb')&lt;/span&gt;
&lt;span style="color: #008000;"&gt;data = file.read()&lt;/span&gt;
&lt;span style="color: #008000;"&gt;r = api.request('statuses/update_with_media', {'status':'''%s'''}, {'media[]':data})"&lt;/span&gt;
                      png-file
                      full-tweet)))

    (&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt; (= 0 (shell-command (format &lt;span style="color: #008000;"&gt;"python %s"&lt;/span&gt; py-file)))
        (message &lt;span style="color: #008000;"&gt;"%s"&lt;/span&gt; full-tweet)
      (message &lt;span style="color: #008000;"&gt;"tweet failed ;("&lt;/span&gt;))))

&lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;Now, try it out.&lt;/span&gt;
(&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt; (find-file-noselect &lt;span style="color: #008000;"&gt;"~/Dropbox/bibliography/references.bib"&lt;/span&gt;)
  (goto-char (point-min))
  (re-search-forward &lt;span style="color: #008000;"&gt;"kitchin-2016-autom-data,"&lt;/span&gt;)
  (tweet-bibtex))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
You can see what this tweet looks like here:
&lt;/p&gt;

&lt;blockquote class="twitter-tweet" data-lang="en"&gt;&lt;p lang="en" dir="ltr"&gt;&lt;a href="https://twitter.com/hashtag/publication?src=hash"&gt;#publication&lt;/a&gt; I tweeted this from a bibtex file.&lt;a href="https://t.co/NGVlRGqKSJ"&gt;https://t.co/NGVlRGqKSJ&lt;/a&gt;&lt;br&gt;bibtex: &lt;a href="https://t.co/0UEkvyBKAM"&gt;https://t.co/0UEkvyBKAM&lt;/a&gt; &lt;a href="https://t.co/OpbAt1h3OP"&gt;pic.twitter.com/OpbAt1h3OP&lt;/a&gt;&lt;/p&gt;&amp;mdash; John Kitchin (@johnkitchin) &lt;a href="https://twitter.com/johnkitchin/status/768838551140261894"&gt;August 25, 2016&lt;/a&gt;&lt;/blockquote&gt; &lt;script async src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;

&lt;p&gt;
That seems pretty reasonable. Now I only need to use it about 48,000 times to benefit from the time-savings M-x tweet-bibtex offers compared to manually making all those tweets ;)
&lt;/p&gt;
&lt;p&gt;Copyright (C) 2016 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;
&lt;p&gt;&lt;a href="/org/2016/08/25/Automated-bibtex-entry-tweeting.org"&gt;org-mode source&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Org-mode version = 8.3.4&lt;/p&gt;
]]></content:encoded>
    </item>
    <item>
      <title>A python version of the s-exp bibtex entry</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2015/06/11/A-python-version-of-the-s-exp-bibtex-entry</link>
      <pubDate>Thu, 11 Jun 2015 10:02:33 EDT</pubDate>
      <category><![CDATA[bibtex]]></category>
      <category><![CDATA[ref]]></category>
      <category><![CDATA[python]]></category>
      <guid isPermaLink="false">wiSIiOPCsb2TZCwk1GsyFwgTiFw=</guid>
      <description>A python version of the s-exp bibtex entry</description>
      <content:encoded><![CDATA[



&lt;p&gt;
In this &lt;a href="http://kitchingroup.cheme.cmu.edu/blog/2015/06/10/A-sexp-version-of-a-bibtex-entry/"&gt;post&lt;/a&gt; we explored representing a bibtex entry in lisp s-exp notation, and showed interesting things that enables. Here, I explore something similar in Python. The s-exp notation in Python is really more like tuples. It looks almost identical, except we need a lot of commas for the Python syntax. One significant difference in Python is we need to define the functions in advance because otherwise the function symbols are undefined. Similar to lisp, we can define the field functions at run-time in a loop. We have to use an eval statement, which some Pythonistas find distasteful, but it is not that different to me than what we did in lisp.
&lt;/p&gt;

&lt;p&gt;
The syntax for "executing" the data structure is quite different than in lisp, because this data is &lt;i&gt;not&lt;/i&gt; code in Python. Instead, we have to deconstruct the data, knowing that the function is the first object, and it takes the remaining arguments in the tuple.
&lt;/p&gt;

&lt;p&gt;
Here is the proof of concept:
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-python"&gt;&lt;span style="color: #0000FF;"&gt;def&lt;/span&gt; &lt;span style="color: #006699;"&gt;article&lt;/span&gt;(bibtex_key, *args):
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #008000;"&gt;"Return the bibtex formatted entry"&lt;/span&gt;
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;return&lt;/span&gt; &lt;span style="color: #008000;"&gt;',\n'&lt;/span&gt;.join([&lt;span style="color: #008000;"&gt;'@article{{{0}}}'&lt;/span&gt;.&lt;span style="color: #006FE0;"&gt;format&lt;/span&gt;(bibtex_key)] +[arg[0](arg[1]) &lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; arg &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; args[0]] + [&lt;span style="color: #008000;"&gt;'}'&lt;/span&gt;])

&lt;span style="color: #BA36A5;"&gt;fields&lt;/span&gt; = (&lt;span style="color: #008000;"&gt;"author"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"title"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"journal"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"pages"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"number"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"doi"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"url"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"eprint"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"year"&lt;/span&gt;)

&lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; f &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; fields:
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #006FE0;"&gt;locals&lt;/span&gt;()[f] = &lt;span style="color: #006FE0;"&gt;eval&lt;/span&gt; (&lt;span style="color: #008000;"&gt;'lambda x: "  {0} = {{{1}}}".format("'&lt;/span&gt; + f + &lt;span style="color: #008000;"&gt;'", x)'&lt;/span&gt;)

&lt;span style="color: #BA36A5;"&gt;entry&lt;/span&gt; = (article, &lt;span style="color: #008000;"&gt;"hallenbeck-2013-effec-o2"&lt;/span&gt;,
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;    (author, &lt;span style="color: #008000;"&gt;"Hallenbeck, Alexander P. and Kitchin, John R."&lt;/span&gt;),
         (title, &lt;span style="color: #008000;"&gt;"Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent"&lt;/span&gt;),
         (journal, &lt;span style="color: #008000;"&gt;"Industrial \&amp;amp; Engineering Chemistry Research"&lt;/span&gt;),
         (pages, &lt;span style="color: #008000;"&gt;"10788-10794"&lt;/span&gt;),
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;    (year, 2013),
         (number, 31),
         (doi, &lt;span style="color: #008000;"&gt;"10.1021/ie400582a"&lt;/span&gt;),
         (url, &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/abs/10.1021/ie400582a"&lt;/span&gt;),
         (eprint, &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/pdf/10.1021/ie400582a"&lt;/span&gt;))


&lt;span style="color: #0000FF;"&gt;print&lt;/span&gt; entry[0](entry[1], entry[2:])
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
@article{hallenbeck-2013-effec-o2},
  author = {Hallenbeck, Alexander P. and Kitchin, John R.},
  title = {Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent},
  journal = {Industrial \&amp;amp; Engineering Chemistry Research},
  pages = {10788-10794},
  year = {2013},
  number = {31},
  doi = {10.1021/ie400582a},
  url = {http://pubs.acs.org/doi/abs/10.1021/ie400582a},
  eprint = {http://pubs.acs.org/doi/pdf/10.1021/ie400582a},
}
&lt;/pre&gt;

&lt;p&gt;
We can still get specific fields out. Since we used a tuple here, it is not quite as nice as using a dictionary, but it is neither too bad, and it can be wrapped in a reasonably convenient function.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-python"&gt;&lt;span style="color: #0000FF;"&gt;def&lt;/span&gt; &lt;span style="color: #006699;"&gt;article&lt;/span&gt;(bibtex_key, *args):
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #008000;"&gt;"Return the bibtex formatted entry"&lt;/span&gt;
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;return&lt;/span&gt; &lt;span style="color: #008000;"&gt;',\n'&lt;/span&gt;.join([&lt;span style="color: #008000;"&gt;'@article{{{0}}}'&lt;/span&gt;.&lt;span style="color: #006FE0;"&gt;format&lt;/span&gt;(bibtex_key)] +[arg[0](arg[1]) &lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; arg &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; args[0]] + [&lt;span style="color: #008000;"&gt;'}'&lt;/span&gt;])

&lt;span style="color: #BA36A5;"&gt;fields&lt;/span&gt; = (&lt;span style="color: #008000;"&gt;"author"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"title"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"journal"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"pages"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"number"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"doi"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"url"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"eprint"&lt;/span&gt;, &lt;span style="color: #008000;"&gt;"year"&lt;/span&gt;)

&lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; f &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; fields:
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #006FE0;"&gt;locals&lt;/span&gt;()[f] = &lt;span style="color: #006FE0;"&gt;eval&lt;/span&gt; (&lt;span style="color: #008000;"&gt;'lambda x: "  {0} = {{{1}}}".format("'&lt;/span&gt; + f + &lt;span style="color: #008000;"&gt;'", x)'&lt;/span&gt;)

&lt;span style="color: #BA36A5;"&gt;entry&lt;/span&gt; = (article, &lt;span style="color: #008000;"&gt;"hallenbeck-2013-effec-o2"&lt;/span&gt;,
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;    (author, &lt;span style="color: #008000;"&gt;"Hallenbeck, Alexander P. and Kitchin, John R."&lt;/span&gt;),
         (title, &lt;span style="color: #008000;"&gt;"Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent"&lt;/span&gt;),
         (journal, &lt;span style="color: #008000;"&gt;"Industrial \&amp;amp; Engineering Chemistry Research"&lt;/span&gt;),
         (pages, &lt;span style="color: #008000;"&gt;"10788-10794"&lt;/span&gt;),
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;    (year, 2013),
         (number, 31),
         (doi, &lt;span style="color: #008000;"&gt;"10.1021/ie400582a"&lt;/span&gt;),
         (url, &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/abs/10.1021/ie400582a"&lt;/span&gt;),
         (eprint, &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/pdf/10.1021/ie400582a"&lt;/span&gt;))


&lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; field &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; entry[2:]:
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;if&lt;/span&gt; field[0] == author:
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;print&lt;/span&gt; field

&lt;span style="color: #0000FF;"&gt;def&lt;/span&gt; &lt;span style="color: #006699;"&gt;get_field&lt;/span&gt;(entry, field):
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;for&lt;/span&gt; element &lt;span style="color: #0000FF;"&gt;in&lt;/span&gt; entry[2:]:
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;if&lt;/span&gt; element[0] == field:
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;return&lt;/span&gt; element[1]
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;:
&lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #9B9B9B; background-color: #EDEDED;"&gt; &lt;/span&gt;   &lt;span style="color: #0000FF;"&gt;return&lt;/span&gt; &lt;span style="color: #D0372D;"&gt;None&lt;/span&gt;

&lt;span style="color: #0000FF;"&gt;print&lt;/span&gt; get_field(entry, title)
&lt;span style="color: #0000FF;"&gt;print&lt;/span&gt; get_field(entry, &lt;span style="color: #008000;"&gt;"bad"&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
(&amp;lt;function &amp;lt;lambda&amp;gt; at 0x1005975f0&amp;gt;, 'Hallenbeck, Alexander P. and Kitchin, John R.')
Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent
None
&lt;/pre&gt;

&lt;p&gt;
So, it seems Python can do some things like lisp in treating functions like first-class objects that can be used as functions, or keys. I still like the lisp s-exp better, but this is an interesting idea for Python too.
&lt;/p&gt;
&lt;p&gt;Copyright (C) 2015 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;&lt;p&gt;&lt;a href="/org/2015/06/11/A-python-version-of-the-s-exp-bibtex-entry.org"&gt;org-mode source&lt;/a&gt;&lt;p&gt;&lt;p&gt;Org-mode version = 8.2.10&lt;/p&gt;]]></content:encoded>
    </item>
    <item>
      <title>A sexp version of a bibtex entry</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2015/06/10/A-sexp-version-of-a-bibtex-entry</link>
      <pubDate>Wed, 10 Jun 2015 08:54:00 EDT</pubDate>
      <category><![CDATA[lisp]]></category>
      <category><![CDATA[bibtex]]></category>
      <guid isPermaLink="false">BmILlGfMZSWZ6HJprHCTM4MR6zA=</guid>
      <description>A sexp version of a bibtex entry</description>
      <content:encoded><![CDATA[



&lt;p&gt;
Below you see a typical bibtex entry. Today we explore an alternate approach to represent the information (data) in that entry as s-expressions, i.e. as a lisp data structure. Why? because it seems like an interesting exploration!
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-bibtex"&gt;&lt;span style="color: #006699;"&gt;@article&lt;/span&gt;{&lt;span style="color: #D0372D;"&gt;hallenbeck-2013-effec-o2&lt;/span&gt;,
  &lt;span style="color: #BA36A5;"&gt;author&lt;/span&gt; =       "Hallenbeck, Alexander P. and Kitchin, John R.",
  &lt;span style="color: #BA36A5;"&gt;title&lt;/span&gt; =        {Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a
                  primary-amine based polymeric \ce{CO_2} sorbent},
  &lt;span style="color: #BA36A5;"&gt;keywords&lt;/span&gt; =     {RUA, orgmode},
  &lt;span style="color: #BA36A5;"&gt;journal&lt;/span&gt; =      "Industrial \&amp;amp; Engineering Chemistry Research",
  &lt;span style="color: #BA36A5;"&gt;pages&lt;/span&gt; =        "10788-10794",
  &lt;span style="color: #BA36A5;"&gt;year&lt;/span&gt; =         2013,
  &lt;span style="color: #BA36A5;"&gt;volume&lt;/span&gt; =       {52},
  &lt;span style="color: #BA36A5;"&gt;number&lt;/span&gt; =       {31},
  &lt;span style="color: #BA36A5;"&gt;doi&lt;/span&gt; =          "&lt;span style="color: #006DAF; text-decoration: underline;"&gt;10.1021/ie400582a&lt;/span&gt;",
  &lt;span style="color: #BA36A5;"&gt;url&lt;/span&gt; =          "&lt;span style="color: #006DAF; text-decoration: underline;"&gt;http://pubs.acs.org/doi/abs/10.1021/ie400582a&lt;/span&gt;",
  &lt;span style="color: #BA36A5;"&gt;eprint&lt;/span&gt; =       "http://pubs.acs.org/doi/pdf/10.1021/ie400582a",
}
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Here is what that same data structure might look like as a sexp-based lisp data structure.
&lt;/p&gt;
&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(article &lt;span style="color: #008000;"&gt;"hallenbeck-2013-effec-o2"&lt;/span&gt;
         (author &lt;span style="color: #008000;"&gt;"Hallenbeck, Alexander P. and Kitchin, John R."&lt;/span&gt;)
         (title &lt;span style="color: #008000;"&gt;"Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent"&lt;/span&gt;)
         (journal &lt;span style="color: #008000;"&gt;"Industrial \&amp;amp; Engineering Chemistry Research"&lt;/span&gt;)
         (pages &lt;span style="color: #008000;"&gt;"10788-10794"&lt;/span&gt;)
         (year 2013)
         (number 31)
         (doi &lt;span style="color: #008000;"&gt;"10.1021/ie400582a"&lt;/span&gt;)
         (url &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/abs/10.1021/ie400582a"&lt;/span&gt;)
         (eprint &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/pdf/10.1021/ie400582a"&lt;/span&gt;))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
We can retrieve data from the sexp form pretty easily. Here we get the authors.
&lt;/p&gt;
&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;let*&lt;/span&gt; ((art '(article &lt;span style="color: #008000;"&gt;"hallenbeck-2013-effec-o2"&lt;/span&gt;
                      (author &lt;span style="color: #008000;"&gt;"Hallenbeck, Alexander P. and Kitchin, John R."&lt;/span&gt;)
                      (title &lt;span style="color: #008000;"&gt;"Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent"&lt;/span&gt;)
                      (journal &lt;span style="color: #008000;"&gt;"Industrial \&amp;amp; Engineering Chemistry Research"&lt;/span&gt;)
                      (pages &lt;span style="color: #008000;"&gt;"10788-10794"&lt;/span&gt;)
                      (year 2013)
                      (number 31)
                      (doi &lt;span style="color: #008000;"&gt;"10.1021/ie400582a"&lt;/span&gt;)
                      (url &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/abs/10.1021/ie400582a"&lt;/span&gt;)
                      (eprint &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/pdf/10.1021/ie400582a"&lt;/span&gt;)))
       (fields (cddr art)))
  (cadr (assoc 'author fields)))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
Hallenbeck, Alexander P. and Kitchin, John R.
&lt;/pre&gt;

&lt;p&gt;
That is simple enough you might just write a little function to streamline it like this, and return a formatted string.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;defun&lt;/span&gt; &lt;span style="color: #006699;"&gt;get-article-field&lt;/span&gt; (article field)
  &lt;span style="color: #036A07;"&gt;"Return value of FIELD in ARTICLE."&lt;/span&gt;
  (cadr (assoc field (cddr article))))

(&lt;span style="color: #0000FF;"&gt;let&lt;/span&gt; ((art '(article &lt;span style="color: #008000;"&gt;"hallenbeck-2013-effec-o2"&lt;/span&gt;
                     (author &lt;span style="color: #008000;"&gt;"Hallenbeck, Alexander P. and Kitchin, John R."&lt;/span&gt;)
                     (title &lt;span style="color: #008000;"&gt;"Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent"&lt;/span&gt;)
                     (journal &lt;span style="color: #008000;"&gt;"Industrial \&amp;amp; Engineering Chemistry Research"&lt;/span&gt;)
                     (pages &lt;span style="color: #008000;"&gt;"10788-10794"&lt;/span&gt;)
                     (year 2013)
                     (number 31)
                     (doi &lt;span style="color: #008000;"&gt;"10.1021/ie400582a"&lt;/span&gt;)
                     (url &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/abs/10.1021/ie400582a"&lt;/span&gt;)
                     (eprint &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/pdf/10.1021/ie400582a"&lt;/span&gt;))))
  (format &lt;span style="color: #008000;"&gt;"%s, doi:%s (%s)"&lt;/span&gt;
          (get-article-field art 'author)
          (get-article-field art 'doi)
          (get-article-field art 'year)))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
Hallenbeck, Alexander P. and Kitchin, John R., doi:10.1021/ie400582a (2013)
&lt;/pre&gt;

&lt;p&gt;
You might be wondering, why is that even a little bit interesting? One reason is that it looks a little like what lisp returns after parsing an xml file. Another is, the data structure looks kind of like data, but it is also some code, if article was defined as a function!  Let us consider what this might look like. I use a macro to define the field functions since in this case they all do the same thing, and these simply return a string with the field-name and value in curly brackets. We eval the macro to make sure it defines the function. I define an article function that wraps the fields in @bibtex-key{fields}, which defines a bibtex entry.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;defmacro&lt;/span&gt; &lt;span style="color: #006699;"&gt;make-field&lt;/span&gt; (field-name)
  &lt;span style="color: #036A07;"&gt;"define a field that returns a string"&lt;/span&gt;
  `(&lt;span style="color: #0000FF;"&gt;defun&lt;/span&gt; ,(intern field-name) (content)
     (format &lt;span style="color: #008000;"&gt;"  %s = {%s}"&lt;/span&gt; ,field-name content)))

(&lt;span style="color: #0000FF;"&gt;loop&lt;/span&gt; for field in '(&lt;span style="color: #008000;"&gt;"author"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"title"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"journal"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"pages"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"number"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"doi"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"url"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"eprint"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"year"&lt;/span&gt;)
  do (eval `(make-field ,field)))

(&lt;span style="color: #0000FF;"&gt;defun&lt;/span&gt; &lt;span style="color: #006699;"&gt;article&lt;/span&gt; (bibtex-key &lt;span style="color: #6434A3;"&gt;&amp;amp;rest&lt;/span&gt; fields)
  (concat
   (format &lt;span style="color: #008000;"&gt;"@article{%s,\n"&lt;/span&gt; bibtex-key)
   (mapconcat (&lt;span style="color: #0000FF;"&gt;lambda&lt;/span&gt; (field) (eval field)) fields &lt;span style="color: #008000;"&gt;",\n"&lt;/span&gt;)
   &lt;span style="color: #008000;"&gt;"\n}\n"&lt;/span&gt;))

(article &lt;span style="color: #008000;"&gt;"hallenbeck-2013-effec-o2"&lt;/span&gt;
         (author &lt;span style="color: #008000;"&gt;"Hallenbeck, Alexander P. and Kitchin, John R."&lt;/span&gt;)
         (title &lt;span style="color: #008000;"&gt;"Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent"&lt;/span&gt;)
         (journal &lt;span style="color: #008000;"&gt;"Industrial \&amp;amp; Engineering Chemistry Research"&lt;/span&gt;)
         (pages &lt;span style="color: #008000;"&gt;"10788-10794"&lt;/span&gt;)
         (number 31)
         (year 2013)
         (doi &lt;span style="color: #008000;"&gt;"10.1021/ie400582a"&lt;/span&gt;)
         (url &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/abs/10.1021/ie400582a"&lt;/span&gt;)
         (eprint &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/pdf/10.1021/ie400582a"&lt;/span&gt;))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
@article{hallenbeck-2013-effec-o2,
  author = {Hallenbeck, Alexander P. and Kitchin, John R.},
  title = {Effects of ce{O_2} and ce{SO_2} on the capture capacity of a primary-amine based polymeric ce{CO_2} sorbent},
  journal = {Industrial &amp;amp; Engineering Chemistry Research},
  pages = {10788-10794},
  number = {31},
  year = {2013},
  doi = {10.1021/ie400582a},
  url = {http://pubs.acs.org/doi/abs/10.1021/ie400582a},
  eprint = {http://pubs.acs.org/doi/pdf/10.1021/ie400582a}
}
&lt;/pre&gt;

&lt;p&gt;
Wow. We &lt;i&gt;executed&lt;/i&gt; our data structure, and got a bibtex entry! That seems moderately interesting to me. Next is an example of taking the same data structure and rendering it as xml. This is some lispy wizardry, rather than use a macro to define functions, I temporarily define functions within a cl-flet macro, which I have to collect as a list of code. Then, I eval the list. This feels pretty odd, but seems like a lispy kind of thing to do.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(eval
 (list 'cl-flet
       (append (&lt;span style="color: #0000FF;"&gt;loop&lt;/span&gt; for field in '(&lt;span style="color: #008000;"&gt;"author"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"title"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"journal"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"pages"&lt;/span&gt;
                                      &lt;span style="color: #008000;"&gt;"number"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"doi"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"url"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"eprint"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"year"&lt;/span&gt;)
                       collect (list (intern field)
                                     '(content)
                                     `(format &lt;span style="color: #008000;"&gt;"  &amp;lt;%s&amp;gt;%s&amp;lt;/%s&amp;gt;"&lt;/span&gt; ,field content ,field)))
               '((article (bibtex-key &lt;span style="color: #6434A3;"&gt;&amp;amp;rest&lt;/span&gt; fields)
                          (concat
                           (format
                            &lt;span style="color: #008000;"&gt;"&amp;lt;article bibtex-key=\"%s\"&amp;gt;\n"&lt;/span&gt; bibtex-key)
                           (mapconcat (&lt;span style="color: #0000FF;"&gt;lambda&lt;/span&gt; (field) (eval field)) fields &lt;span style="color: #008000;"&gt;"\n"&lt;/span&gt;)
                           &lt;span style="color: #008000;"&gt;"\n&amp;lt;/article&amp;gt;"&lt;/span&gt;)))
               )
       &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;body of cl-flet&lt;/span&gt;
       '(article &lt;span style="color: #008000;"&gt;"hallenbeck-2013-effec-o2"&lt;/span&gt;
                (author &lt;span style="color: #008000;"&gt;"Hallenbeck, Alexander P. and Kitchin, John R."&lt;/span&gt;)
                (title &lt;span style="color: #008000;"&gt;"Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent"&lt;/span&gt;)
                (journal &lt;span style="color: #008000;"&gt;"Industrial \&amp;amp; Engineering Chemistry Research"&lt;/span&gt;)
                (pages &lt;span style="color: #008000;"&gt;"10788-10794"&lt;/span&gt;)
                (number 31)
                (year 2013)
                (doi &lt;span style="color: #008000;"&gt;"10.1021/ie400582a"&lt;/span&gt;)
                (url &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/abs/10.1021/ie400582a"&lt;/span&gt;)
                (eprint &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/pdf/10.1021/ie400582a"&lt;/span&gt;))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
&amp;lt;article bibtex-key="hallenbeck-2013-effec-o2"&amp;gt;
  &amp;lt;author&amp;gt;Hallenbeck, Alexander P. and Kitchin, John R.&amp;lt;/author&amp;gt;
  &amp;lt;title&amp;gt;Effects of ce{O_2} and ce{SO_2} on the capture capacity of a primary-amine based polymeric ce{CO_2} sorbent&amp;lt;/title&amp;gt;
  &amp;lt;journal&amp;gt;Industrial &amp;amp; Engineering Chemistry Research&amp;lt;/journal&amp;gt;
  &amp;lt;pages&amp;gt;10788-10794&amp;lt;/pages&amp;gt;
  &amp;lt;number&amp;gt;31&amp;lt;/number&amp;gt;
  &amp;lt;year&amp;gt;2013&amp;lt;/year&amp;gt;
  &amp;lt;doi&amp;gt;10.1021/ie400582a&amp;lt;/doi&amp;gt;
  &amp;lt;url&amp;gt;http://pubs.acs.org/doi/abs/10.1021/ie400582a&amp;lt;/url&amp;gt;
  &amp;lt;eprint&amp;gt;http://pubs.acs.org/doi/pdf/10.1021/ie400582a&amp;lt;/eprint&amp;gt;
&amp;lt;/article&amp;gt;
&lt;/pre&gt;

&lt;p&gt;
Prefer json? No problem, just reformat the functions!
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(eval
 (list 'cl-flet
       (append (&lt;span style="color: #0000FF;"&gt;loop&lt;/span&gt; for field in '(&lt;span style="color: #008000;"&gt;"author"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"title"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"journal"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"pages"&lt;/span&gt;
                                      &lt;span style="color: #008000;"&gt;"number"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"doi"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"url"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"eprint"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"year"&lt;/span&gt;)
                       collect (list (intern field)
                                     '(content)
                                     `(format &lt;span style="color: #008000;"&gt;"   \"%s\": \"%s\""&lt;/span&gt; ,field content)))
               '((article (bibtex-key &lt;span style="color: #6434A3;"&gt;&amp;amp;rest&lt;/span&gt; fields)
                          (concat
                           (format
                            &lt;span style="color: #008000;"&gt;"{\"article\":\n  {\"bibtex-key\": \"%s\",\n"&lt;/span&gt; bibtex-key)
                           (mapconcat (&lt;span style="color: #0000FF;"&gt;lambda&lt;/span&gt; (field) (eval field)) fields &lt;span style="color: #008000;"&gt;",\n"&lt;/span&gt;)
                           &lt;span style="color: #008000;"&gt;"}\n}"&lt;/span&gt;))))
       &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;body of cl-flet&lt;/span&gt;
       '(article &lt;span style="color: #008000;"&gt;"hallenbeck-2013-effec-o2"&lt;/span&gt;
                (author &lt;span style="color: #008000;"&gt;"Hallenbeck, Alexander P. and Kitchin, John R."&lt;/span&gt;)
                (title &lt;span style="color: #008000;"&gt;"Effects of \ce{O_2} and \ce{SO_2} on the capture capacity of a primary-amine based polymeric \ce{CO_2} sorbent"&lt;/span&gt;)
                (journal &lt;span style="color: #008000;"&gt;"Industrial \&amp;amp; Engineering Chemistry Research"&lt;/span&gt;)
                (pages &lt;span style="color: #008000;"&gt;"10788-10794"&lt;/span&gt;)
                (number 31)
                (year 2013)
                (doi &lt;span style="color: #008000;"&gt;"10.1021/ie400582a"&lt;/span&gt;)
                (url &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/abs/10.1021/ie400582a"&lt;/span&gt;)
                (eprint &lt;span style="color: #008000;"&gt;"http://pubs.acs.org/doi/pdf/10.1021/ie400582a"&lt;/span&gt;))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
{"article":
  {"bibtex-key": "hallenbeck-2013-effec-o2",
   "author": "Hallenbeck, Alexander P. and Kitchin, John R.",
   "title": "Effects of ce{O_2} and ce{SO_2} on the capture capacity of a primary-amine based polymeric ce{CO_2} sorbent",
   "journal": "Industrial &amp;amp; Engineering Chemistry Research",
   "pages": "10788-10794",
   "number": "31",
   "year": "2013",
   "doi": "10.1021/ie400582a",
   "url": "http://pubs.acs.org/doi/abs/10.1021/ie400582a",
   "eprint": "http://pubs.acs.org/doi/pdf/10.1021/ie400582a"}
}
&lt;/pre&gt;

&lt;p&gt;
Is this useful? Great question. I don't plan to convert by bibtex files to sexp format anytime soon ;) The format I used above is just a simple one. It might be desirable to include individual authors instead of an author string, and maybe support attributes to establish an author order. An author structure might be more complex to include scientific ids like an orcid, alternative names, etc&amp;#x2026; Finally, the s-exp data structure is super easy to use in lisp, but other languages would have parse it into some native structure the way they parse json or xml. There is limited support for s-expressions in most other non-lispy languages.
&lt;/p&gt;

&lt;p&gt;
I like the idea of data representation as code, and its conversion to some other kind of format. It is subtle here, but notice we &lt;i&gt;never&lt;/i&gt; had to write a parser for the sexp notation. That &lt;i&gt;already exists as the lisp interpreter&lt;/i&gt;. We did write code to use the data, and convert the data. The sexp notation is pretty easy to write, in contrast to the xml or json representations. Some interesting issues might be what to do with fields that are not defined, perhaps a macro would be used on the fly, or in the cl-flet definition. It is hard to imagine doing these things in another language than lisp!
&lt;/p&gt;
&lt;p&gt;Copyright (C) 2015 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;&lt;p&gt;&lt;a href="/org/2015/06/10/A-sexp-version-of-a-bibtex-entry.org"&gt;org-mode source&lt;/a&gt;&lt;p&gt;&lt;p&gt;Org-mode version = 8.2.10&lt;/p&gt;]]></content:encoded>
    </item>
    <item>
      <title>Bibtex Entries from Arxiv.org</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2015/03/09/Bibtex-Entries-from-Arxiv-org</link>
      <pubDate>Mon, 09 Mar 2015 15:14:52 EDT</pubDate>
      <category><![CDATA[emacs]]></category>
      <category><![CDATA[bibtex]]></category>
      <guid isPermaLink="false">HE-BdWxxqUIs7VAhvRQXrqoIpes=</guid>
      <description>Bibtex Entries from Arxiv.org</description>
      <content:encoded><![CDATA[



&lt;p&gt;
&lt;a href="http://arxiv.org"&gt;http://arxiv.org&lt;/a&gt; is an open-source physics preprint server where copies of scientific manuscripts can be found. For example, &lt;a href="http://arxiv.org/abs/0801.1144"&gt;http://arxiv.org/abs/0801.1144&lt;/a&gt; is a paper I wrote, and you can find the PDF for that paper here: &lt;a href="http://arxiv.org/pdf/0801.1144v1"&gt;http://arxiv.org/pdf/0801.1144v1&lt;/a&gt; . Each entry at Arxiv has an arxiv number, and for this paper the number is "0801.1144". In this post, we explore some capabilities of the &lt;a href="https://github.com/jkitchin/org-ref/blob/master/arxiv.el"&gt;arxiv.el&lt;/a&gt; library which is part of org-ref (&lt;a href="https://github.com/jkitchin/org-ref"&gt;https://github.com/jkitchin/org-ref&lt;/a&gt; ).
&lt;/p&gt;

&lt;p&gt;
To use this library, get the org-ref distribution, make sure it is on your path, and then require the library:
&lt;/p&gt;
&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;require&lt;/span&gt; '&lt;span style="color: #D0372D;"&gt;arxiv&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
First, there is a new org-link:  &lt;a href="http://arxiv.org/abs/0801.1144"&gt;arxiv:0801.1144&lt;/a&gt;. This is a clickable link that simply opens arxiv.org at the URL for an arxiv number, and exports as a link to that entry in arxiv.
&lt;/p&gt;

&lt;p&gt;
On the right hand side of the arxiv page, there is a link under References &amp;amp; Citations that takes you to a page where you can get a bibtex entry. The link for this entry is &lt;a href="http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:0801.1144"&gt;http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:0801.1144&lt;/a&gt; . On that page, there is a link to a bibtex entry (&lt;a href="http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=2008PhRvB..77g5437K&amp;data_type=BIBTEX&amp;db_key=PHY&amp;nocookieset=1"&gt;http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=2008PhRvB..77g5437K&amp;data_type=BIBTEX&amp;db_key=PHY&amp;nocookieset=1&lt;/a&gt; ).  We can construct this link pretty easily, we just need the bibcode for that entry. arxiv.el provides a function for that.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(arxiv-get-bibliographic-code &lt;span style="color: #008000;"&gt;"0801.1144"&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
2008PhRvB..77g5437K
&lt;/pre&gt;

&lt;p&gt;
Next, once we have a url, we can get the text of the bibtex entry.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(arxiv-get-bibtex-entry &lt;span style="color: #008000;"&gt;"2008PhRvB..77g5437K"&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
@ARTICLE{2008PhRvB..77g5437K,
   author = {{Kitchin}, J.~R. and {Reuter}, K. and {Scheffler}, M.},
    title = "{Alloy surface segregation in reactive environments: First-principles atomistic thermodynamics study of Ag$_{3}$Pd(111) in oxygen atmospheres}",
  journal = {\prb},
archivePrefix = "arXiv",
   eprint = {0801.1144},
 primaryClass = "cond-mat.mtrl-sci",
 keywords = {Ab initio calculations of adsorbate structure and reactions, Density functional theory local density approximation gradient and other corrections, Oxidation},
     year = 2008,
    month = feb,
   volume = 77,
   number = 7,
      eid = {075437},
    pages = {075437},
      doi = {10.1103/PhysRevB.77.075437},
   adsurl = {http://adsabs.harvard.edu/abs/2008PhRvB..77g5437K},
  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
&lt;/pre&gt;

&lt;p&gt;
Finally, arxiv.el wraps those to functions together into an interactive function &lt;code&gt;arxiv-add-bibtex-entry&lt;/code&gt; which prompts you for an arxiv number, and then a bibtex file, and then adds the text above to your bibtex file. You can then clean the entry as you see fit. It is also possible to get the pdf for an arxiv entry via &lt;code&gt;arxiv-get-pdf&lt;/code&gt;. This is an interactive function that will prompt you for an arxiv number and a pdf file name, and it will then get the pdf for you and open it. I have not integrated this with the bibtex entry function yet, but one would ideally clean the bibtex entry to get a uniform key, and then get the pdf and name it according to the key like we do in org-ref.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(arxiv-get-pdf &lt;span style="color: #008000;"&gt;"0801.1144"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"0801.1144.pdf"&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
If you use &lt;a href="https://github.com/jkitchin/jmax/blob/master/words.el"&gt;words.el&lt;/a&gt; you will find a new function &lt;code&gt;words-arxiv&lt;/code&gt; which allows you to search the selected text or word at point on arxiv.org.
&lt;/p&gt;

&lt;p&gt;
I do not use arxiv.org a lot, so this is not super well tested on many articles in arxiv.org, but it has worked on the few examples I have tested so far.
&lt;/p&gt;
&lt;p&gt;Copyright (C) 2015 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;&lt;p&gt;&lt;a href="/org/2015/03/09/Bibtex-Entries-from-Arxiv.org.org"&gt;org-mode source&lt;/a&gt;&lt;p&gt;&lt;p&gt;Org-mode version = 8.2.10&lt;/p&gt;]]></content:encoded>
    </item>
    <item>
      <title>Turn an ISBN to a bibtex entry</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2015/01/31/Turn-an-ISBN-to-a-bibtex-entry</link>
      <pubDate>Sat, 31 Jan 2015 15:48:39 EST</pubDate>
      <category><![CDATA[bibtex]]></category>
      <guid isPermaLink="false">r4J6MnDJgujiwuNPEsngAyRriio=</guid>
      <description>Turn an ISBN to a bibtex entry</description>
      <content:encoded><![CDATA[


&lt;p&gt;
Occasionally, I need a bibtex entry for a book. Books are often identified by an ISBN number. Similar to using Crossref to get metadata about a DOI, we can use a web service to get metadata about an ISBN. From that, we might be able to construct a bibtex entry.
&lt;/p&gt;

&lt;p&gt;
Here is an example of what we can get for ISBN 9780309095211. It does not seem to matter if there are dashes in the ISBN or not.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt;
        (url-retrieve-synchronously
&lt;span style="color: #008000;"&gt;"http://xisbn.worldcat.org/webservices/xid/isbn/9780309095211?method=getMetadata&amp;amp;format=json&amp;amp;fl=*"&lt;/span&gt;)
      (buffer-substring url-http-end-of-headers (point-max)))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
{
 "stat":"ok",
 "list":[{
	"url":["http://www.worldcat.org/oclc/224969280?referer=xid"],
	"publisher":"National Academies Press",
	"form":["BC"],
	"lccn":["2006016786"],
	"lang":"eng",
	"city":"Washington, D.C.",
	"author":"Committee on the Guide to Recruiting and Advancing Women Scientists and Engineers in Academia, Committee on Women in Science and Engineering, Policy and Global Affairs, National Research Council of the National Academies.",
	"ed":"[Online-Ausg.]",
	"year":"2006",
	"isbn":["9780309095211"],
	"title":"To recruit and advance women students and faculty in science and engineering",
	"oclcnum":["224969280",
	 "70060944",
	 "756709329",
	 "804792476",
	 "817950524",
	 "833420290",
	 "836338922",
	 "704551455"]}]}
&lt;/pre&gt;

&lt;p&gt;
We get a nice json data string back. We can parst that to get an actual data structure.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt;
        (url-retrieve-synchronously
&lt;span style="color: #008000;"&gt;"http://xisbn.worldcat.org/webservices/xid/isbn/9780309095211?method=getMetadata&amp;amp;format=json&amp;amp;fl=*"&lt;/span&gt;)
      (json-read-from-string
        (buffer-substring url-http-end-of-headers (point-max))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;((list .
       [((oclcnum .
                  [&lt;span style="color: #008000;"&gt;"224969280"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"70060944"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"756709329"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"804792476"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"817950524"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"833420290"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"836338922"&lt;/span&gt; &lt;span style="color: #008000;"&gt;"704551455"&lt;/span&gt;])
         (title . &lt;span style="color: #008000;"&gt;"To recruit and advance women students and faculty in science and engineering"&lt;/span&gt;)
         (isbn .
               [&lt;span style="color: #008000;"&gt;"9780309095211"&lt;/span&gt;])
         (year . &lt;span style="color: #008000;"&gt;"2006"&lt;/span&gt;)
         (ed . &lt;span style="color: #008000;"&gt;"[Online-Ausg.]"&lt;/span&gt;)
         (author . &lt;span style="color: #008000;"&gt;"Committee on the Guide to Recruiting and Advancing Women Scientists and Engineers in Academia, Committee on Women in Science and Engineering, Policy and Global Affairs, National Research Council of the National Academies."&lt;/span&gt;)
         (city . &lt;span style="color: #008000;"&gt;"Washington, D.C."&lt;/span&gt;)
         (lang . &lt;span style="color: #008000;"&gt;"eng"&lt;/span&gt;)
         (lccn .
               [&lt;span style="color: #008000;"&gt;"2006016786"&lt;/span&gt;])
         (form .
               [&lt;span style="color: #008000;"&gt;"BC"&lt;/span&gt;])
         (publisher . &lt;span style="color: #008000;"&gt;"National Academies Press"&lt;/span&gt;)
         (url .
              [&lt;span style="color: #008000;"&gt;"http://www.worldcat.org/oclc/224969280?referer=xid"&lt;/span&gt;]))])
 (stat . &lt;span style="color: #008000;"&gt;"ok"&lt;/span&gt;))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Ok, so we should check that stat is ok, then build the bibtex entry. Accessing the metadata below seems pretty hacky; but it works, and I don't understand the deep nesting of results, and there seems to be a vector in there.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;let*&lt;/span&gt; ((results  (&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt;
                    (url-retrieve-synchronously
                     &lt;span style="color: #008000;"&gt;"http://xisbn.worldcat.org/webservices/xid/isbn/9780309095211?method=getMetadata&amp;amp;format=json&amp;amp;fl=*"&lt;/span&gt;)
                  (json-read-from-string
                   (buffer-substring url-http-end-of-headers (point-max)))))
       (status (cdr (nth 1 results)))
       (metadata (aref (cdar results) 0)))

  (&lt;span style="color: #0000FF;"&gt;unless&lt;/span&gt; (string= &lt;span style="color: #008000;"&gt;"ok"&lt;/span&gt; status)
    (&lt;span style="color: #ff0000; font-weight: bold;"&gt;error&lt;/span&gt; &lt;span style="color: #008000;"&gt;"Status is %s"&lt;/span&gt; status))

  (concat &lt;span style="color: #008000;"&gt;"@book{,\n"&lt;/span&gt;
          (mapconcat (&lt;span style="color: #0000FF;"&gt;lambda&lt;/span&gt; (x)
                       (format &lt;span style="color: #008000;"&gt;"  %s={%s},"&lt;/span&gt; (car x) (cdr x)))
                     metadata &lt;span style="color: #008000;"&gt;"\n"&lt;/span&gt;)
          &lt;span style="color: #008000;"&gt;"}\n"&lt;/span&gt;))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
@book{,
  oclcnum={[224969280 70060944 756709329 804792476 817950524 833420290 836338922 704551455]},
  title={To recruit and advance women students and faculty in science and engineering},
  isbn={[9780309095211]},
  year={2006},
  ed={[Online-Ausg.]},
  author={Committee on the Guide to Recruiting and Advancing Women Scientists and Engineers in Academia, Committee on Women in Science and Engineering, Policy and Global Affairs, National Research Council of the National Academies.},
  city={Washington, D.C.},
  lang={eng},
  lccn={[2006016786]},
  form={[BC]},
  publisher={National Academies Press},
  url={[http://www.worldcat.org/oclc/224969280?referer=xid]},}
&lt;/pre&gt;

&lt;p&gt;
That looks good to me. Let us finally wrap it into a function that will take an ISBN and bibtex file interactively, create a bibtex entry, and insert it if there is not an entry with a key like that already. If we have selected region, lI should note this code uses some functionality from my org-ref package (and when I am done here, I am adding it to the doi-utils package inside org-ref). This is a fancy function, built from the experience I have from writing doi-utils.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #0000FF;"&gt;defun&lt;/span&gt; &lt;span style="color: #006699;"&gt;isbn-to-bibtex&lt;/span&gt; (isbn bibfile)
  &lt;span style="color: #036A07;"&gt;"Get bibtex entry for ISBN and insert it into BIBFILE unless an&lt;/span&gt;
&lt;span style="color: #036A07;"&gt;entry with the generated key already exists in the file."&lt;/span&gt;
  (interactive
   (list
    (read-input
     &lt;span style="color: #008000;"&gt;"ISBN: "&lt;/span&gt;
     &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;now set initial input&lt;/span&gt;
     (&lt;span style="color: #0000FF;"&gt;cond&lt;/span&gt;
      &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;If region is active and it starts with a number, we use it&lt;/span&gt;
      ((and  (region-active-p)
             (s-match &lt;span style="color: #008000;"&gt;"^[0-9]"&lt;/span&gt; (buffer-substring (region-beginning) (region-end))))
       (buffer-substring (region-beginning) (region-end)))
      &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;if first entry in kill ring starts with a number assume it is an isbn&lt;/span&gt;
      &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;and use it as the guess&lt;/span&gt;
      ((&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt; (s-match &lt;span style="color: #008000;"&gt;"^[0-9]"&lt;/span&gt; (car kill-ring))
           (car kill-ring)))
      &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;type or paste it in&lt;/span&gt;
      (t
       nil)))
    (ido-completing-read
     &lt;span style="color: #008000;"&gt;"Bibfile: "&lt;/span&gt;
     (append (f-entries &lt;span style="color: #008000;"&gt;"."&lt;/span&gt; (&lt;span style="color: #0000FF;"&gt;lambda&lt;/span&gt; (f) (f-ext? f &lt;span style="color: #008000;"&gt;"bib"&lt;/span&gt;)))
             org-ref-default-bibliography))))

  (&lt;span style="color: #0000FF;"&gt;let*&lt;/span&gt; ((results (&lt;span style="color: #0000FF;"&gt;with-current-buffer&lt;/span&gt;
                      (url-retrieve-synchronously
                       (format
                        &lt;span style="color: #008000;"&gt;"http://xisbn.worldcat.org/webservices/xid/isbn/%s?method=getMetadata&amp;amp;format=json&amp;amp;fl=*"&lt;/span&gt;
                        isbn))
                    (json-read-from-string
                     (buffer-substring url-http-end-of-headers (point-max)))))
         (status (cdr (nth 1 results)))
         (metadata (aref (cdar results) 0))
         (new-entry)
         (new-key))

    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;check if we got something&lt;/span&gt;
    (&lt;span style="color: #0000FF;"&gt;unless&lt;/span&gt; (string= &lt;span style="color: #008000;"&gt;"ok"&lt;/span&gt; status)
      (&lt;span style="color: #ff0000; font-weight: bold;"&gt;error&lt;/span&gt; &lt;span style="color: #008000;"&gt;"Status is %s"&lt;/span&gt; status))

    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;construct an alphabetically sorted bibtex entry. I assume ISBN numbers go&lt;/span&gt;
    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;with book entries.&lt;/span&gt;
    (setq new-entry
          (concat &lt;span style="color: #008000;"&gt;"\n@book{,\n"&lt;/span&gt;
                  (mapconcat
                   'identity
                   (loop for field in (-sort 'string-lessp (mapcar 'car metadata))
                         collect
                         (format &lt;span style="color: #008000;"&gt;"  %s={%s},"&lt;/span&gt; field (cdr (assoc field metadata))))
                   &lt;span style="color: #008000;"&gt;"\n"&lt;/span&gt;)
                  &lt;span style="color: #008000;"&gt;"\n}\n"&lt;/span&gt;))

    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;build entry in temp buffer to get the key so we can check for duplicates&lt;/span&gt;
    (setq new-entry (&lt;span style="color: #0000FF;"&gt;with-temp-buffer&lt;/span&gt;
                      (insert new-entry)
                      (org-ref-clean-bibtex-entry)
                      (setq new-key (bibtex-key-in-head))
                      (buffer-string)))
    (find-file bibfile)
    (goto-char (point-min))
    (&lt;span style="color: #0000FF;"&gt;when&lt;/span&gt; (search-forward new-key nil t)
      (beep)
      (setq new-key (read-input
                     (format  &lt;span style="color: #008000;"&gt;"%s already exists. Enter new key (C-g to cancel): "&lt;/span&gt; new-key)
                     new-key)))
    (goto-char (point-max))
    (insert new-entry)
    &lt;span style="color: #8D8D84;"&gt;;; &lt;/span&gt;&lt;span style="color: #8D8D84; font-style: italic;"&gt;set key. It is simplest to just replace it, even if it is the same.&lt;/span&gt;
    (bibtex-beginning-of-entry)
    (re-search-forward bibtex-entry-maybe-empty-head)
    (&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt; (match-beginning bibtex-key-in-head)
        (delete-region (match-beginning bibtex-key-in-head)
                       (match-end bibtex-key-in-head)))
    (insert new-key)
    (bibtex-fill-entry)
    (save-buffer)))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
isbn-to-bibtex
&lt;/pre&gt;

&lt;p&gt;
That is it, for the one ISBN I have tested it on, I get a nicely sorted bibtex entry in the file I select! Hopefully that means no more tedious bibtex entry entering for books! If you use org-ref, just update to the latest version and you should be able to use this function.
&lt;/p&gt;

&lt;p&gt;
Now, back to that proposal I am writing that needs a lot of citations to books that are not in my bibtex file yet, but will be soon ;)
&lt;/p&gt;
&lt;p&gt;Copyright (C) 2015 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;&lt;p&gt;&lt;a href="/org/2015/01/31/Turn-an-ISBN-to-a-bibtex-entry.org"&gt;org-mode source&lt;/a&gt;&lt;p&gt;&lt;p&gt;Org-mode version = 8.2.10&lt;/p&gt;]]></content:encoded>
    </item>
    <item>
      <title>Generating your bibliography in another file</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2014/10/30/Generating-your-bibliography-in-another-file</link>
      <pubDate>Thu, 30 Oct 2014 19:42:35 EDT</pubDate>
      <category><![CDATA[bibtex]]></category>
      <guid isPermaLink="false">oztog6TAGyeAKMDvrygUnGjA-7k=</guid>
      <description>Generating your bibliography in another file</description>
      <content:encoded><![CDATA[


&lt;div id="table-of-contents"&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;
&lt;div id="text-table-of-contents"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#sec-1"&gt;1. Getting the references in another file&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;
It has been proposal season. This particular round of proposals had a requirement to print the references in a separate file from the proposal. Usually I just build a pdf from org-mode, and then manually separate the references. That is not very fun if you have to do it several times. Here we examine a way to avoid this issue by using a new nobibliography link from org-ref with the bibentry LaTeX package.
&lt;/p&gt;

&lt;p&gt;
We wrote this paper &lt;a href="#mehta-2014-ident-poten"&gt;mehta-2014-ident-poten&lt;/a&gt; and this one &lt;a href="#xu-2014-relat"&gt;xu-2014-relat&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;

&lt;h1&gt;Bibliography&lt;/h1&gt;
&lt;ul&gt;&lt;li&gt;&lt;a id="mehta-2014-ident-poten"&gt;[mehta-2014-ident-poten] Prateek Mehta, Paul Salvador, John \&amp; Kitchin, Identifying Potential \ce{BO2} Oxide Polymorphs for  Epitaxial Growth Candidates, &lt;i&gt;ACS Appl. Mater. Interfaces&lt;/i&gt;, &lt;b&gt;6(5)&lt;/b&gt;, 3630-3639 (2014). &lt;a href="https://doi.org/10.1021/am4059149"&gt;link&lt;/a&gt;. &lt;a href="https://doi.org/10.1021/am4059149"&gt;doi&lt;/a&gt;.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a id="xu-2014-relat"&gt;[xu-2014-relat] Zhongnan Xu \&amp; John Kitchin, Relating the Electronic Structure and Reactivity of  the 3d Transition Metal Monoxide Surfaces, &lt;i&gt;Catalysis Communications&lt;/i&gt;, &lt;b&gt;52()&lt;/b&gt;, 60-64 (2014). &lt;a href="https://doi.org/10.1016/j.catcom.2013.10.028"&gt;link&lt;/a&gt;. &lt;a href="https://doi.org/10.1016/j.catcom.2013.10.028"&gt;doi&lt;/a&gt;.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;

&lt;p&gt;
Here is the resulting pdf, with no references: &lt;a href="separate-bib.pdf"&gt;separate-bib.pdf&lt;/a&gt;.
&lt;/p&gt;


&lt;div id="outline-container-sec-1" class="outline-2"&gt;
&lt;h2 id="sec-1"&gt;&lt;span class="section-number-2"&gt;1&lt;/span&gt; Getting the references in another file&lt;/h2&gt;
&lt;div class="outline-text-2" id="text-1"&gt;
&lt;p&gt;
Now, we need to get the reference file. We create a new file, in org-mode, mostly for the convenience of exporting that to a pdf. Here is the code that does that.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #8b0000;"&gt;let*&lt;/span&gt; ((base (file-name-sans-extension
              (file-name-nondirectory (buffer-file-name))))
       (bbl (concat base &lt;span style="color: #228b22;"&gt;".bbl"&lt;/span&gt;))
       (orgfile (concat base &lt;span style="color: #228b22;"&gt;"-references.org"&lt;/span&gt;))
       (pdffile (concat base &lt;span style="color: #228b22;"&gt;"-references.pdf"&lt;/span&gt;)))
  (&lt;span style="color: #8b0000;"&gt;with-temp-file&lt;/span&gt; orgfile
    (insert
     (format &lt;span style="color: #228b22;"&gt;"#+LATEX_CLASS: cmu-article&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;#+OPTIONS: toc:nil&lt;/span&gt;

&lt;span style="color: #228b22;"&gt;#+BEGIN_LaTeX&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;\\input{%s}&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;#+END_LaTeX&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;"&lt;/span&gt; bbl)))

  (find-file orgfile)
  (org-latex-export-to-pdf)
  (org-open-file pdffile))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
And, here is the reference file: &lt;a href="/media/2014-10-30-Generating-your-bibliography-in-another-file/separate-bib.pdf"&gt;separate-bib.pdf&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
I think this would be integrated into a noexport build section of a document that would generate the pdf and references.
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Copyright (C) 2014 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;&lt;p&gt;&lt;a href="/org/2014/10/30/Generating-your-bibliography-in-another-file.org"&gt;org-mode source&lt;/a&gt;&lt;p&gt;&lt;p&gt;Org-mode version = 8.2.7c&lt;/p&gt;
]]></content:encoded>
    </item>
    <item>
      <title>Navigating your bibtex file</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2014/10/13/Navigating-your-bibtex-file</link>
      <pubDate>Mon, 13 Oct 2014 10:22:27 EDT</pubDate>
      <category><![CDATA[bibtex]]></category>
      <guid isPermaLink="false">KaBIqwpzObifsEczKwvSTdV_ZrU=</guid>
      <description>Navigating your bibtex file</description>
      <content:encoded><![CDATA[



&lt;p&gt;
You may be able to tell I am spending some time cleaning up bibtex files these days. One of the things I need to do is navigate around a bibtex file easily. There are some built-in navigation keys within an entry.
&lt;/p&gt;

&lt;table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides"&gt;


&lt;colgroup&gt;
&lt;col  class="left" /&gt;

&lt;col  class="left" /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th scope="col" class="left"&gt;navigation&lt;/th&gt;
&lt;th scope="col" class="left"&gt;key strokes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class="left"&gt;next field&lt;/td&gt;
&lt;td class="left"&gt;C-j&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td class="left"&gt;end of field&lt;/td&gt;
&lt;td class="left"&gt;TAB&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td class="left"&gt;beginning of entry&lt;/td&gt;
&lt;td class="left"&gt;C-M-a&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td class="left"&gt;end of entry&lt;/td&gt;
&lt;td class="left"&gt;C-M-e&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;
I am not aware of an easy way to navigate to the next or previous entry though. I would like something simple to do that. There is a regexp defined in bibtex "bibtex-entry-head", to search for the next or previous entry.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;bibtex-entry-head
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
^[      ]*\(@[  ]*\(?:\(?:Article\|Book\(?:let\)?\|In\(?:Book\|Collection\|Proceedings\)\|M\(?:a\(?:nual\|stersThesis\)\|isc\)\|P\(?:\(?:hdThesi\|roceeding\)s\)\|TechReport\|Unpublished\)\)\)[        ]*[({][         
]*\([][[:alnum:].:;?!`'/*@+|()&amp;lt;&amp;gt;&amp;amp;_^$-]+\)
&lt;/pre&gt;

&lt;p&gt;
Here are two functions that do it. This was a little more subtle than I anticipated.  The subtlety comes about if you are at the beginning of the entry, we need to move the cursor by a character, and then search forward because of the way re-search-forward works. I also wrote in an option for a prefix argument, so you can go forward or backward several entries.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;bibtex-next-entry&lt;/span&gt; (&lt;span style="color: #4682b4;"&gt;&amp;amp;optional&lt;/span&gt; n)
  &lt;span style="color: #228b22;"&gt;"Jump to the beginning of the next bibtex entry. N is a prefix&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;argument. If it is numeric, jump that many entries&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;forward. Negative numbers do nothing."&lt;/span&gt;
  (interactive &lt;span style="color: #228b22;"&gt;"P"&lt;/span&gt;)
  ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;Note if we start at the beginning of an entry, nothing&lt;/span&gt;
  ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;happens. We need to move forward a char, and call again.&lt;/span&gt;
  (&lt;span style="color: #8b0000;"&gt;when&lt;/span&gt; (= (point) (&lt;span style="color: #8b0000;"&gt;save-excursion&lt;/span&gt;
                     (bibtex-beginning-of-entry)))
    (forward-char)
    (bibtex-next-entry))

  ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;search forward for an entry &lt;/span&gt;
  (&lt;span style="color: #8b0000;"&gt;when&lt;/span&gt; 
      (re-search-forward bibtex-entry-head nil t (and (numberp n) n))
    ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;go to beginning of the entry&lt;/span&gt;
    (bibtex-beginning-of-entry)))


(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;bibtex-previous-entry&lt;/span&gt; (&lt;span style="color: #4682b4;"&gt;&amp;amp;optional&lt;/span&gt; n)
  &lt;span style="color: #228b22;"&gt;"Jump to beginning of the previous bibtex entry. N is a prefix&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;argument. If it is numeric, jump that many entries back."&lt;/span&gt;
  (interactive &lt;span style="color: #228b22;"&gt;"P"&lt;/span&gt;)
  (bibtex-beginning-of-entry)
 (&lt;span style="color: #8b0000;"&gt;when&lt;/span&gt; 
     (re-search-backward bibtex-entry-head nil t (and (numberp n) n))
   (bibtex-beginning-of-entry)))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
bibtex-previous-entry
&lt;/pre&gt;

&lt;p&gt;
That is pretty simple. Let us go ahead and bind these to M-n, and M-p, but only in bibtex-mode. Thanks to &lt;a href="http://ergoemacs.org/emacs/emacs_set_keys_for_major_mode.html"&gt;Xah Lee&lt;/a&gt; for this idea. 
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;jmax-bibtex-mode-keys&lt;/span&gt; ()
  &lt;span style="color: #228b22;"&gt;"Modify keymaps used by `&lt;/span&gt;&lt;span style="color: #cd0000;"&gt;bibtex-mode&lt;/span&gt;&lt;span style="color: #228b22;"&gt;'."&lt;/span&gt;
  (local-set-key (kbd &lt;span style="color: #228b22;"&gt;"M-n"&lt;/span&gt;) 'bibtex-next-entry)
  (local-set-key (kbd &lt;span style="color: #228b22;"&gt;"M-p"&lt;/span&gt;) 'bibtex-previous-entry))

;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;add to bibtex-mode-hook&lt;/span&gt;
(add-hook 'bibtex-mode-hook 'jmax-bibtex-mode-keys)
&lt;/pre&gt;
&lt;/div&gt;

&lt;table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides"&gt;


&lt;colgroup&gt;
&lt;col  class="left" /&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class="left"&gt;jmax-bibtex-mode-keys&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;
Now, C-n moves forward an entry, C-u 2 C-n moves you two entries, etc&amp;#x2026; and C-p moves you back an entry, while C-u 2 C-p moves you back two entries. 
&lt;/p&gt;

&lt;p&gt;
Finally, I sometimes want to jump to a field in an entry. Basically, I want a completion enabled function that lists the fields in the current entry, and then jumps to the selected field. Yes, you could simply do an incremental search forward or backward that is about as simple. But, then I would not get to remind myself how to do a completion command ;)
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;jmax-bibtex-get-fields&lt;/span&gt; ()
  &lt;span style="color: #228b22;"&gt;"Get a list of fields in a bibtex entry."&lt;/span&gt;
  (bibtex-beginning-of-entry)
  (remove &lt;span style="color: #228b22;"&gt;"=type="&lt;/span&gt;
          (remove &lt;span style="color: #228b22;"&gt;"=key="&lt;/span&gt;
                  (mapcar 'car (bibtex-parse-entry)))))

(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;jmax-bibtex-jump-to-field&lt;/span&gt; (field)
  &lt;span style="color: #228b22;"&gt;"Jump to FIELD in the current bibtex entry"&lt;/span&gt;
  (interactive
   (list
    (ido-completing-read &lt;span style="color: #228b22;"&gt;"Field: "&lt;/span&gt; (jmax-bibtex-get-fields))))
  (&lt;span style="color: #8b0000;"&gt;save-restriction&lt;/span&gt;
    (bibtex-narrow-to-entry)
    (bibtex-beginning-of-entry)
    (&lt;span style="color: #8b0000;"&gt;when&lt;/span&gt;
        ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;fields start with spaces, a field name, possibly more&lt;/span&gt;
        ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;spaces, then =&lt;/span&gt;
        (re-search-forward (format &lt;span style="color: #228b22;"&gt;"^\\s-*%s\\s-*="&lt;/span&gt; field) nil t))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
jmax-bibtex-jump-to-field
&lt;/pre&gt;

&lt;p&gt;
These functions live in &lt;a href="https://github.com/jkitchin/jmax/blob/master/jmax-bibtex.el"&gt;https://github.com/jkitchin/jmax/blob/master/jmax-bibtex.el&lt;/a&gt; , which is the version we use on a regular basis.
&lt;/p&gt;
&lt;p&gt;Copyright (C) 2014 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;&lt;p&gt;&lt;a href="/org/2014/10/13/Navigating-your-bibtex-file.org"&gt;org-mode source&lt;/a&gt;&lt;p&gt;&lt;p&gt;Org-mode version = 8.2.7c&lt;/p&gt;]]></content:encoded>
    </item>
    <item>
      <title>Title casing bibtex entry journal titles</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2014/10/12/Title-casing-bibtex-entry-journal-titles</link>
      <pubDate>Sun, 12 Oct 2014 09:23:17 EDT</pubDate>
      <category><![CDATA[bibtex]]></category>
      <guid isPermaLink="false">m94rowIK5jHo6S-Aoj10V0fKTr8=</guid>
      <description>Title casing bibtex entry journal titles</description>
      <content:encoded><![CDATA[



&lt;p&gt;
I mostly love bibtex. You keep bibliographic entries in a central file, and you can cite them in your writing. Bibtex takes care of &lt;i&gt;most&lt;/i&gt; of the formatting for you, but not always all of it. Lately, we have been writing some manuscripts for submission to ACS journals. They want the titles of journal articles included in the bibliography, preferrably in title-case, or in sentence case, but all the same format either way. Unfortunately, the achemso.bst bibtex format does not make this happen. You have to title-case or sentence case the titles themselves in your bibtex file. Well, at least we can get Emacs to do the heavy lifting on that for us.
&lt;/p&gt;

&lt;p&gt;
First, the manual approach. Open your bibtex file, navigate to a title field, put your cursor on the first letter of the title, and press M-c until you get to the end of the title. That runs (capitalize-word). For a few titles, you might just do this. It does not take long.
&lt;/p&gt;

&lt;p&gt;
For a lot of entries though, you might prefer some code to do it. Here we consider how to convert all article titles to Title case. The current code can be found at &lt;a href="https://github.com/jkitchin/jmax/blob/master/jmax-bibtex.el"&gt;https://github.com/jkitchin/jmax/blob/master/jmax-bibtex.el&lt;/a&gt; .
&lt;/p&gt;

&lt;p&gt;
First, we need to decide on some rules. We will capitalize every word in a title except for words like a, an, the, &amp;#x2026; unless they start the title. We do not want to change words with $, {} in them, or \, because these are either protected or LaTeX commands and we probably do not want to change them. The gist of our idea is to get the title, split it into words, capitalize each word that needs to be,  join the words together, and then set the entry title to the new capitalized title.
&lt;/p&gt;

&lt;p&gt;
We use functions from &lt;a href="https://github.com/magnars/s.el"&gt;s.el&lt;/a&gt; , and &lt;a href="https://github.com/jkitchin/jmax/blob/master/org/doi-utils.org"&gt;doi-utils.org&lt;/a&gt; here.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #8b0000;"&gt;defvar&lt;/span&gt; &lt;span style="color: #8b008b;"&gt;jmax-lower-case-words&lt;/span&gt;
  '(&lt;span style="color: #228b22;"&gt;"a"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"an"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"on"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"and"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"for"&lt;/span&gt;
    &lt;span style="color: #228b22;"&gt;"the"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"of"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"in"&lt;/span&gt;)
  &lt;span style="color: #228b22;"&gt;"List of words to keep lowercase"&lt;/span&gt;)

(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;jmax-title-case-article&lt;/span&gt; (&lt;span style="color: #4682b4;"&gt;&amp;amp;optional&lt;/span&gt; key start end)
  &lt;span style="color: #228b22;"&gt;"Convert a bibtex entry article title to title-case. The&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;arguments are optional, and are only there so you can use this&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;function with `&lt;/span&gt;&lt;span style="color: #cd0000;"&gt;bibtex-map-entries&lt;/span&gt;&lt;span style="color: #228b22;"&gt;' to change all the title&lt;/span&gt;
&lt;span style="color: #228b22;"&gt;entries in articles."&lt;/span&gt;
  (interactive)
  (bibtex-beginning-of-entry)

  (&lt;span style="color: #8b0000;"&gt;let*&lt;/span&gt; ((title (bibtex-autokey-get-field &lt;span style="color: #228b22;"&gt;"title"&lt;/span&gt;))
         (words (split-string title))
         (lower-case-words '(&lt;span style="color: #228b22;"&gt;"a"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"an"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"on"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"and"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"for"&lt;/span&gt;
                             &lt;span style="color: #228b22;"&gt;"the"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"of"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"in"&lt;/span&gt;)))
    (&lt;span style="color: #8b0000;"&gt;when&lt;/span&gt;
        (string= &lt;span style="color: #228b22;"&gt;"article"&lt;/span&gt; (downcase (cdr (assoc &lt;span style="color: #228b22;"&gt;"=type="&lt;/span&gt; (bibtex-parse-entry)))))
      (setq words (mapcar
                   (&lt;span style="color: #8b0000;"&gt;lambda&lt;/span&gt; (word)
                     (&lt;span style="color: #8b0000;"&gt;if&lt;/span&gt; (or
                          ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;match words containing {} or \ which are probably&lt;/span&gt;
                          ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;LaTeX or protected words&lt;/span&gt;
                          (string-match &lt;span style="color: #228b22;"&gt;"\\$&lt;/span&gt;&lt;span style="color: #228b22;"&gt;\\&lt;/span&gt;&lt;span style="color: #228b22;"&gt;|&lt;/span&gt;&lt;span style="color: #228b22;"&gt;{&lt;/span&gt;&lt;span style="color: #228b22;"&gt;\\&lt;/span&gt;&lt;span style="color: #228b22;"&gt;|&lt;/span&gt;&lt;span style="color: #228b22;"&gt;}&lt;/span&gt;&lt;span style="color: #228b22;"&gt;\\&lt;/span&gt;&lt;span style="color: #228b22;"&gt;|&lt;/span&gt;&lt;span style="color: #228b22;"&gt;\\\\"&lt;/span&gt; word)
                          ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;these words should not be capitalized, unless they&lt;/span&gt;
                          ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;are the first word&lt;/span&gt;
                          (-contains? lower-case-words (s-downcase word)))
                         word
                       (s-capitalize word)))
                   words))

      ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;Check if first word should be capitalized&lt;/span&gt;
      (&lt;span style="color: #8b0000;"&gt;when&lt;/span&gt; (-contains? jmax-lower-case-words (car words))
        (setf (car words) (s-capitalize (car words))))

      ;; &lt;span style="color: #ff0000; font-weight: bold;"&gt;this is defined in doi-utils&lt;/span&gt;
      (bibtex-set-field
       &lt;span style="color: #228b22;"&gt;"title"&lt;/span&gt;
       (mapconcat 'identity words &lt;span style="color: #228b22;"&gt;" "&lt;/span&gt;))
      (bibtex-fill-entry))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
jmax-title-case-article
&lt;/pre&gt;


&lt;p&gt;
Now, a single command converts this:
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-bibtex"&gt;&lt;span style="color: #8b2323;"&gt;@article&lt;/span&gt;{&lt;span style="color: #cd0000;"&gt;campbell-2013-enthal-entrop&lt;/span&gt;,
  &lt;span style="color: #8b008b;"&gt;author&lt;/span&gt; =       {Charles T. Campbell and Jason R. V. Sellers},
  &lt;span style="color: #8b008b;"&gt;title&lt;/span&gt; =        {Enthalpies and entropies of adsorption on
                  well-defined oxide surfaces: experimental
                  measurements},
  &lt;span style="color: #8b008b;"&gt;journal&lt;/span&gt; =      CR,
  &lt;span style="color: #8b008b;"&gt;volume&lt;/span&gt; =       113,
  &lt;span style="color: #8b008b;"&gt;number&lt;/span&gt; =       6,
  &lt;span style="color: #8b008b;"&gt;pages&lt;/span&gt; =        {4106-4135},
  &lt;span style="color: #8b008b;"&gt;year&lt;/span&gt; =         2013,
  &lt;span style="color: #8b008b;"&gt;doi&lt;/span&gt; =          {&lt;span style="color: #3a5fcd; text-decoration: underline;"&gt;10.1021/cr300329s&lt;/span&gt;},
  &lt;span style="color: #8b008b;"&gt;url&lt;/span&gt; =          {&lt;span style="color: #3a5fcd; text-decoration: underline;"&gt;https://doi.org/10.1021/cr300329s&lt;/span&gt;},
  &lt;span style="color: #8b008b;"&gt;month&lt;/span&gt; =        6,
}
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
to this:
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-bibtex"&gt;&lt;span style="color: #8b2323;"&gt;@article&lt;/span&gt;{&lt;span style="color: #cd0000;"&gt;campbell-2013-enthal-entrop&lt;/span&gt;,
  &lt;span style="color: #8b008b;"&gt;author&lt;/span&gt; =       {Charles T. Campbell and Jason R. V. Sellers},
  &lt;span style="color: #8b008b;"&gt;title&lt;/span&gt; =        {Enthalpies and Entropies of Adsorption on
                  Well-defined Oxide Surfaces: Experimental
                  Measurements},
  &lt;span style="color: #8b008b;"&gt;journal&lt;/span&gt; =      CR,
  &lt;span style="color: #8b008b;"&gt;volume&lt;/span&gt; =       113,
  &lt;span style="color: #8b008b;"&gt;number&lt;/span&gt; =       6,
  &lt;span style="color: #8b008b;"&gt;pages&lt;/span&gt; =        {4106-4135},
  &lt;span style="color: #8b008b;"&gt;year&lt;/span&gt; =         2013,
  &lt;span style="color: #8b008b;"&gt;doi&lt;/span&gt; =          {&lt;span style="color: #3a5fcd; text-decoration: underline;"&gt;10.1021/cr300329s&lt;/span&gt;},
  &lt;span style="color: #8b008b;"&gt;url&lt;/span&gt; =          {&lt;span style="color: #3a5fcd; text-decoration: underline;"&gt;https://doi.org/10.1021/cr300329s&lt;/span&gt;},
  &lt;span style="color: #8b008b;"&gt;month&lt;/span&gt; =        6,
}
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
We wrote the title case function so we can use it with bibtex-map-entries. That means we can fix every entry in a file by putting a comment at the top like this:
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-bibtex"&gt;&lt;span style="color: #ff0000; font-weight: bold;"&gt;% (bibtex-map-entries 'jmax-title-case-article)  &amp;lt;- put cursor here. C-x C-e&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
The function is not perfect, and does not include every word that should not be capitalized. You will still want to review your entries, but hopefully this saves some typing in the end.&lt;/p&gt;
&lt;p&gt;Copyright (C) 2014 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;&lt;p&gt;&lt;a href="/org/2014/10/12/Title-casing-bibtex-entry-journal-titles.org"&gt;org-mode source&lt;/a&gt;&lt;p&gt;&lt;p&gt;Org-mode version = 8.2.7c&lt;/p&gt;
]]></content:encoded>
    </item>
    <item>
      <title>Abbreviated journal names in bibtex</title>
      <link>https://kitchingroup.cheme.cmu.edu/blog/2014/10/11/Abbreviated-journal-names-in-bibtex</link>
      <pubDate>Sat, 11 Oct 2014 17:31:59 EDT</pubDate>
      <category><![CDATA[bibtex]]></category>
      <guid isPermaLink="false">hIlJ3pTaapHY6Y7BGGC1XcWOeo8=</guid>
      <description>Abbreviated journal names in bibtex</description>
      <content:encoded><![CDATA[



&lt;p&gt;
Some journals require abbreviated journal names in the bibliography, and some require full names. Unfortunately, it is not possible to have both in your bibtex file. Or is it&amp;#x2026;
&lt;/p&gt;

&lt;p&gt;
It is possible to define a &lt;a href="http://www.bibtex.org/Format/"&gt;@string&lt;/a&gt; that is replaced in your bibtex file. If we have the definition of the @string in a separate file, we can specify its definition there, e.g. as an abbreviation, or as the full name. To make this useful, we need a simple way to add new journals, and to generate the definitions.
&lt;/p&gt;

&lt;p&gt;
First, you can find accepted journal name abbreviations here: &lt;a href="http://cassi.cas.org/search.jsp"&gt;http://cassi.cas.org/search.jsp&lt;/a&gt; .
&lt;/p&gt;

&lt;p&gt;
We are going to define a variable to hold the string definition, journal full name and an abbreviation. You can find our production version of what follows here: &lt;a href="https://github.com/jkitchin/jmax/blob/master/jmax-bibtex.el"&gt;https://github.com/jkitchin/jmax/blob/master/jmax-bibtex.el&lt;/a&gt;
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #8b0000;"&gt;defvar&lt;/span&gt; &lt;span style="color: #8b008b;"&gt;jmax-bibtex-abbreviations&lt;/span&gt;
  '((&lt;span style="color: #228b22;"&gt;"ACAT"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"ACS Catalysis"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"ACS Catal."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"AM"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Acta Materialia"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Acta Mater."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"AMM"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Acta Metallurgica et Materialia"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Acta Metall. Mater."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"AMiner"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"American Mineralogist"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Am. Mineral."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"AngC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Angewandte Chemie-International Edition"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Angew. Chem. Int. Edit."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"APLM"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"APL Materials"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"APL Mat."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"ACBE"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Applied Catalysis B: Environmental"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Appl. Catal. B-Environ."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"APL"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Applied Physics Letters"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Appl. Phys. Lett."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"ASS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Applied Surface Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Appl. Surf. Sci."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CL"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Catalysis Letters"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Catal. Lett."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CT"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Catalysis Today"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Catal. Today"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CPL"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chemical Physics Letters"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chem. Phys. Lett"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CR"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chemical Reviews"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chem. Rev."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CSR"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chemical Society Reviews"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chem. Soc. Rev."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CSR"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chemical Society Reviews"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chem. Soc. Rev."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CM"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chemistry of Materials"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Chem. Mater."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CSA"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Colloids and Surfaces, A: Physicochemical and Engineering Aspects"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Colloids Surf., A"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CPMS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Computational Materials Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Comp. Mater. Sci."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CPC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Computer Physics Communications"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Comput. Phys. Commun."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CGD"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Crystal Growth \\&amp;amp; Design"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Cryst. Growth Des."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"CEC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"CrystEngComm"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"CrystEngComm"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"ECST"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"ECS Transactions"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"ECS Trans."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"EES"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Energy \\&amp;amp; Environmental Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Energy Environ. Sci."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"HPR"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"High Pressure Research"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"High Pressure Res."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"IC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Inorganic Chemistry"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Inorg. Chem."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"IECR"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Industrial \\&amp;amp; Engineering Chemistry Research"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Ind. Eng. Chem. Res."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JJAP"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Japanese Journal of Applied Physics"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Jpn. J. Appl. Phys."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JMatR"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of  Materials Research"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Mater. Res."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JALC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Alloys and Compounds"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Alloy Compd."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JAC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Applied Crystallography"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Appl. Crystallogr."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JAP"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Applied Physics"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Appl. Phys."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Catalysis"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Catal."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JCP"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Chemical Physics"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Chem. Phys."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JCG"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Crystal Growth"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Crys. Growth"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JMC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Materials Chemistry"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Mater. Chem."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JMC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Materials Chemistry"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Mater. Chem."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JMSL"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Materials Science Letters"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Mater. Sci. Lett."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JMS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Membrane Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Memb. Sci."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JPE"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Phase Equilibria"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Phase Equilib."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JPCS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Physics and Chemistry of Solids"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Phys. Chem. Solids"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JPCM"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Physics: Condensed Matter"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Phys.: Condens. Matter"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JSSC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Solid State Chemistry"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Solid State Chem."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JACerS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of the American Ceramic Society"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Am. Ceram. Soc."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JACS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of the American Chemical Society"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Am. Chem. Soc."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JES"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of The Electrochemical Society"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Electrochem. Soc."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JES"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of The Electrochemical Society"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Electrochem. Soc."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JMS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Membrane Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Memb. Sci."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JVST"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Journal of Vacuum Science \\&amp;amp; Technology A"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Vac. Sci. Technol. A"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"ML"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Materials Letters"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Mater. Lett."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"MSE-BS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Materials Science and Engineering B"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Mat. Sci. Eng. B-Solid"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"MOLSIM"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Molecular Simulation"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Mol. Sim."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"Nature"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Nature"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Nature"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"NM"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Nature Materials"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Nat. Mater."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PML"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Philosophical Magazine Letters"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Phil. Mag. Lett."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PMA"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Philosophical Magazine A"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Phil. Mag. A"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PA"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physica A: Statistical Mechanics and its Applications"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physica A"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PB"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physica B-Condensed Matter"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physica B"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PCCP"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physical Chemistry Chemical Physics"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Phys. Chem. Chem. Phys."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PSSB"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"physica status solidi (b)"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Phys. Status Solidi B"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PRA"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physical Review A"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Phys. Rev. A"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PRB"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physical Review B"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Phys. Rev. B"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PRL"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physical Review Letters"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Phys. Rev. Lett."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PCM"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Physics and Chemistry of Minerals"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Phys. Chem. Miner."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"PSurfSci"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Progress in Surface Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Prog. Surf. Sci."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Science"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"SABC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Sensors and Actuators B: Chemical"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Sensor. Actuat. B-Chem."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"SS"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Surface Science"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Surf. Sci."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"EPJB"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"The European Physical Journal B"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Eur. Phys. J. B"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JPC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"The Journal of Physical Chemistry"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Phys. Chem."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JPCB"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"The Journal of Physical Chemistry  B"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Phys. Chem. B"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JPCC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"The Journal of Physical Chemistry C"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Phys. Chem. C"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"JCP"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"The Journal of Chemical Physics"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"J. Chem. Phys."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"TSF"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Thin Solid Films"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Thin Solid Films"&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"TC"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Topics in Catalysis"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Top. Catal."&lt;/span&gt;)
    (&lt;span style="color: #228b22;"&gt;"WR"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Water Research"&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"Water Res."&lt;/span&gt;))
  &lt;span style="color: #228b22;"&gt;"List of (string journal-full-name journal-abbreviation)"&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
bibtex-abbreviations
&lt;/pre&gt;

&lt;p&gt;
This data structure will serve a few purposes.
&lt;/p&gt;

&lt;ol class="org-ol"&gt;
&lt;li&gt;We will generate the bib files that define the @string definitions
&lt;/li&gt;
&lt;li&gt;We will use it to modify bibtex files to use those strings.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
First, here are some simple functions to generate the @string definitions.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;jmax-bibtex-generate-longtitles&lt;/span&gt; ()
  (interactive)
  (&lt;span style="color: #8b0000;"&gt;with-temp-file&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"longtitles.bib"&lt;/span&gt;
    (&lt;span style="color: #8b0000;"&gt;dolist&lt;/span&gt; (row bibtex-abbreviations)
      (insert (format &lt;span style="color: #228b22;"&gt;"@string{%s=\"%s\"}\n"&lt;/span&gt;
                      (nth 0 row)
                      (nth 1 row))))))

(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;jmax-bibtex-generate-shorttitles&lt;/span&gt; ()
  (interactive)
  (&lt;span style="color: #8b0000;"&gt;with-temp-file&lt;/span&gt; &lt;span style="color: #228b22;"&gt;"shorttitles.bib"&lt;/span&gt;
    (&lt;span style="color: #8b0000;"&gt;dolist&lt;/span&gt; (row bibtex-abbreviations)
      (insert (format &lt;span style="color: #228b22;"&gt;"@string{%s=\"%s\"}\n"&lt;/span&gt;
                      (nth 0 row)
                      (nth 2 row))))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
jmax-bibtex-generate-shorttitles
&lt;/pre&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(jmax-bibtex-generate-longtitles)
(jmax-bibtex-generate-shorttitles)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Here are the results of running that code: &lt;a href="/media/2014-10-11-Abbreviated-journal-names-in-bibtex/shorttitles.bib"&gt;shorttitles.bib&lt;/a&gt; and &lt;a href="/media/2014-10-11-Abbreviated-journal-names-in-bibtex/longtitles.bib"&gt;longtitles.bib&lt;/a&gt; . This is the first step. We have the @strings defined. Now, we need to convert the names in a bibtex entry to use our string. We want to replace full names and abbreviated names with the @string.
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-emacs-lisp"&gt;(&lt;span style="color: #8b0000;"&gt;defun&lt;/span&gt; &lt;span style="color: #8b2323;"&gt;jmax-stringify-journal-name&lt;/span&gt; (&lt;span style="color: #4682b4;"&gt;&amp;amp;optional&lt;/span&gt; key start end)
  &lt;span style="color: #228b22;"&gt;"replace journal name with a string. The strings are defined in `&lt;/span&gt;&lt;span style="color: #cd0000;"&gt;bibtex-abbreviations&lt;/span&gt;&lt;span style="color: #228b22;"&gt;'."&lt;/span&gt;
  (interactive)
  (bibtex-beginning-of-entry)
  (&lt;span style="color: #8b0000;"&gt;when&lt;/span&gt;
      (string= &lt;span style="color: #228b22;"&gt;"article"&lt;/span&gt;
               (downcase
                (cdr (assoc &lt;span style="color: #228b22;"&gt;"=type="&lt;/span&gt; (bibtex-parse-entry)))))
    (&lt;span style="color: #8b0000;"&gt;let*&lt;/span&gt; ((full-names (mapcar
                        (&lt;span style="color: #8b0000;"&gt;lambda&lt;/span&gt; (row)
                          (cons  (nth 1 row) (nth 0 row)))
                        bibtex-abbreviations))
           (abbrev-names (mapcar
                          (&lt;span style="color: #8b0000;"&gt;lambda&lt;/span&gt; (row)
                            (cons  (nth 2 row) (nth 0 row)))
                          bibtex-abbreviations))
           (journal (s-trim (bibtex-autokey-get-field &lt;span style="color: #228b22;"&gt;"journal"&lt;/span&gt;)))
           (bstring (or
                     (cdr (assoc journal full-names))
                     (cdr (assoc journal abbrev-names)))))
      (&lt;span style="color: #8b0000;"&gt;when&lt;/span&gt; bstring
        (bibtex-set-field &lt;span style="color: #228b22;"&gt;"journal"&lt;/span&gt; bstring t)
        (bibtex-fill-entry)))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;pre class="example"&gt;
jmax-stringify-journal-name
&lt;/pre&gt;

&lt;p&gt;
Now, with a single command, we can convert this:
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-bibtex"&gt;&lt;span style="color: #8b2323;"&gt;@article&lt;/span&gt;{&lt;span style="color: #cd0000;"&gt;lizzit-2001-surfac-ru&lt;/span&gt;,
  &lt;span style="color: #8b008b;"&gt;author&lt;/span&gt; =       {S. Lizzit and A. Baraldi and A. Groso and K. Reuter
                  and M. Ganduglia-Pirovano and C. Stampfl and
                  M. Scheffler and M. Stichler and C. Keller and
                  W. Wurth and D. Menzel},
  &lt;span style="color: #8b008b;"&gt;title&lt;/span&gt; =        {Surface Core-level Shifts of Clean and
                  Oxygen-covered {R}u(0001)},
  &lt;span style="color: #8b008b;"&gt;journal&lt;/span&gt; =      {Physical Review B,
  &lt;span style="color: #8b008b;"&gt;volume&lt;/span&gt; =       63,
  &lt;span style="color: #8b008b;"&gt;number&lt;/span&gt; =       20,
  &lt;span style="color: #8b008b;"&gt;pages&lt;/span&gt; =        {nil},
  &lt;span style="color: #8b008b;"&gt;year&lt;/span&gt; =         2001,
  &lt;span style="color: #8b008b;"&gt;doi&lt;/span&gt; =          {&lt;span style="color: #3a5fcd; text-decoration: underline;"&gt;10.1103/physrevb.63.205419&lt;/span&gt;},
  &lt;span style="color: #8b008b;"&gt;url&lt;/span&gt; =          {&lt;span style="color: #3a5fcd; text-decoration: underline;"&gt;https://doi.org/10.1103/PhysRevB.63.205419&lt;/span&gt;},
  &lt;span style="color: #8b008b;"&gt;month&lt;/span&gt; =        5,
}
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
into this:
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-bibtex"&gt;&lt;span style="color: #8b2323;"&gt;@article&lt;/span&gt;{&lt;span style="color: #cd0000;"&gt;lizzit-2001-surfac-ru&lt;/span&gt;,
  &lt;span style="color: #8b008b;"&gt;author&lt;/span&gt; =       {S. Lizzit and A. Baraldi and A. Groso and K. Reuter
                  and M. Ganduglia-Pirovano and C. Stampfl and
                  M. Scheffler and M. Stichler and C. Keller and
                  W. Wurth and D. Menzel},
  &lt;span style="color: #8b008b;"&gt;title&lt;/span&gt; =        {Surface Core-level Shifts of Clean and
                  Oxygen-covered {R}u(0001)},
  &lt;span style="color: #8b008b;"&gt;journal&lt;/span&gt; =      PRB,
  &lt;span style="color: #8b008b;"&gt;volume&lt;/span&gt; =       63,
  &lt;span style="color: #8b008b;"&gt;number&lt;/span&gt; =       20,
  &lt;span style="color: #8b008b;"&gt;pages&lt;/span&gt; =        {nil},
  &lt;span style="color: #8b008b;"&gt;year&lt;/span&gt; =         2001,
  &lt;span style="color: #8b008b;"&gt;doi&lt;/span&gt; =          {&lt;span style="color: #3a5fcd; text-decoration: underline;"&gt;10.1103/physrevb.63.205419&lt;/span&gt;},
  &lt;span style="color: #8b008b;"&gt;url&lt;/span&gt; =          {&lt;span style="color: #3a5fcd; text-decoration: underline;"&gt;https://doi.org/10.1103/PhysRevB.63.205419&lt;/span&gt;},
  &lt;span style="color: #8b008b;"&gt;month&lt;/span&gt; =        5,
}
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
If you have a lot of entries you want to modify, you can use bibtex-map-entries like this. Basically, put the elisp form in a comment, and then execute the elisp form
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-bibtex"&gt;&lt;span style="color: #ff0000; font-weight: bold;"&gt;%% (bibtex-map-entries 'jmax-stringify-journal-name)  &amp;lt;- put cursor here. C-x C-e&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
This saves some effort. Over time, I will keep adding entries to the abbreviation table. As long as a standard journal name or abbreviation is in your bibtex file, this approach should work pretty well. After you replace the journal names with @string entries, you have to generate the string file, either shorttitles.bib or longtitles.bib, and in your LaTeX file, change your bibliography line to:
&lt;/p&gt;

&lt;div class="org-src-container"&gt;

&lt;pre class="src src-latex"&gt;&lt;span style="color: #8b0000;"&gt;\bibliography&lt;/span&gt;{&lt;span style="color: #cd0000;"&gt;shorttitles,references&lt;/span&gt;}
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
The order is important. The @string definitions are in shorttitles.bib, and your bibtex entries in references.bib.&lt;/p&gt;
&lt;p&gt;Copyright (C) 2014 by John Kitchin. See the &lt;a href="/copying.html"&gt;License&lt;/a&gt; for information about copying.&lt;p&gt;&lt;p&gt;&lt;a href="/org/2014/10/11/Abbreviated-journal-names-in-bibtex.org"&gt;org-mode source&lt;/a&gt;&lt;p&gt;&lt;p&gt;Org-mode version = 8.2.7c&lt;/p&gt;
]]></content:encoded>
    </item>
  </channel>
</rss>
