# Citation style and arranging references

Following is the latex code provided by @Mike Renfro from Putting Serial Numbers in References

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{refs.bib}
@BOOK
{KandR,
AUTHOR  = "Kernighan, Brian W. and Ritchie, Dennis M.",
TITLE   = "{The C Programming Language Second Edition}",
PUBLISHER = "Prentice-Hall, Inc.",
YEAR = 1988
}
\end{filecontents*}
\usepackage[bibstyle=numeric,citestyle=authoryear,backend=bibtex]{biblatex}

\defbibenvironment{bibliography}
{\enumerate{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endenumerate}
{\item}

\begin{document}

In 1988 C was totally awesome. \autocite{KandR}

\printbibliography
\end{document}


However in the text at same time if I have to use (Kernighan and Ritchie, 1988) and at some places Kernighan and Ritchie (1988) then what will be the citing style for second scenario.

Moreover in references, i also need them to appear like this:

1. Kernighan, B.W. and Ritchie, D.M. The C Programming Lan- guage Second Edition. Prentice-Hall, Inc., 1988.

ie last name appearing first and accordingly all refernces are arranged in alphabetically order according to last name of first author.

• Ad 1: \textcite{KandR}? Ad 2: sorting=nty/sorting=nyt (name-title-year/name-year-title) and \DeclareNameAlias{sortname}{last-first} – moewe Apr 18 '14 at 12:59
• @moewe - Where is "sorting=nty/sorting=nyt (name-title-year/name-year-title) and \DeclareNameAlias{sortname}{last-first}" to be added in the above code ? – Neeraj Bhanot Apr 18 '14 at 13:04
• Add sorting to the load-time options, so \usepackage[bibstyle=numeric,citestyle=authoryear,backend=bibtex]{biblatex} reads \usepackage[bibstyle=numeric,citestyle=authoryear,backend=bibtex,sorting=nty]{biblatex} or \usepackage[bibstyle=numeric,citestyle=authoryear,backend=bibtex,sorting=nyt]{biblatex} afterward. \DeclareNameAlias{sortname}{last-first} should be added somewhere in the preamble after biblatex was loaded (put it before \renewcommand*{\nameyeardelim}{\addcomma\space}, for example). – moewe Apr 18 '14 at 13:07
• @moewe - \DeclareNameAlias{sortname}{last-first} is not making references to start from last name. Kindly look into it. – Neeraj Bhanot Apr 18 '14 at 13:33
• @Christoph Done! – moewe Apr 26 '14 at 15:49

You need to specify the sorting option at loading time (you probably want nty: "name-title-year" and nyt: "name-year-title", for more sorting options look at pp. 44 sq. of the biblatex documentation and the sectioned linked from there).

The call to biblatex would then read (with "name-year-title" sorting)

\usepackage[bibstyle=numeric,citestyle=authoryear,backend=bibtex,sorting=nyt]{b‌​iblatex}


To change the name format, go with

\DeclareNameAlias{default}{last-first}


Full MWE

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@BOOK
{KandR,
AUTHOR  = "Kernighan, Brian W. and Ritchie, Dennis M.",
TITLE   = "{The C Programming Language Second Edition}",
PUBLISHER = "Prentice-Hall, Inc.",
YEAR = 1988
}
\end{filecontents*}
\usepackage[bibstyle=numeric,citestyle=authoryear,backend=bibtex,sorting=nyt]{b‌​iblatex}

\defbibenvironment{bibliography}
{\enumerate{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endenumerate}
{\item}

\DeclareNameAlias{default}{last-first}