12

I'd like to sort my references alphabetically by last name of the author (firstly Art, then Fart). There's one more thing - I want to have the last names put in the front.

I guess the latter can be solved simply by

\bibitem{art} ART, John.
\bibitem{fart} FART, Jack.

I don't know about the former. I'm still new to libraries, so I don't mind using any package. I prefer the simplest code possible though. (I'm using the TeXworks editor.)

My code is below

\documentclass{article}

\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}

\begin{thebibliography}{99}
\addcontentsline{toc}{chapter}{Bibliography}

\bibitem{art}
ART, John.

\bibitem{fart}
FART, Jack.

\end{thebibliography}

\end{document}

Picture with intention included:enter image description here

Thank you!

1
  • If you want alphabetical sorting in the bibliography section, those citations have to be [2] and [1]. If you use the thebibliography environment, you are responsible for typing the references as you like.
    – egreg
    Commented Dec 5, 2013 at 23:31

1 Answer 1

18

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

Sample bibtex output

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

Sample biblatex output

Read more at Guidelines for customizing biblatex styles and in the biblatex manual combined with the bitex reference above.

2
  • 1
    That is more complicated than I had expected. Thank you though.
    – Vochmelka
    Commented Dec 6, 2013 at 12:12
  • 1
    Once you get used to it, it is very useful. You can use the same database file for all your projects, and style the references in individual ways in different projects. Commented Dec 6, 2013 at 12:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .