# Formatting citations to the literature on MathOverflow

We'd like to make it easier to cite articles from the literature, on MathOverflow.

I propose adding a single button to the edit toolbar while writing posts, which will pop up a search dialog, allow the user to select a result, and then insert a nicely formatted link to the paper back into the edit box.

The button would appear next to the current four icons for inserting hyperlinks, blockquotes, preformatted text, and images. (We could insert this button ourselves, via our allowed javascript footer, but eventually we'd want SE to insert it natively.)

To get a sense of how the search dialog might work, please look at this prototype. (Obviously this would need some polishing; suggestions for improvements welcome.)

Once a search result has been selected, I propose inserting into the edit box something like:

<span class="citation" authors="Sendak, Maureen and Geisel, Theresa" mrnumber="MR1234567"
cite="J. Unexpected Results 17 (2015), no. 1, 17-29">
<a href="http://dx.doi.org/10.1111/2222">A mathematics paper</a>
</span>


which will render simply as the hyperlink A mathematics paper. The hyperlink should be the 'best available URL', e.g. the DOI resolution address, a direct link to the published version, or the link to the corresponding record on MathSciNet.

I would like to include the extra <span> tag around the actual hyperlink for several reasons:

1. it makes the extra citation data available, in case the user wants to also show the authors or journal reference in the text,
2. it allows us to render citation links differently via the CSS selector .citation if desired,
3. it allows us to programmatically detect and reformat citation links after the fact, if desired (e.g. to provide links to your local library's resolver).

There are a number of things we'll need to do:

• verify we really can add a button to the edit interface
• pick a 'backend' for the search dialog (the prototype above is a hack; it would be nice to run off MathSciNet or Zentralblatt, etc, but this may require a lot of coordination)
• design and build the search dialog
• beta test with some users
• I recall similar discussions on meta.MSE, – Asaf Karagila Feb 9 '14 at 3:44
• @AsafKaragila I have looked at the questions that are tagged citation, but I did not find which one you have in mind. The only thing I recall, which is related to this, is DOI support for hyperlinks - a feature-request by Willie Wong on meta.SO. – Martin Sleziak Feb 9 '14 at 9:26
• @Martin: Yes, the DOI feature was born from a discussion, and my adamant refusal to open an account on meta.SO, leading Willie to post this request. (It was before the days that it was established that feature requests can be made on any meta.) I should also point out that the situation here is different, because MO is allowed to inject non-malicious scripts into the page, so we can do it independently. – Asaf Karagila Feb 9 '14 at 10:21
• @quid: Oh, it might be the case that I was thinking about this thread. (Scott, note how you claimed to be uninterested in implementing this yourself. :-)) – Asaf Karagila Feb 9 '14 at 10:31
• @AsafKaragila (Sorry I deleted comment as I were to add something. Yes I think this could be it, see one of your later comments) There is a discussion on tea started also mentioning some to be started discussion on meta.math.SE see tea.mathoverflow.net/discussion/1147/doi-feature Yet in a comment to this later related dicussion you only recall tea and meta.SO meta.math.stackexchange.com/questions/3277/… – user9072 Feb 9 '14 at 10:32
• Thank you for the historical research! I'd forgotten so much (even though I'd been part of those conversations). – Scott Morrison Feb 9 '14 at 11:05
• The 'hack' search interface above already recognizes MR numbers, and could very easily be made to recognize arXiv identifiers too. I'm imagining that if you already have text selected when clicking the 'add citation' button, that will be pasted into the search. Thus one could simply type 'in the paper MR12345', highlight the MR12345, click the 'add citation' button, accept the first search result, and be on your way. This sounds really appealing to me! – Scott Morrison Feb 9 '14 at 11:07
• I have a very similar feature request on MSO (meta.stackexchange.com/questions/116397/…). Mine is a bit more focused on life sciences though. – user35354 Feb 9 '14 at 12:16
• By the way, the script is pretty awesome. I got a bit scared when "Iggy Pop" returned ten results. :-) – Asaf Karagila Feb 9 '14 at 15:20
• @MadScientist's request also suggests footnoting the full citation, which I think is a nice idea. – Scott Morrison Feb 9 '14 at 20:51
• @AsafKaragila, yes, as written it's intended as a very 'fast and loose' search. If some of your search queries don't match, it still returns the best matches for the others. Notice iggy returns no results – Scott Morrison Feb 9 '14 at 20:53
• Yeah, obviously the "Iggy Pop" search was to poke fun at this pretty cool tool. I also searched for several metal bands. Interestingly most of them (except obvious names like Death and Earth) returned nothing. Abyssic Hate, on the other hand, had four results! :-) – Asaf Karagila Feb 9 '14 at 21:11
• It is definitely possible to add buttons to the edit window; for a nice example see MathJax buttons on the edit window in stackapps. – Emilio Pisanty Feb 17 '14 at 11:50
• @EmilioPisanty, thanks for this. Someone (likely me) should adapt the example you linked to do what we want. If that looks okay we can arrange to inject it from the footer. – Scott Morrison Feb 19 '14 at 8:43
• Old request for this feature in MSO, turned up by Shog9: Add explicit support for citing scientific literature. – Emilio Pisanty Feb 24 '14 at 22:15

