|
|
|||
![]() |
Department of Engineering |
| University of Cambridge > Engineering Department > computing help > LaTeX |
@BOOK
{KandR,
AUTHOR = "Kernighan, Brian W. and Ritchie, Dennis M.",
TITLE = "{The C Programming Language Second Edition}",
PUBLISHER = "Prentice-Hall, Inc.",
YEAR = 1988
}
The first field (in this case KandR) is the tag used when you \cite the item.
How this citation appears in the text depends on the packages used and the
bibliography style.
The AUTHOR field should be in the following format
Surname1, Forename1 and Surname2, Forename2 and Surname3, Forename3 ...
- this information will be reformatted in the document.
In your main latex document you need \bibliographystyle{plain}
at the top to set the style and \bibliography{testbib} where you
want the bibliography to appear, and to specify the bibtex file. Only cited
items will appear in the bibliography.
As a test, put the following in test.tex
\documentclass{article}
\bibliographystyle{plain}
\begin{document}
See \cite{KandR} for details.
\bibliography{testbib}
\end{document}
Initially you have to run latex test, bibtex test,
latex test and latex test
again on your document before everything appears. After that, you only
have to run latex (unless you change the bibliography file).
\documentclass{article}
\usepackage{natbib}
\bibliographystyle{plainnat} % note the change here
\begin{document}
See \cite{KandR} for details.
\bibliography{testbib}
\end{document}
Now it's easy to add features. For instance, to have superscripted, sorted
citations, use
...
\usepackage[super,sort]{natbib}
...
natbib offers variants like \citep, \citet and
gives control over punctuation, vertical space between bibliography items, etc.
The tocbibind package helps add bibliographies to contents pages.
To have a section of References (items cited) and a Bibliography (which
may contain items not cited) in a single-file article you can do the following - add \usepackage{bibunits} to your latex document and create your references in the usual way.
Then add
\renewcommand\refname{Bibliography}
\begin{bibunit}[plain]
\nocite{*}
\putbib[testbib]
\end{bibunit}
to the file (called test.tex say). Then run latex test, bibtex test, bibtex bu1 (and bibtex bu2 if you have 2 bibunits, etc),
latex test and finally latex test.
To have a single bibliography sectioned by chapters, use chapterbib
- see the chapterbib.sty file for details. Here's a short example:
in your main document (called test.tex say), use the information
in test.bib
\documentclass{book}
\bibliographystyle{plain}
\usepackage[gather]{chapterbib}
\begin{document}
\include{One}
\include{Two}
\include{Three}
\bibliography{test}
\end{document}
Each included file can be something like this
\chapter{One}
\bibliographystyle{plain}
\cite{KP78}
\cite{H90}
\bibliography{test}
Then process as follows
latex test bibtex One bibtex Two bibtex Three latex test latex testIf you want multiple bibliographies and you're using natbib, check the natbib documentation.
To split a bibliography into several categories/subcategories try splitbib
| | computing help | LaTeX | |