# Bibliography Per Chapter Texmaker Windows

By:

In part 1 of this tutorial, we managed to set up software that helps us creating our thesis with LaTeX. It’s time to get started with the real LaTeX stuff. This is not going to be an introduction to LaTeX as there are plenty of very good LaTeX tutorials; you can easily find them using google. This tutorial is rather a guide on which packages are helpful to be used, how you can organize your files, how to insert graphics, create tables and write algorithms in LaTeX. To understand the commands provided in this tutorial, I strongly recommend doing some general introduction to LaTeX first!

## 1. Folder structure

We start with creating a new folder (our project directory), preferably directly using our cloud service. I use Dropbox and hence create a new folder in my Dropbox folder called Thesis. Within this folder, let’s add some additional folders:

• fig (will contain all figure)
• tex (will contain LaTeX files)
• bib (will contain bibliography files)

2. Creating the main LaTeX document

First, open Texmaker and click New icon to create a new file. Each Latex document has to define a document class, indicating what kind of document we are about to create, this may be a book, a thesis or even a presentation. We are using document class report and define it by writing

\documentclass[a4paper,12pt]{report} \begin{document} Hello World! \end{document}

to the very top of the file. We defined the document to be a report and added some additional parameters. As I am European, I use A4 paper size and a default font size of 12pt. If you prefer using the letter paper size, just replace a4paper with letterpaper. Next, save the document into your projects root directory as Thesis.tex. The directory should now look like

Please note that the little green check mark is indicating that the files are in sync with my Dropbox account.

Now we are going to translate the document by Tools->PDFLaTeX from the top menu or by simply pressing [F6] on the keyboard. If you have activated the messages and log window in Texmaker, you see some output written there. For sure, you will need the outputs later if you note that you have some errors in your LaTeX code and the messages window is presenting shiny red error messages. If we have a look at our project directory, we note that some additional files have been created by LaTeX. Don’t care what they mean at all! The only thing to note is that there is a PDF document called Thesis.pdf which can be displayed directly in Texmaker on the most right column. The PDF view is refreshed by selecting Tools->View PDF from the menu or by clicking [F7]. Doing so, Texmaker shows a PDF file containing only the text Hello World!

Let’s create the main document structure for our thesis. Many universities do provide LaTeX templates, but unfortunately, mine did not. So I created by own structure to be:

• Title page
• Abstract
• Introduction
• Material
• Some real boring stuff for at least 99.9% of people
• Discussion
• Conclusion
• Acknowledgment
• Appendices
• List of Algorithms
• List of Figures
• List of Tables
• Bibliography

Let’s model this structure in our main Thesis.tex file. First we create the table of contents which is easily done by putting the command

\tableofcontents

\chapter{Introduction} \section{Motivation} I was motivated to write a Phd thesis because I did not want to work directly after finishing my study \section{Organization} This thesis is organized as follows, ...

to Introduction.tex and save the file. As you note, we have just created a new chapter containing two sections. All we have to do know is to import the file into our main document. Thus, write

\input{tex/introduction}\newpage\cleardoublepage

Great, we just started creating our document structure. Lets put all the other chapters in there as well

\input{tex/material}\newpage\cleardoublepage \input{tex/boring}\newpage\cleardoublepage \input{tex/discussion}\newpage\cleardoublepage \input{tex/conclusion}\newpage\cleardoublepage \input{tex/acknowledgement}\newpage\cleardoublepage

and don’t forget to create the files, add \chapter{Some Name} and save them. Translate again. By the way, there is a nice trick that you can translate the master document by pressing [F6] even if there is another document open. Just open the Thesis.tex file and click Options->Define Current Document as ‘Master Document’ in Texmaker:

Now, our document is already 7 pages long and contains a table of contents. But I don’t like how the headlines and chapters look like. Thus, I want to change the style of my document and I prefer to use a package called fncychap. The package comes with a bunch of styles where I like Sonny the most. A package is used in LaTeX by calling the \usepackage{} command. In Texmaker, simply write

\usepackage[Sonny]{fncychap}

in the preamble of your document, that is before \begin{document}. The command tells to use the fncychap package with parameter Sonny. If you try to translate, you might note one of the biggest benefits with using Texmaker and MiKTeX. As you are attempting to use a package that is not yet installed, you are asked if MiKTeX should do that for you.

Click install and wait until installation and translation has finished. Updating the PDF will show a newly designed document. Another useful package is loaded by

\usepackage{fullpage}

and leads to the usage more wider page width.

Next we are adding the additional lists to the end of the document:

\listofalgorithms \listoffigures \listoftables

where the list of algorithms needs package

\usepackage{algorithm}

Obviously, the lists are empty for now.

The bibliography is handled a bit different. LaTeX uses so called BibTeX files that contain entries for papers, books and other published stuff. The idea behind is that you have only one big BibTeX file (.bib) with all your publications in it. LaTeX is calling BibTeX with references to the entries using a unique key and BibTeX is creating a file containing only the referenced entries. LaTeX further uses the created file and inserts the entries into the document. Although, it is possible to add several bib files. You can edit the bib files using software or insert entries manually to the bib file. I prefer doing it manually this saves me the time of importing and exporting all the time. Thus, I open the bib file in Notepad++ and copy the references by hand. Let’s create a simply scientific article reference. The BibTeX code might look like

