How to Use plain and unsrt Bibliography Styles in LaTeX
Category: Latex
Date: 6 months ago
Views: 381
LaTeX provides a powerful way to manage bibliographies using BibTeX. Two common bibliography styles are `plain` and `unsrt`. This article will demonstrate how to use both styles in your LaTeX documents.
Using the `plain` Style
The `plain` style sorts the references alphabetically by the author's last name. Here's an example:
LaTeX File (`main.tex`)
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{cite}
\begin{document}
\title{Sample Document}
\author{Author Name}
\date{\today}
\maketitle
\section{Introduction}
This document cites multiple sources \cite{goossens97, lamport94, knuth84, greenwade93, patashnik88}.
\bibliographystyle{plain}
\bibliography{references}
\end{document}
BibTeX File (`references.bib`)
@book{patashnik88,
author = "Oren Patashnik",
title = "BibTeXing",
year = "1988",
publisher = "Oren Patashnik",
address = "Stanford, California"
}
@book{lamport94,
author = "Leslie Lamport",
title = "LaTeX: A Document Preparation System",
year = "1994",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@book{knuth84,
author = "Donald E. Knuth",
title = "The TeXbook",
year = "1984",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@book{goossens97,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1997",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@article{greenwade93,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}e{X} {A}rchive {N}etwork ({CTAN})",
year = "1993",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
In the document above, the bibliography will be sorted alphabetically by the authors' last names.
Using the `unsrt` Style
The `unsrt` style lists references in the order they are cited in the document. Here's how to use it:
LaTeX File (`main.tex`)
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{cite}
\begin{document}
\title{Sample Document}
\author{Author Name}
\date{\today}
\maketitle
\section{Introduction}
This document cites multiple sources \cite{goossens97, lamport94, knuth84, greenwade93, patashnik88}.
\bibliographystyle{unsrt}
\bibliography{references}
\end{document}
BibTeX File (`references.bib`)
@book{patashnik88,
author = "Oren Patashnik",
title = "BibTeXing",
year = "1988",
publisher = "Oren Patashnik",
address = "Stanford, California"
}
@book{lamport94,
author = "Leslie Lamport",
title = "LaTeX: A Document Preparation System",
year = "1994",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@book{knuth84,
author = "Donald E. Knuth",
title = "The TeXbook",
year = "1984",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@book{goossens97,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1997",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@article{greenwade93,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}e{X} {A}rchive {N}etwork ({CTAN})",
year = "1993",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
In the document above, the bibliography will be listed in the order the references are cited in the text.
Compiling the Document
To compile your LaTeX document with BibTeX, follow these steps:
- Run
pdflatex main.tex
to generate an initial `.aux` file. - Run
bibtex main.aux
to generate the bibliography. - Run
pdflatex main.tex
twice more to update references and generate the final document.
By using these steps and styles, you can control the order of your bibliography entries in LaTeX documents. Choose `plain` for alphabetical order or `unsrt` for citation order.
0 Comments, latest
No comments.