Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In general auctex makes a good job of formating latex. However, the formating for Bibtex doesn't seem that great. For example, I would tend to format my bibtex entries in this way:

@article{Smith,
   author = {Smith, John},
   journal = "A good journal",
   title = {A snappy title},
   volume = {1},
   year = {2010}
}

However, C-M-\ formats the entry as:

          @article{Smith,
          author = {Smith, John},
          journal = "A good journal",
          title = {A snappy title},
          volume = {1},
          year = {2010}
          }

(notice the large gap on the LHS). Is there a better mechanism for formating Bibtex entries when using emacs?

share|improve this question
    
When you enter bibtex entries using C-c C-b in auctex bibtex mode, they are indented as you want them to be... –  Seamus Sep 6 '10 at 9:41
    
Thanks. But I tend to import my entries from mendeley or citeulike. –  csgillespie Sep 6 '10 at 10:21
add comment

3 Answers

up vote 6 down vote accepted

I guess you're looking for C-c C-q (= bibtex-fill-entry). Result for your example would be:

@article{Smith,
  author =       {Smith, John},
  journal =      "A good journal",
  title =        {A snappy title},
  volume =       {1},
  year =         {2010}
}

There is also a bibtex-reformat (in the menu) which uses bibtex-fill-entry for the whole buffer. See also the help for these functions.

share|improve this answer
add comment

You have used the wrong command to format bib entries.

This might be an oversight from bibtex-mode's part that C-M-\ does not do the right thing. You can use C-c C-q as others have suggested. I personally use C-c C-c which cleans up the entry including proper indentation.

share|improve this answer
add comment

On OSX, I just load the bibtex file with an application called bibdesk and then save it, which sets up the format you desire. Probably there is a similar tool on most platforms.

I love emacs dearly, but end up doing most of my citation work in bibdesk because of its extra features. The tagging of entries with keywords is particularly helpful, because I maintain a large central bibtex file, and when I am writing something specific I like to extract a subset and use it locally. (This use of a separate bibtex file for each paper I write makes the papers less brittle. I never have to worry that when I go to make revisions to satisfy reviewers, I might have accidentally deleted an entry or changed its citation key.) Another great feature of bibdesk is that it supports drag and drop of PDF files and URLs, so that bibdesk is not just a citation manager, but a sort of reading library.

One more bit of advice: pay careful attention to your citation keys. I've tried several schemes, but lately I've switched to the following scheme. Take the last name of the first author, and write this in lower case. To the right, put the 4 digits of the publication date. To the right of that, put (in lower case) the first letter of each of the first four words of the title (or as many words as exist). I never skip a word in a title, e.g. "The End of the World" becomes "teot". The benefit of this scheme is that there are essentially never any conflicts, and the keys are very easy to remember, or to construct at a glance, given the full citation as it appears in a bibliography.

share|improve this answer
    
I was on my way to creating a bib manager mode for emacs but was distracted by bibdesk. It is possible to implement something as powerful as bibdesk in emacs. I may do it some day. –  Leo Liu Sep 6 '10 at 14:40
    
Of course it's possible, but are you willing to write it from scratch in elisp? BibTeX does lack a decent set of command-line tools (to query, filter, normalize, format, merge... .bib files). That would be a better idea IMHO. –  Damien Pollet Sep 6 '10 at 15:58
    
I build it on top of bibtex.el. Currently my package can do the following: pastebin.ca/1934451. But I have been using bibdesk. –  Leo Liu Sep 6 '10 at 16:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.