These recent weeks I have been working on the literature review section of my thesis, and while doing that I’ve been trying to use LaTeX packages to make that experience as easy as possible. I’ll outline some of the things I’ve done here.
Use subfiles
for a modular thesis
The first thing I realised was that my thesis is going to very quickly get unwieldy if it is all contained in one document. I did some research, and I found that the subfiles
package was well suited to my situation.
subfiles
allows you to have separate LaTeX files for different chapters, while allowing you to still compile both the chapters separately, and the whole document. This is great, as while I’m working on the literature review section, for instance, I don’t want to waste my time compiling my whole thesis document when all I care about is one section.
This is the directory structure of my thesis;
honours/
├── cshonours.cls
├── discussion
│ └── discussion.tex
├── introduction
│ └── introduction.tex
├── litreview
│ └── litreview.tex
├── methods
│ └── methods.tex
├── proposal
│ └── proposal.tex
├── references
│ └── primary.bib
├── results
│ └── results.tex
└── thesis
└── thesis.tex
Using subfiles is pretty easy; what it does is copies the header of your “main document” to your subdocuments. I have my main document, thesis/thesis.tex
, which looks similar to this;
and a bunch of subfiles like my literature review chapter, litreview/litreview.tex
, which look like this;
Both documents can be successfully compiled without problems.
Conditional actions with subfiles
One improvement I’ve made over the default subfiles configuration is the use of \newcommand{\mainfile}{}
. This defines a pointless command called \mainfile
if you are compiling thesis.tex
directly. However, because it is in the body of thesis.tex
, not the header, this command will not be defined if you are compiling an individual chapter.
This means we can use the \ifcsdef
function (provided by etoolbox
) to check if \mainfile
is defined, and make things print or not print depending on if the document is being compiled as the whole, or just a part.
The above line prints a copy of the bibliography after the chapter, provided we’re just compiling the chapter on its own. This is useful, as if I’m working on an individual chapter, I still want to see the bibliography for that specific chapter, but if I’m compiling the whole document, I don’t want to see the bibliography after each chapter.
Using the same style file for each subfile
One problem that you run into with subfiles
is that if you have a custom document class file like I do (cshonours.cls
), you can’t write \documentclass{cshonours}
in your main document, or other subfiles will look for the cshonours.cls
file in their own directories, not in the main document’s directory. If LaTeX cannot find the style file there, the compile will fail.
One way to solve this problem is to have a copy of your .cls
file in each subfiles’ directory, but another trickier way to solve it is to also put your main document (in my case thesis/thesis.tex
) in its own subdirectory, and use a relative path that is correct for all subfiles AND the main file; \documentclass{..\cshonours}
. You’ll get a warning message from LaTeX, but it will compile just fine.
Acronyms and abbreviations
If you’re like me and doing a thesis in an area with a lot of tech, chances are you’re going to be using a lot of acronyms and abbreviations to describe things. I’ve found both the acronyms
and abbrevs
packages useful for this.
Here is part of my thesis/thesis.tex
header;
What the \acrodef
does is defines an acronym, which you can then reference with \ac{acroname}
. If you use that, the first time you use it, it will define the whole acronym, and subsequent times, it will just use the acronym. For example;
will produce
We can see that IPv6 over Low power Wireless Personal Area Networks (6LoWPAN) is a good system by which to etc, etc.
6LoWPAN is also good for x, y, z.
The abbreviations package is similar, in that it lets you define more simple abbreviations to map to LaTeX commands, or just text. This is different to using \newcommand
, as it handles spacing a lot better. I use it to define some IEEE standards that I mention a lot, as well as even shorter versions of the acronym commands. This allows me to use this, instead of the above;
which I find very convenient.
fancyref
support for subsections
I also use the fancyref
package for cross-referencing. fancyref
provides a much smarter cross-referencing system that automatically describes the type of thing you’re referencing, and the page it is on.
One thing that fancyref
doesn’t seem to have support for is referencing subsections. If you add these commands to your document header, it should be able to reference them;
These are just some of the things I’ve done to improve my thesis’ LaTeX experience. You can see all of my changes on its repository page.
Noticed a problem with this post? Leave a comment or submit a pull request.