# Latex Texshop Bibliography

## Using BibTex in LATEX documents

BibTex is a program that reads entries from a database of citations based on the output of LATEX and then makes a bibliography file that LATEX can insert into the document. There is lots to say about BibTex (and some good manuals that do it well) but here are some essentials I have found useful and not covered in the books. (There is a lot to say and learn about LATEX too).

Finding the material for a BibTex database is a chapter of its own, covered at least briefly at http://www.sci.utah.edu/~macleod/litbase

There is a repository of bibtex files available for use at the SCI Institute.

Quick Links:

1. Usage Conventions
2. Teaching Bibtex to find your bibtex files
3. BibTex, PMCID, and the NIH
4. Editing BibTex files
5. Additional BibTex tools

## 1 Usage Conventions

There are a suggestions when using BibTex:

1. The standard way to show citations in the text is as 76'' where N is the reference number in the bibliography. We often use a style and a package called as in the LaTeX file that writes them as superscripted numbers. This style is also smart enough to find sequences of numbers and compress them, e.g., text1,2,3,4,5,9 becomes text1-5,9.
2. Enter refs as you go and do not leave them all to the last minute! This makes for unnecessary stress when we need it least. Give us your refs in whatever form you have and we can get them entered now.
3. If you are part of SCI (or otherwise smart and organized), please note the key naming conventions we use. You can find these in the SCI Bibtex tips web page.

## 2 Teaching Bibtex to find your bibtex files

The default location for the Bibtex files for a document are in the same directory as that document. A slightly better solution is to have a directory that holds all your Bibtex files and then hard-wire the commands in LateX to find those files.

A better way (the best way?) is to store all your Bibtex files in one place in your computer, ideally managed through a system like Subversion, and then to tell the Bibtex program where to look. How this works depends on the operating system and the Bibtex application, of course, but here are some typical examples. I found a lot of this information at this web site by Julien Dutant .

• Unix, in all its flavors.
This is the simplest but not the most common, sadly. The solution requires, of course, on an Environmental variable, which users typically set in a start script like .bashrc (for the Bash shell). # Set up the TeX environmentals TEXINPUTS=.:${HOME}/tex/latex: export TEXINPUTS BIBINPUTS=.:${HOME}/litbase/bibtex: export BIBINPUTS This bit of code also sets the TEXINPUTS environment variable, which is also helpful when one has some style files that are stored in a common directory and need to be available to all LaTeX files. ${HOME} is a built in variable that is set to be a user's home directory so this bit of code sets my LaTeX directory to ~macleod/tex/latex and my Bibtex directory to ~macleod/litbase/bibtex. • TexShop on the Mac (OSX) TexShop is based on TexLive and TeXLive requires a pre-set location, i.e., you cannot adjust this location and must store all .bib files in this place. The files go in ~/Library/texmf/bibtex/bib or subfolders of this directory. Of course, this directory is not directly visible in the modern versions of Mac OSX and the Finder, thus protecting users from all this tedious detail? To access the ~/Library directory, either use a terminal or use the "Go" command in the Finder but hold down the the option key to see this directory in the list. Here is what the result should look like: Once visible, you can maneuver to the texmf/ directory and then add the necessary bibtex/bib directories and store bibtex files there. I like to keep things in the same (visible) place for all programs that use bibtex so I have created a link between this standard location and the place TexShop wants to see things. This is a Terminal command so use with the usual care: cd ~/Library/tex/bibtex ln -s ~/litbase/bibtex bib You should then see something like the following (again from a terminal window): ls -l bib -> /Users/macleod/litbase/bibtex A above, this assumes my bibtex files are all in my ~/libtase/bibtex directory. • WinEdt In the control menu: Menu > Options > Executions Modes... A window opens with several tabs. In the "Console Applications" tab, you find a list of commands. Select bibtex, and add to the "Switches" field: --include-directory="F:\my bibliography folder" ## 3 BibTex, PMCID, and the NIH NIH requires public disclosure of journal articles supported by NIH funding and all such articles receive a code called the PMCID as part of the PubMed system. As an NIH funded researcher, you MUST include this code every time you cite such a reference, especially in progress reports, proposals, and biosketches. To support this code in BibTeX, I have created a slightly modified version of one of the most common BibTeX style files (.bst), which is available here. To use this new style file, 1. Add a field called "pmcid" to each BibTeX reference that contains the PMCID string, which you can locate by searching for the papers in the PubMed system. 2. Modify your command to look (something) like this: \bibliography{strings,biglit,crj,rtw,jgs,md,cdh,dhb,jaw,crb,sci} \bibliographystyle{nihunsrt} ## 4 Editing BibTex files To edit a BibTex file, you can use any editor but emacs has lots of great support for this process. The ones I like are Nelson Beebe's emacs tools found at www.math.utah.edu/pub/emacs/, in particular and . Here is what my contains to access these: ;;; Add bibtex mode unconditionally; it is already bound to text-mode ;;; and we can do better than that. (delq (assoc "\\.bib$" auto-mode-alist) auto-mode-alist) (setq auto-mode-alist (cons (cons "\\.bib\$" 'bibtex-mode) auto-mode-alist)) (autoload 'bibtex-mode "~/emacs/lisp/bibtex/bibtex" ;(autoload 'bibtex-mode "bibtex" "Enter BibTeX mode for bibliography editing." t nil) (setq bibtex-mode-hook '(lambda () (setq comment-end "") (setq comment-start "%% ") (setq comment-start-skip "%+ *") (setq bibtex-include-OPTcrossref nil) (setq bibtex-include-OPTkey nil) (setq bibtex-include-OPTannote nil) (setq bibtex-include-robnote t) (load "~/emacs/lisp/bibtex/bibtex-support") (load "~/emacs/lisp/bibtex/bibtools") ))