@article{schoen2013, author = {Torsten Schoen and Co Author}, title = {Ten things you better not say to your wife}, journal = {Optimizing Husbands}, volume = {21}, year = {2013}, pages = {85--91}, }

We simply open Notepad++, create a new file, put the code above in there and save it in the Thesis\bib folder by name Literature.bib. Below our lists, we add the bibliography:

\bibliography{bib/Literature}\newpage\cleardoublepage

Further, we have to define a bibliography style in the preamble

\bibliographystyle{plain}

where I prefer the plain style. We can cite entries of the bibliography using the \cite{} command and providing the unique key. For example, write in any of you chapter files:

We refer to Sch\"on \cite{schoen2013} for things you ...

On translating the document, a warning is shown in the message console as the key schoen2013 cannot be found. This is because we have to run BibTeX first by pressing [F11] in Texmaker. Again, as there are references you have to press [F6] and [F11] in turn again and again until the citation finally works. Updating the PDF after persistent pressing of [F6] and [F11] until all warnings disappeared, we can see that a bibliography with one entry has been added at the end of the document and in the text part, \cite{schoen2013} has been replaced with its related number.

A nice source to find papers and get them directly in BibTex format is to search at Google’s scientific search engine called Scholar. If you do a search, you can click on “cite”

and a export citation window appears where you can export the entry as BibTeX code to simply copy and paste it into your bib file.

4. The title page

Next step is to add a title page. Most universities require to use a predefined title page so as my one did. The title page actually consists of two page, the real title page and a page with some formalities. Of course, the title page is nothing else than a normal LaTeX file. Hence, we simply create a new file in our tex folder and name it Title.tex. The only difference is that we should define the title page as title page by inserting:

\begin{titlepage} This is my thesis! \end{titlepage}

Anything that should be part of the title page is written between the tags. Further we have to input the file into Thesis.tex by writing

\input{tex/title}\newpage\thispagestyle{plain}

right after \begin{document}. Next, we gonna add some empty pages between the title, abstract and table of contents and change the numbering to be roman. The real Arabic page numbering of the thesis therefore start just with the first page of the introduction.
This is a bit more complicated and I will simply provide the code without any explanations. The complete Thesis.tex file is hence defined as:

\documentclass[a4paper,12pt]{report} \usepackage[Sonny]{fncychap} \usepackage{fullpage} \usepackage{algorithm} \bibliographystyle{plain} \setcounter{secnumdepth}{3} \setcounter{tocdepth}{3} \pagenumbering{roman} \begin{document} \newcounter{rom} \input{tex/title}\newpage\thispagestyle{plain} \addtocounter{rom}{1}\setcounter{page}{2}~ \newpage\thispagestyle{plain}\setcounter{page}{3} \tableofcontents \newpage\thispagestyle{plain}~ \clearpage \pagenumbering{arabic} \input{tex/introduction}\newpage\cleardoublepage \input{tex/material}\newpage\cleardoublepage \input{tex/boring}\newpage\cleardoublepage \input{tex/discussion}\newpage\cleardoublepage \input{tex/conclusion}\newpage\cleardoublepage \input{tex/acknowledgement}\newpage\cleardoublepage \listofalgorithms \listoffigures \listoftables \bibliography{bib/Literature}\newpage\cleardoublepage \end{document}

This is the end of the second part of this tutorial. You can download related source as zip file here:
TS thesis template Part 2

In the next part, I will give you some useful tips and tricks that helped me a lot:

==> Continue with Part 3

This entry was posted in Latex and tagged BibTeX, Latex, Miktex, Notepad++, TexMaker, Thesis by Torsten. Bookmark the permalink.

Multiplatform, free, and powerful. I could be using these terms to describe Mendeley Desktop, but what I’m going to write in this blog post is about something else, something called LaTeX and BibTeX. For those of you that are unfamiliar with LaTeX, it’s:

a high-quality typesetting system; it includes features designed for the production of technical and scientific documentation.

And now let me introduce you to BibTeX too:

a tool and a file format which are used to describe and process lists of references, mostly in conjunction with LaTeX documents.

Ok, so we’re now acquainted with LaTeX and BibTeX. Let’s see how we can use these tools along with Mendeley Desktop to get you citing and writing your manuscript.

### BibTeX preferences

Go to Mendeley Desktop preferences, select the BibTeX tab. Once there, tick the box labeled “Enable BibTeX syncing” and select one of the options you prefer. I chose the middle one, “Create one BibTeX file per collection”. This generates one .bib file for each folder you create in Mendeley Desktop.

### Autogenerate .bib file(s)

The next step is to create a folder where you will store all the articles or references pertaining to your manuscript. This will generate a .bib folder as per your settings in the preference menu.

Any articles or references added to a given folder are automatically synchronized and changes reflected in the .bib file with the same name as the folders you created. In my example, I have a folder I labeled “Bioinformatics”, therefore Mendeley Desktop automatically generates a Bioinformatics.bib file with all the document details for the references within that folder.

### Citing in LaTeX

Here’s where the cool (and the only complicated) part is: writing your article using LaTeX syntax. There are great resources online to learn LaTeX, such as this one. However, what I really wanted to show you is how to add citations using LaTeX and your automatically generated BibTeX file (.bib).
In the following image, you can see an example LaTeX file (.tex) where I’ve added some dummy text, and in the middle you will see two citations from my .bib file.