The command to print the bibliography in natbib
is \bibliography{<your-bib-file>}
. You don't use \begin{thebibliography} ... \end{thebibliography}
.
So the following document should work:
\documentclass[a4paper,norsk]{article}
\usepackage{amstext}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage[comma,authoryear]{natbib}
\usepackage[norsk]{babel}
\usepackage[hmargin=3cm,vmargin=3.5cm]{geometry}
\pagestyle{plain}
\begin{document}
Insert some \cite{} commands here to your citations.
\printindex
\bibliographystyle{plainnat}
\bibliography{<your-bib-file>} % Insert the name of your bib file here
\end{document}
Sorting of the bibliography requires that you have an external database of entries rather than a hand built list. In your case your external file mybib.bib
could be:
@Article{art,
author = {Art, John},
title = {John's Article},
journal = {J. Jour.},
year = 2006,
volume = 7,
pages = {12-45}
}
@Book{fart,
author = {Fart, Peter},
title = {Travelling at speed},
publisher = {P. Press},
year = 2009,
address = {Sometown}
}
To use this in your document there are two approaches: (1) traditional bibtex
; (2) modern biblatex
.
Bibtex approach
Choose a style for the bibliography via \bibliographystyle
. Choose the database file and print the bibliography via \bibliography{mybib}
. As you seem to want your authors listed as Lastname, Firstname
then one choice is the apa
style, which requires the natbib
package; pass the option numbers
to this package to get numerical citations.
\documentclass{article}
\usepackage[numbers]{natbib}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat~\cite{fart}. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum~\cite{art}.
\bibliographystyle{apa}
\bibliography{mybib}
\end{document}
Compile as
pdflatex myfile
bibtex myfile
pdflatex myfile
to get
Read more at bibtex on CTAN
Biblatex approach
Load the package biblatex
, with style=numeric
for numerical citations. To get Lastname, Firstname in the bibilography use the command \DeclareNameAlias{default}{last-first}
. Point to your database via \addbibresource{mybib.bib}
. Put \printbibliography
at the place in you file you want the bibliography to appear.
\documentclass{article}
\usepackage[style=numeric]{biblatex}
\addbibresource{mybib.bib}
\DeclareNameAlias{default}{last-first}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat~\cite{fart}. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum~\cite{art}.
\printbibliography
\end{document}
Compile with
pdflatex myfile
biber myfile
pdflatex myfile
to get
Read more at Guidelines for customizing biblatex styles and in the biblatex
manual combined with the bitex reference above.
Best Answer
For an overview of how LaTeX and BibTeX work, generally, see:
Here's a simple example:
Assume your
.bib
file looks like this:testbib.bib
(You can create these entries using your favourite reference manager (most likely JabRef (Windows/Linux/Mac) or BibDesk (Mac). See:
Now create a document:
Compile this using
pdflatex
, thenbibtex
, thenpdflatex
andpdflatex
once more. For more on why this is necessary, see:Question mark or bold citation key instead of citation number
The resulting document should look like this: