How to order citations by appearance using BibTeX? - latex

By default (using the plain style) BibTeX orders citations alphabetically.
How to order the citations by order of appearance in the document?

There are three good answers to this question.
Use the unsrt bibliography style, if you're happy with its formatting otherwise
Use the makebst (link) tool to design your own bibliography style
And my personal recommendation:
Use the biblatex package (link). It's the most complete and flexible bibliography tool in the LaTeX world.
Using biblatex, you'd write something like
\documentclass[12pt]{article}
\usepackage[sorting=none]{biblatex}
\bibliography{journals,phd-references} % Where journals.bib and phd-references.bib are BibTeX databases
\begin{document}
\cite{robertson2007}
\cite{earnshaw1842}
\printbibliography
\end{document}

Change
\bibliographystyle{plain}
to
\bibliographystyle{ieeetr}
Then rebuild it a few times to replace the .aux and .bbl files that were made when you used the plain style.
Or simply delete the .aux and .bbl files and rebuild.
If you use MiKTeX you shouldn't need to download anything extra.

The best I came up with is using the unsrt style, which seems to be a tweaked plain style. i.e.
\bibliographystyle{unsrt}
\bibliography{bibliography}
However what if my style is not the default?

Just a brief note - I'm using a modified version of plain.bst sitting in the directory with my Latex files; it turns out having sorting by order of appearance is a relatively easy change; just find the piece of code:
...
ITERATE {presort}
SORT
...
... and comment it - I turned it to:
...
%% % avoid sort:
%% ITERATE {presort}
%%
%% SORT
...
... and then, after running bibtex, pdflatex, pdflatex - the citations will be sorted by order of appearance (that is, they will be unsorted :) ).
Cheers!
EDIT: just realized that what I wrote is actually in the comment by #ChrisN: "can you edit it to remove the SORT command" ;)

You answered your own question---unsrt is to be used when you want references to ne listed in the order of appeareance.
But you might also want to have a look at natbib, an extremely flexible citation package. I can not imagine living without it.

I'm a bit new to Bibtex (and to Latex in general) and I'd like to revive this old post since I found it came up in many of my Google search inquiries about the ordering of a bibliography in Latex.
I'm providing a more verbose answer to this question in the hope that it might help some novices out there facing the same difficulties as me.
Here is an example of the main .tex file in which the bibliography is called:
\documentclass{article}
\begin{document}
So basically this is where the body of your document goes.
``FreeBSD is easy to install,'' said no one ever \cite{drugtrafficker88}.
``Yeah well at least I've got chicken,'' said Leeroy Jenkins \cite{goodenough04}.
\newpage
\bibliographystyle{ieeetr} % Use ieeetr to list refs in the order they're cited
\bibliography{references} % Or whatever your .bib file is called
\end{document}
...and an example of the .bib file itself:
#ARTICLE{ goodenough04,
AUTHOR = "G. D. Goodenough and others",
TITLE = "What it's like to have a sick-nasty last name",
JOURNAL = "IEEE Trans. Geosci. Rem. Sens.",
YEAR = "xxxx",
volume = "xx",
number = "xx",
pages = "xx--xx"
}
#BOOK{ drugtrafficker88,
AUTHOR = "G. Drugtrafficker",
TITLE = "What it's Like to Have a Misleading Last Name",
YEAR = "xxxx",
PUBLISHER = "Harcourt Brace Jovanovich, Inc."
ADDRESS = "The Florida Alps, FL, USA"
}
Note the references in the .bib file are listed in reverse order but the references are listed in the order they are cited in the paper.
More information on the formatting of your .bib file can be found here: http://en.wikibooks.org/wiki/LaTeX/Bibliography_Management

I often use the bibliography style natbib because it supplies quite complete set of formats as well as tags for us.

Add this if you want the number of citations to appear in order in the document
they will only be unsorted in the reference page:
\bibliographystyle{unsrt}

I used the following in overleaf and become in ascending order:
\usepackage{cite}
\bibliographystyle{unsrt}

with unsrt the problem is the format. use \bibliographystyle{ieeetr} to get refences in order of citation in document.

If you happen to be using amsrefs they will override all the above - so comment out:
\usepackage{amsrefs}