Note that these commands assume a subdirectory called in which the require lisp code ( or files) is available.

## 5 Additional BibTex tools

There are some other fun software tools that can make life easier with BibTex. Most are in the public domain in one form or another and I have included links where I had them--if the links fail, use Google and please let me know (macleod@sci.utah.edu).

## 5.1 EndNote

EndNote is not really a program that works on BibTexfiles but it does manage citations well and it has some support for BibTex that can make it useful.

See endnote.html for more details on how to convert between Endnote and BibTex.

## 5.2 bibclean

The goal of bibclean is to clean up syntax and layout errors in BibTex files so that all entries have a nice, clean look that is consistent. The program will also reveal some errors in the file, which can be very helpful! To get bibclean, surf on over to
and thank Nelson Beebe for making this available.

Here are some direct links that might be helpful

One of the many arguments to bibclean essential for SCI databases, if only because it is the convention we had adopted:

bibclean -no-fix-names which I actually alias to bibclean so that I don't forget!

## 5.3 Mendeley

The free literature databased program Meddeley has support for Bibtex output.

## 5.4 Converting from Word bibliography to BibTex

This is truly amazing! There is a website called hubmed.org that will convert from Word document text that you copy to the web page into Bibtex files! It actually works.

This program is some sort of search engine interface to Pubmed and it manages to parse the text and propose matches for each entry in the bibliography. I am really impressed with this tool!

## 5.5 Testing a BibTex file

There is a simple way to test a BibTex file for completeness using LATEX and the bibtex commands from your own computer. Testing is a good plan, especially if you do it after editing the file and not when you are in a hurry and have to build a document using the file.

To test a BibTex file, make a LaTeX file, call it with the following contents:

\documentclass[]{article} \begin{document} Some text. \nocite{*} \bibliography{sci} \bibliographystyle{unsrt} \end{document} where sci'' is the name of the BibTex file to test.

Then run

latex testbib bibtex testbib and the output will list all the errors or warnings resulting from trying to parse the file . Some of the output will be warnings that you can ignore but other errors can be fatal the next time you use the file.

## 5.5 BibDesk

BibDesk is a Mac OSX program to edit and manage your bibliography. It will keep track of both the bibliographic information and the associated files or web links for you. Read more at .

## 5.6 JabRef

JabRef is a new cross platform, open source program to edit and manage your bibliography. It performs searches and downloads articles (assuming they are open access) and seems to have a lot of customlization options. It claims to integrate well with many LaTeX systems/editors, including eXstudio, LyX, Kile, LatexEditor, Emacs, Vim, and WinEdt.

Last modified: Sat Mar 25 08:37:38 MDT 2017

## Using BibTeX to Create Your Bibliography

To learn about specific bibliography styles in BibTeX (e.g., how to do Chicago style citations), visit our BibTeX style page here.

## Using BibTex

Here's what to do after you have entered your sources in JabRef,EndNote, Bookends or BibDesk:

### For TeXShop

• Save your bibliography as a .bib file in the same folder as your thesis document. Make sure your filename ends in .bib.
• To have LaTex process your .bib file, add to the end of your .tex file these three lines (thesis.bib is the bibliography filename):    \bibliography{thesis}
\bibliographystyle{filename}
\nocite{*}
• To make changes to your bibliography, you can edit the .bib file directly or make changes in JabRef, EndNote, BibDesk or Bookends.
• To generate a PDF with your bibliography, in the .tex file, First typeset with  LaTex (click the first dropdown menu and select LaTex)
• Then typeset with BibTex (click the first dropdown menu and select BibTex)
• and Finally typeset in LaTex again, and then typeset in LaTex once more.

Note: Using the method above gives you an error log, which allows you to troubleshoot the errors in your bibliography. It is recommended that you use the shortcut below after you have done the above steps at least once.

As a shortcut to the three typesetting stages, click the Macros button --> Applescript --> Bibliography.

### For TeXnicCenter

• Save your bibliography as a .bib file in the same folder as your thesis document. Make sure your filename ends in .bib.
• To have LaTex process your .bib file, add to the end of your .tex file these three lines (thesis.bib is the bibliography filename):    \bibliography{thesis}
\bibliographystyle{filename}
\nocite{*}
• To make changes to your bibliography, you can edit the .bib file directly or make changes in JabRef, EndNote, BibDesk or Bookends.
• To generate a PDF with your bibliography, in the .tex file:
• Finally click Build on the tool bar --> Current File--> Build

## Natbib Cheatsheet

To learn how do make small changes to the citation styles in natbib, check out this Natbib cheatsheet.