Lyx Bibliography Sample

I am just in the process of finishing writing my PhD, which I wrote entirely in LyX. The productivity advantages of using LyX over LaTeX are too large to ignore, which is why I went with LyX, and why you should too. In this post I will go over the process I went through to get LyX producing documents conforming with my university’s thesis formatting guidelines.

If your anything like me, you have a mixture of past papers you have written in LaTeX, as well as a bunch of notes and drafts in LyX. The university provides a thesis template in LaTeX which the recommend you use. Fortunately, it is actually not too difficult to convert such a template into a working LyX document. Likewise, the papers in LaTeX can also be imported into LyX.

My LyX thesis template is available for download here: template-thesis.zip. The source code is also on github at https://github.com/adefazio/lyx-thesis-template.

Creating a preamble

We will get LyX to format our document correctly using the thesis style by overriding most things using a preamble file containing TeX commands. The advantage of this approach is we can pretty much copy and paste the LaTeX from the thesis template provided by the university.

I used two preamble files. The primary file contains the usual TeX package statements, includes and the like. It points to the ANU thesis style file as well:

This is not exactly the same as the preamble in the ANU provided style files. Several packages are already automatically imported by LyX, so they don’t need to be included here.

The default style uses the traditional American indenting of the first line of each paragraph. I think that looks old-fashioned, so I change it to just put a little but more padding between paragraphs instead:

The second file I use is main-preamble.tex, which contains the title and author information:

Setting up chapters as child documents

You probably want to setup your thesis so that each chapter is in a separate document. In LaTeX you would have each chapter imported into your main TeX file using \input{}. In LyX, this is done using child documents. As an example, the main document for my thesis looks like the following:

Setting up the main document

Create a new document, and go to Document->Settings->LaTeX Preamble, put in the preamble files we created above:

Each of the child documents is included via Insert->File->LyX Document ... The “include type” needs to be set to “include” for it to work correctly. The \mainmatter command signifies the switch over from page numbering using Roman numerals (for the introductory material) to Arabic numerals (for the thesis proper). It is inserted using the “TeX Code” insertion (Ctrl-L), which just directly inserts LaTeX commands into the document.

The Append is started with Document->Start Appendix Here, which should probably be in the insert menu of LyX instead. The bibliography is created with Insert->List/TOC->BibTex bibliography.., which lets you select a BibTex .bib file to use for your citations. LyX supports using multiple different bib files, which would appear useful if your combining multiple papers you have written into a thesis. A word of caution: if there are repeated entries between the bib files you will run into various hard to debug problems in LyX, especially if the entries only differ in capitalisation. I would suggest taking all the bib files and merging them using a command line tool into one file. I used the command:

LyX obeys most of the styling information specified by the preamble we created above. However, there are a few things that it overrides. Follow steps 3-7 from the next section to fix these up.

Setting up the child documents

In my case I put each child document in it’s own folder. This is not necessary, but it seemed like a good idea to keep the child documents in a folder together with any figures used by that document. I will walk through the creation of a single child document here. I created all the chapters initially by just copying the first one I created, but you could do it in a more organised way using LyX templates. The steps for creating the chapter are:

  1. Create a new empty LyX document and save it to a folder with the chapter within your thesis directory.
  2. Add the document to your main document using the include procedure described above.
  3. Open up the settings of the chapter document, and set the document class to Book, and in the master document field, point it at your main.lyx document
  4. On the font section, change the default family base font size to what ever your university requires. This was different than the default for me.
  5. Tick the Two-sided document check-box under Page Layout. This sets it so that the margin is wider on the outside-edge of each page, so it looks right when bound as a book.
  6. On the Language section, change it to English (Australian) or English (UK) if your not in the ’ol US of A.
  7. Your university almost certain specifies a particular citation style. Specify that in the Bibliography section. My university (ANU) recommends a Author-year style:
  8. In the LaTeX Preamble, add the command , which just points to the previously created preamble file. The main-preamble file is not used by the child documents.
  9. If your using sub-folders for each chapter, place a copy of the thesis.sty and (for ANU) the anuthesis.sty files in the subfolder as well.
The above setup will mean that you can view each chapter separately in LyX using the eye button in the toolbar. The chapter can be viewed within the whole-thesis PDF using the button. When viewing separately, the bibliography references will display as question marks (?), whereas they will be displayed correctly in the whole-thesis PDF. There are some suggested work-arounds for this issue on on the LyX Wiki, but I couldn’t get them to work.

Other productivity enhancements

There is a few additional setup steps you should go through in LyX if you haven’t already. These are not required, but they will generally increase your productivity.

  • Setup Forward and Reverse Search
  • Setup groups of chapters as LyX branches to make sending subsets of your thesis easier
  • Setup math macros
  • Add keyboard shortcuts for citations and cross-references.
​ \usepackage{svn-multi} \svnid{$Id$} \usepackage[hyperindex=true, bookmarks=true, colorlinks=false, pdfborder=0, pagebackref=false, citecolor=blue, plainpages=false, pdfpagelabels, pagebackref=true, hyperfootnotes=false]{hyperref} \usepackage[all]{hypcap} \usepackage[palatino]{anuthesis} \usepackage{afterpage} \usepackage{graphicx} \usepackage{thesis} \usepackage[normalem]{ulem} \usepackage[table]{xcolor} \usepackage{makeidx} \usepackage{cleveref} \usepackage[centerlast]{caption} \usepackage{float} \urlstyle{sf} \renewcommand{\sfdefault}{uop} \usepackage[T1]{fontenc} \usepackage[scaled]{beramono} \usepackage{pifont} \usepackage{rotating} \usepackage{algorithmic} ​ \usepackage{multirow} ​ %%%% Old macros file includes \usepackage{booktabs} \usepackage{relsize} \usepackage{xspace} \usepackage{subfig} \usepackage{listings} %%%%%%%%
\setlength{\parindent}{0cm} \setlength{\parskip}{4mm plus2mm minus3mm}
\makeatletter \AtBeginDocument{ \hypersetup{ pdftitle = {\@title}, pdfauthor = {\@author} } } \makeatother ​ \title{Advances in stuff} \author{John Smith} \date{\today} ​ \renewcommand{\thepage}{\roman{page}}
\input{general-preamble} \input{main-preamble}
bibtool -s -d *.bib > all.bib

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 could be:

To use this in your document there are two approaches: (1) traditional ; (2) modern .

Bibtex approach

Choose a style for the bibliography via . Choose the database file and print the bibliography via . As you seem to want your authors listed as then one choice is the style, which requires the package; pass the option to this package to get numerical citations.

Compile as

to get

Read more at bibtex on CTAN

Biblatex approach

Load the package , with for numerical citations. To get Lastname, Firstname in the bibilography use the command . Point to your database via . Put at the place in you file you want the bibliography to appear.

Compile with

to get

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

0 thoughts on “Lyx Bibliography Sample

Leave a Reply

Your email address will not be published. Required fields are marked *