The datatool package offers a nice way to sort bibliography by an arbitrary criterion, by converting it first into some database format.
Short example, taken from here and posted for the record:
\documentclass{article}
\usepackage{databib}
\begin{document}
% First argument is the name of new datatool database
% Second argument is list of .bib files
\DTLloadbbl{mybibdata}{acmtr}
% Sort database in order of year starting from most recent
\DTLsort{Year=descending}{mybibdata}
% Add citations
\nocite{*}
% Display bibliography
\DTLbibliography{mybibdata}
\end{document}

I use natbib in combination with bibliographystyle{apa}. Eg:
\begin{document}
The body of the document goes here...
\newpage
\bibliography{bibliography} % Or whatever you decided to call your .bib file
\usepackage[round, comma, sort&compress ]{natbib}
bibliographystyle{apa}
\end{document}

Related

Augment latex citation with specific table (or figure) reference

How do I include a specific table within a latex citation, i.e., what's the syntax? In other words, I'd like to cite table 11.1 in the "Handbook of Hydrology" by David Maidment. In my BibTex text file, the reference is:
#book{maidment1993,
Author = {Maidment, David R},
Isbn = {0-07-039732-5},
Publisher = {McGraw-Hill},
Address = {New York, USA},
Title = {Handbook of Hydrology},
Year = {1993}}
and so in the tex file that invokes this reference, it's easy enough to add ...\citep{maidment1993}..., but if I want the output to also include table 11.1, as in "...(Table 1.1; Maidment, 1993)." and not merely "(Maidment, 1993)", how do I do that in the .tex file? I tried \citep{Table 11.1 maidment1993}, but not surprisingly, that doesn't work.
You can add the table as optional argument. For example with biblatex:
\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\cite[Table 11.1]{knuth:ct}
\printbibliography
\end{document}

Print parts of bibliography using BibTeX?

