I'm not sure if you consider this an appropriate answer, as your question is »how do I make natbib
work«, and my answer involves abandoning it for something more contemporary (there haven't been any updates to natbib
whatsoever for a few years). But then again, your ultimate aim is »using the harvard referencing system« -- and this is something quite easily done with biblatex,
out of the box. So what I'm suggesting is a slightly different tool for that purpose...
Consider the following example and its output. Note I've used the more suitable @online
field rather than @book
.
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents,hyperref}
\usepackage[style=authoryear,backend=biber]{biblatex}
\begin{filecontents}{bibtest.bib}
@online{aardvark2013china,
author = {Aardvark, T.},
title = {China Bans It's Airlines From Taking Part In {EU} Emissions Trading Scheme},
year = {2013},
url = {http://toryaardvark.com/2012/02/06/china-bans-etc/},
urldate = {2013-03-10}
}
@article{aef2013org,
author = {AEF},
title = {Some Title},
journal = {Some Journal},
volume = {10},
number = {3},
year = {2013},
url = {http://www.aef.org.uk/?p=803}
}
\end{filecontents}
\bibliography{bibtest}
\begin{document}
AEF have been doing so and so \parencite{aef2013org}. But \textcite{aardvark2013china} have been etc.
\printbibliography
\end{document}
So, my suggestion is: let's work from there; let us know if that looks like something you're roughly comfortable with, and what details you want changed. If, for example, you prefer »available at« to »URL«, or »accessed« to »visited«, if you want every online article to be marked with an »[online]« in addition to the URL, if you want purple journal titles instead of italic ones -- all of this is really simple in biblatex
, plus, as mentioned earlier, it's going to be a lot easier to get help if you need it.
If I understand you correctly, you can do this with biblatex
, which is a quite new LaTeX package for dealing with bibliographies. As LyX hasn't built in support for this in the GUI yet, there is some initial setup required. The information in this answer comes from two sources:
The LyX wiki: http://wiki.lyx.org/BibTeX/Biblatex
Sorting the bibliography by entry type
Setting up LyX for biblatex
You have to install a biblatex
module, which is can be downloaded at http://wiki.lyx.org/uploads/BibTeX/biblatex.module Place the biblatex.module
file in the layouts folder in the LyX user directory, the location of which is listed in Help --> About LyX. Reconfigure and restart LyX.
Change document settings
Go to Document --> Settings, and do the following:
Under Modules, add the Biblatex-citation-styles module.
Under Bibliography, change
Processor to biber
Citation to Natbib, and Natbib style to Author-year
Under LaTeX Preamble, add the following:
\usepackage[style=authoryear, natbib=true]{biblatex}
\addbibresource{path/to/your/bibfile.bib}
of course changing the path to the bib-file. I think you need the complete path, and the file ending must be included.
In the document
To be able to use the LyX GUI to add citations, you have to trick LyX to search that file by first adding a LyX Note with Insert --> Note --> LyX Note, and then do Insert --> List/ToC --> BibTeX bibliography with the cursor inside the note.
Add an unnumbered (or numbered, depending on requirements) chapter (or section, if you're using an article-class) heading, called Bibliography or References, or whatever you like. Then you have to add something like
\printbibliography[type=book,title={Books},heading=subbibliography]
\printbibliography[type=article,title={Articles},heading=subbibliography]
\printbibliography[nottype=book,nottype=article,title={Miscellaneous},heading=subbibliography]
in an ERT (Insert --> TeX Code, or Ctrl + L) where you want to print the reference lists. Note the type=<reference type>
, which defines that the reference list printed there has only one type of source, and the title=Something
that changes the heading of the reference list. You have to add one \printbibliography
for each type of source.
heading=subbibliography
causes the heading to be typeset with a heading that is one level below the highest level. That is, section for book or report classes (where chapter is the highest), or subsection for article classes (where section is the highest).
In the last one nottype
is used instead, which prints everything that does not have the specified entry type. Note there is one such for article, one for book.
Image example. Here I added three citations from biblatex-examples.bib
, one book, one article, and one something else:
Best Answer
If you're writing the bibliography yourself, then you need to add a label for each item. Right click the grey box in the reference list where the citation key is written - highlighted by the red ellipse in the screenshot below - and choose Settings (the only option).
In the Label field write
authorname(year)
without a space before the parenthesis, e.g.Author(2012)
. Quoting thenatbib
manual:oneself, such that it conforms to natbib.