We now have a prototype for inserting citations!

See it in action in this video tutorial.

It currently requires you to install a user script, and has only been tested on the Chrome browser.

Now, visit MathOverflow and start asking a new question (or starting answering an existing question). You'll see at the top of the edit box there's a button labelled \cite. Click this, and a search dialog will pop up. (If you've selected text in the edit window, this will automatically be copied into the search dialog.) The search dialog accepts titles, authors, and citation data in any combination. You'll see one or more best matches, and often a preview of the PDF in the right pane. If you see what you want, select it in the left pane, and a nicely formatted citation will be inserted back in the edit box!

Here are some screenshots of the script in action.

• Is it possible to make the citation link text more than just the title? I would prefer a more comprehensive link text, with authors, journal, year, etc. It is easy to delete this or simplify it, for those who don't want it, but a bit harder to add it in. Also, I guess the literature search doesn't seem to include the math arxiv? – Joel David Hamkins Mar 10 '14 at 16:28
• @JoelDavidHamkins, I think this can be arranged pretty easily. The search tool returns all this data, so it's just a matter of tweaking the javascript that inserts the link. I'll ask Manish to do this. I can include all the arxiv readily enough, but I'm going to wait on resolving another issue. – Scott Morrison Mar 10 '14 at 22:22
• Another idea might be to make the article title the link, but to have the rest of the citation information such as author and journal etc. available inside the <cite> object as (unlinked) mere text. – Joel David Hamkins Mar 12 '14 at 0:14
• @JoelDavidHamkins What do you think of this, for the linkification? (A quick way to test this for one page is to disable the citation userscript in chrome://extensions and copy the code from the above link into the JS console; Ctrl-Shift-J) The entire block now inserts the citation, however you can click on a preview link and have the preview load inline. – Manishearth Mar 15 '14 at 10:08
• @Manishearth, I am very sorry, but I evidently I am not capable of implementing your script properly. Perhaps you can just provide a sample output? – Joel David Hamkins Mar 16 '14 at 0:23
• @joel here. There's a chance I broke something yesterday (I linked you to the non-stable branch of the code which is not guaranteed to work), I'll have a look in a while. Thanks. – Manishearth Mar 16 '14 at 3:55
• @Manishearth, looks great, if I understand what you are saying. – Joel David Hamkins Mar 16 '14 at 11:37
• @JoelDavidHamkins, I've just added some screenshots, showing how it works and the updated linking style. – Scott Morrison Mar 16 '14 at 13:04
• We need to sort a few things out in the background, but hopefully this is going to be ready soon! – Scott Morrison Mar 16 '14 at 13:04
• Fantastic! This is exactly the kind of thing I had had in mind with my suggestion. – Joel David Hamkins Mar 16 '14 at 13:05
• So when can we expect a FF script? – Asaf Karagila Mar 16 '14 at 19:37
• Great! Tested in Firefox and GreaseMonkey and seems to work (I needed to allow javascript from herakuapp.com). By the way can you add also Theoretical Computer Science to the list of the sites that the script works on? – Kaveh Mar 17 '14 at 5:55
• @Kaveh the best place to report issues is here, but pinging me here is fine too. (Somehow I missed this). I think Scott's backend is acting strange in this case. I'll try rehosting it this weekend if possible and look into it (no guarantees though, I'm not too familiar with the backend). – Manishearth Apr 11 '14 at 10:14
• @Manishearth This extension no longer works for me in Chrome, since Chrome won't let me enable it, as it is not "from the Chrome store". Is there any way to get it working again? Can it be made available at the Chrome web store? – Joel David Hamkins Jun 27 '14 at 13:51
• @JoelDavidHamkins There are some solutions to the problem here and here. I shall try to publish this to the play store, maybe as an unlisted app, next week when I'm not travelling so much. – Manishearth Jun 27 '14 at 16:21

Seems like a very useful feature to me. I am not an expert on HTML and co; but wouldn't the cite element be more appropriate than a general span tag?

As far as I know, you can still use all the other attributes that you were already using. The benefit would be a more semantic markup, which is good for SEO, and for custom stylesheets of users (or say specific browsers).

You could still keep the .citation class, but it would even be less necessary. (Though I can imagine you want someway to distinguish between tags inserted by this button, and cite-tags inserted manually by users.)