For some days I am trying to solve the following problem for which I wasn't able to find a solution. Help is very much appreciated.
I am writing a long document and for some sections I would like to print a subset of items from the total bibliography that will be included at the very end before the appendix.
Is there a way do this? I was playing with refsection and imagining something like:
\documentclass[ twoside,openright,titlepage,numbers=noenddot,
headinclude,footinclude,
cleardoublepage=empty,abstract=on,
BCOR=5mm,paper=a4,fontsize=11pt
]{scrreprt}
\usepackage{biblatex}
\addbibresource[label=ownpubs]{ownpubs.bib}
\addbibresource[label=refs]{references.bib}
\begin{document}
%here I want to print a selection of the complete bibliography
%References are required to be consistent throughout the whole document
\chapter*{Related Publications}
\begin{refsection}[references.bib]
\nocite{*}
\printbibliography[heading=none]
\end{refsection}
%here goes all the other stuff: chapters, sections, whatever
%print complete bibliography
\nocite{*}
\printbibliography
\end{document}
ownpubs.bib:
#article{einstein1935can,
title={Can quantum-mechanical description of physical reality be considered complete?},
author={Einstein, Albert and Podolsky, Boris and Rosen, Nathan},
journal={Physical review},
volume={47},
number={10},
pages={777},
year={1935},
publisher={APS}
}
#article{einstein1905movement,
title={On the movement of small particles suspended in stationary liquids required by the molecularkinetic theory of heat},
author={Einstein, A},
journal={Ann. d. Phys},
volume={17},
number={549-560},
pages={1},
year={1905}
}
references.bib:
#article{schrodinger1935gegenwartige,
title={Die gegenw{\"a}rtige Situation in der Quantenmechanik},
author={Schr{\"o}dinger, Erwin},
journal={Naturwissenschaften},
volume={23},
number={50},
pages={844--849},
year={1935},
publisher={Springer-Verlag}
}
With the above code I got the bibliographies printed, but the references (numbers) are not consistent.
Does anyone know a way to approach this problem? I am in no means restricted to splitting the files up. That was just the only solution I was able to come up with.
Thanks for your help and warm Greetings!
You could use a similar approach as in https://tex.stackexchange.com/a/166018 and automatically add some keyword to all entries in references.bib. This will allow you to filter for those when using \printbibliography:
\documentclass[ twoside,openright,titlepage,numbers=noenddot,
headinclude,footinclude,
cleardoublepage=empty,abstract=on,
BCOR=5mm,paper=a4,fontsize=11pt
]{scrreprt}
\usepackage{biblatex}
\addbibresource[label=ownpubs]{ownpubs.bib}
\addbibresource[label=refs]{references.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\perdatasource{references.bib}
\step[fieldset=keywords, fieldvalue={,Perhalo}, append]
}
}
}
\begin{document}
%here I want to print a selection of the complete bibliography
%References are required to be consistent throughout the whole document
\chapter*{Related Publications}
\printbibliography[heading=none,keyword={Perhalo}]
%here goes all the other stuff: chapters, sections, whatever
%print complete bibliography
\nocite{*}
\printbibliography
\end{document}

Latex: In Springer class svjour3, want references sorted in alphabetical order, in author-year format

I am writing a paper in LAtex and using Springer macro package (svjour3 class).
Requirement is: citations should be in the form of authoryear and sorted in alphabetical order.
My tex file looks like:
{
\documentclass[smallextended]{svjour3}
\usepackage{natbib}
\begin{document}
\title{abc}
\bibliographystyle{spbasic} % basic style, author-year citations
%\bibliographystyle{spmpsci} % mathematics and physical sciences
%\bibliographystyle{apa}
%bibliographystyle{spphys} % APS-like style for physics
%\bibliographystyle{plainnat}
\bibliography{review} % name your BibTeX data base
\end{document}
}
I have used all the possible options of bibliographystyle.
Also I have used various types of options in \usepackage[options]{natbib}
Tried deleting all the temporary files aux, logs and all others.
All entries in bib file have author and year and are separated by commas.
Still I am getting following errors:
{
Package natbib Error: Bibliography not compatible with author-year citations. ...mmand\NAT#force#numbers{}\NAT#force#numbers
}
You have to add:
\usepackage[numbers,sort&compress]{natbib}
and then add bibliography as:
\bibliographystyle{spbasic}
\bibliography{sample.bib}
You have to add:
\usepackage[numbers,sort&compress]{natbib}
and then add bibliography as:
\bibliographystyle{spbasic}
\bibliography{sample.bib}
That almost did it for me. I changed it to
\usepackage[sort&compress]{natbib}
in the preamble. Cited with
\citep{ReferenceXY}
and added my bib
\bibliographystyle{spbasic}
\bibliography{literature.bib}

How can I import bib File to Latex?

I'm new to using Latex. I want to import File reference.bib to my File document.tex. Above is my Code
reference.bib
#article{lin1973,
author = "Shen Lin and Brian W. Kernighan",
title = "An Effective Heuristic Algorithm for the Travelling-Salesman Problem",
journal = "Operations Research",
volume = 21,
year = 1973,
pages = "498-516"
}
And here is my document.tex
\documentclass[a4paper,12pt, fleqn]{scrreprt}
\usepackage{natbib}
\begin{document}
\bibliographystyle{plainnat}
\bibliography{reference}
\end{document}
But nothing happens when i run my Latex. Can anyone help me.
Thanks in Advance ^^
There is a separate platform to ask LateX-related questions.
Apart from that, the question is really vague.
Let's start with your document having no content. Assuming that your LateX environment has been set up properly, adding something to your document should do something.
Compile, run BibteX twice, compile again a few times and you should be set.
EDIT: removed screenshot output file, as it was needlessly taking up space.
BibTeX build is usually found in your interpreter:
\documentclass[a4paper,12pt, fleqn]{scrreprt}
\usepackage{natbib}
\begin{document}
Blablabla happened because I need to cite \cite{lin1973}..
\bibliographystyle{plainnat}
\bibliography{reference}
\end{document}

LaTEX: changing the format of citation in References to list authors' last name first

It seems the format in the Reference section is a little off! Can you please show me how to format the citation to list authors' last name first?
Thanks all.
Here is the current form in the Reference section:
C. B. Grimmond, A. Isard, and J. Belding. Development and evaluation of
continuously weighing mini-lysimeters. Agricultural and Forest Meteorology,
62(3-4):205{218, 1992.
I use BibDesk to organize the citation database. Here is what I am using in the TeXstudio:
\documentclass[]{article}
\usepackage[pdftex]{graphicx}
\usepackage[round]{natbib}
\begin{document}
\bibliographystyle{plainnat}
\bibliography{/Users/me/Citation/citation}
\end{document}
You can try to change the Bibtex Bibliography style to 'acm' or 'apalike'
\bibliographystyle{stylename}
\bibliography{bibfile}
Read more about other styles: https://www.sharelatex.com/learn/Bibtex_bibliography_styles

Resources