Differences

This shows you the differences between two versions of the page.

Link to this comparison view

latex_and_bibtex [2009/06/02 00:23]
latex_and_bibtex [2009/06/02 00:23] (current)
Line 1: Line 1:
 +=====BibTeX=====
 +
 +BibTeX is a convenient way to organize your references. ​ To use BibTeX, insert the following lines at the end of your LaTeX file where the bibliography would be:
 +
 +  \bibliographystyle{apj}
 +  \bibliography{refs}
 +
 +You will need this file:
 +
 +[[http://​ads.harvard.edu/​pubs/​bibtex/​astronat/​apj/​apj.bst|apj.bst]]
 +
 +and your bibliography file
 +
 +  refs.bib
 +
 +On a Mac, you can put these in Library/​texmf/​bibtex/​ or you can put them in the directory you are compiling from.
 +
 +Now you need to make refs.bib. ​ It is a text file that contains information about your references. ​ ADS automatically generates BibTeX entries for articles. ​ Click on "​Bibtex entry for this abstract"​ under the ADS abstract. ​ The ADS entries for articles are good, but books and articles in books usually need to be modified.
 +
 +  * For books, you need the title, publisher, year, and author (some of which will be right). ​ The "​Address"​ field should have the publication city, and ADS doesn'​t generally put that in.  The type of publication (drop-down menu choice in [[#​BibDesk|BibDesk]]) should be "​book."​
 +
 +  * For articles in books (e.g., PPV), "​inproceedings"​ is a good type of publication. ​ ADS sometimes uses in "​inbook"​ (especially for older articles), and that doesn'​t seem to work as well.  I found that I generally needed to put in the publisher and address (i.e. city) myself.
 +
 +To cite a paper in the text of your document, you use commands like
 +
 +  \citet{citekey} ​     citation in the text
 +  \citep{citekey} ​     parenthetical citation
 +
 +You need to specify a citekey for each citation in your bibliography file.  There are many variations on these commands to make the citations look the way you want them to.  [[ftp://​ftp.edpsciences.org/​pub/​aa/​bibtex/​natnotes.pdf|This document]] lists some of them.  The command ​ \nocite{citekey1,​citekey2,​citekey3} adds references to the bibliography that haven'​t been cited in the text.  I used this to add papers to the bibliography of my thesis that were cited by hand in the text of my pre-BibTeX papers.
 +
 +
 +To compile your LaTeX file, run
 +
 +  latex (or pdflatex or whatever you use) 
 +  bibtex ​
 +  latex
 +  latex
 +
 +When you are ready to submit to ApJ, you will need to comment out
 +  \bibliography{refs}
 +and paste in the contents of 
 +  ms.bbl
 +This file is generated automatically by BibTeX.
 +
 +
 +=====BibDesk=====
 +
 +BibDesk is a nice Mac program for maintaining your bibliography file(s). ​ Here are a few BibDesk notes:
 +
 +  * If you select the BibTeX entry for a paper generated by ADS over the reference list, it will automatically create a new reference.
 + 
 +  * In Preferences;​ General, you can choose a bibliography file to open on launch.
 +
 +  * In Preferences;​ Cite Key, you can specify a format for citation keys, and then BibDesk will automatically generate them for you.  For example:
 +
 +  Preset Format: Custom
 +  Format String: %a[][+]31%y%u0 ​ (set by clicking on Advanced)
 +  Generate lowercase cite keys is checked in the Advanced dialog box.
 +
 +This example generates cite keys like mc05, mcp05, mcp+05 where the letters are the authors'​ last initials, a + says that there are more than three authors, and the last two digits are the year.  When you drag citations in from ADS, they have a citation key already set.  Hitting ⌘k (apple-k) with the citation highlighted will regenerate the cite key according to your rule.
 +
 +  * BibDesk will link citation entries to downloaded versions of the paper if you like.  It will also organize the papers and rename them according to a rule that you set.  Under Preferences;​ AutoFile, I have:
 +
 +  File papers in fixed location: ~/​Documents/​References
 +  File papers automatically is checked
 +  Preset Format: Custom
 +  Format String: %a1/%f{Cite Key}%u0%e
 +
 +When I download a paper, I save it to the desktop then drag it over its citation entry in BibDesk. ​ BibDesk renames the file citekey.pdf and moves it to ~/​Documents/​References/​FirstAuthorLastName/​citekey.pdf. ​ A thumbnail of the paper appears in the right-hand column of BibDesk when I click on a reference. ​ I can double-click on the thumbnail, and it opens the paper. ​ I like finding papers this way.
 +
 +  * To organize citations, you can make different bibliography files and refer to several of them in a tex file by separating their names with a comma. ​ Instead, when I put in the references for the older chapters in my thesis, I decided to just use one file and give each reference a Group tag.  This probably isn't the most elegant way to go, but I'm trying it for now.  Here's how it works:
 +I added a column to the list of references by ctrl-clicking on the column names and choosing Add Other, then picking Group from the list.  None of my references had a group field already. ​ To add one, I select one or more references, then chose Edit; Find; Database Find and Replace.
 +  Operation: Overwrite or Add Field
 +  Field: Group
 +  Value to Set: groupname
 +  Selected Items and Set empty fields are checked
 +  Then I click Replace All
 +The dialog box will stay open, so you don't have to go through all that again to do the same thing to other references. ​ By clicking on the header of the left-hand column in BibDesk, you can choose "​Group,"​ and it will list your groups. ​ If you click on one, you will only see references in that group.