A LyX Thesis Layout for UNSW Theses

Stop formatting and start writing!

LyX Logo Since I’ve had my PhD thesis accepted I’ve had a couple of friends who are writing up their theses at CSE ask me for help. In particular, they’ve wanted to know how I used LyX to write and format my thesis. In case anyone else needs a hand, I’ve made the LyX layout files available below, along with some tips and tricks.

LyX and LateX

For the uninitiated, LyX is a front-end for LaTeX, a command-line driven typesetting system that produces beautiful looking documents. The front-end provided by LyX alleviates some of the more arcane and tedious aspects of working with pure LaTeX. You can use LyX without knowing any LaTeX (although you do have to install it) and still get great results.

The LyX GUI lets you write in a manner similar to a word processor, using buttons, menus or key shortcuts to layout and format your text while giving you a preview of what it looks like. When you’re ready to print or submit your work, LyX translates what is on the screen into LaTeX code and then hands it off to the LaTeX system to do all the heavy typesetting, resulting in a beautifully rendered PDF.

I’ve written an undergraduate thesis and several conference papers in pure LaTeX and a PhD using LyX. For me, LyX wins hands down as many LaTeX annoyances such as forgetting to close environments, including figures, managing citations and dealing with tables become much easier in LyX. This results in more time writing and less time tracking down compile bugs.

For a gentle introduction to LyX, I’d recommend having a look at the Structured Writing with LyX article (even though it’s a little out of date) and the Tutorials section of the excellent LyX wiki.

The Layout File

Much of the presentation of your document that is normally configured through LaTeX commands can be managed through LyX layout files. A layout defines the various styles and blocks (such as titles, headings, author details, code, etc.), how they will appear on screen in LyX and how they are to be translated to LaTeX.

This is not a tutorial on writing LyX layouts but if you are curious about how this stuff works a good place to start is Section 5.2 of the Customization document that can be found in LyX’s Help menu.

To make the UNSW thesis layout file easier to use I embedded the LaTeX mark-up commands into the preamble of the LyX layout file. I realise the “correct” way to do this sort of thing is to write a LaTeX class file (e.g., unswthesis.cls) and create a corresponding layout file (e.g., unswthesis.layout) that references its commands. However, I thought it would be easier for LyX and LaTeX newcomers to only have to deal with a single file and not have to worry about fiddling with their LaTeX configuration too much.

Installing the Layout File

Download the following layout file and save it to the layout section LyX configuration directory. This is usually in Library/Application Support/LyX-1.5/layouts/ relative to your home directory.

Now open LyX and select LyX > Reconfigure from the menu. LyX will then ask you to restart. Once this is done the thesis layout should be installed and visible in the Document Class field of window opened via the Document > Settings... menu.

For this layout to work correctly, you will also need an image of the UNSW crest. I found a black and white PDF one that works nicely with this layout. You can download it here:

This file needs to be in the same folder as the LyX document using the thesis layout.

Using the Layout File

Once you have LyX restarted, open a new document and then go to Document > Settings... and then select “UNSW Thesis” from the document class list and hit OK.

This layout has all of the usual styles found in the Book class. Two of them, Author and Title, are used to control what is displayed on your thesis title page. In your new document, add a title using the Title style and put your name underneath in the Author style.

Save the document in the same directory as the unswcrest.pdf file and then turn it into a PDF document via the View > PDF (pdflatex) menu option. If all goes well you should see something like the following:

UNSW Thesis Front Page

Note: As this layout makes use of the graphicx package (found in most LaTeX distributions) and a PDF version of the UNSW crest only the pdflatex view will work.

Templates

It makes sense to split a thesis-sized document into several manageable chunks. This allows you to work on each chunk in isolation, making it easier to zoom around your document and examine the final output without having to build the entire thesis.

I used a separate LyX document for each chapter and appendix and a “main” file to draw them all together when I needed to inspect the entire thesis.

The zip file below has everything you need to get started, including:

  • unswthesis.layout - The layout file described above.
  • unswcrest.pdf - The UNSW crest described above.
  • main.lyx - The main template used to build the whole thesis.
  • chapter.lyx - An example chapter that is included by the main.lyx file.
  • example.bib - An example BibTeX file that is included by the main template.
  • copyright.tex - A LaTeX file that is used by the main.lyx template to add the required copyright statement to the beginning of your thesis.
  • originality.tex - Another LaTeX file that is included by main.lyx and required by UNSW.

You can download the lot here:

Just unzip the directory somewhere convenient and copy the unswthesis.layout file to your LyX directory as described eariler. Then open the main.lyx file with LyX and you should be able to create a PDF from it using View > PDF (pdflatex) straight away. After that, just use the File > New from Template... menu item to open the chapter.lyx document as a template, replace the text with your thesis chapter and save it. To add your chapter to the main.lyx document use the Insert > File > Child Document... menu to add it.

Happy writing!

Caveats

I originally started writing my thesis using LyX 1.3. Since then LyX has gone from strength to strength and is now up to version 1.5. The files here have all been adapted and improved from the LyX 1.3 versions I originally used and tested using LyX 1.5.1.

I’ve also only tried this on the Mac version of LyX 1.5 using teTeX as the LaTeX system under the hood, though there’s no reason things shouldn’t work with something like MacTeX instead. The only thing I’m not too sure about is whether there are any packages that I use in this layout that don’t come with a standard LaTeX distribution. Let me know if you have any problems.

Also, the format of the title page, margins, declarations, and so on met the submission guidelines for UNSW as of July 2006. You may want to check if they’re still valid. If not, a quick poke around in the files and it should be apparent where to make any changes.

Acknowledgements

Most of the code for formatting the thesis title page comes from a LaTeX class file I found on CTAN as does the formatting for the copyright.tex and originality.tex files. Thanks to Stephen Harker for making these available.

The LyX image in this post is thanks to the LyX page at the Linux Guiden wiki.

34 comments

Nick
13:06, 10/09/2007
hey Mark,

Massive thanks for this. I tried the test files and all work seamlessly for me (Lyx 1.5, and I don’t actually know which tex/latex installation I’m using – I think it’s gwTeX from either the i-Installer or MacTeX).

I haven’t tried it on my actual thesis documents yet, and at the moment I’m hesitant because I quite like some of the layout from the default book class that seems to be different in your layout (eg the font, the TOC style).

So, I’d really like to know either: (1) how easy is it to just add the copyright.tex and originality.tex to the book class as-is, or (2) how easy is it to modify the unswthesis.layout to change fonts and some layout to my own tastes?

Maybe this is where I need to look into the Customization document you mentioned?

I’m in no massive rush to do this yet, as I still have many words to write before I indulge in layout modification procrastination!
13:20, 10/09/2007
Both of those options are pretty straight-forward.

For option 1, you can just do an “Insert > Child Document…”, choose “Input” from the list of Include Types and then include the copyright.tex file.

For option 2, you can control most of the fonts and TOC settings from inside LYX. In the “Document > Settings…” window you can mess with the fonts using the lists in the “Fonts” section and the amount of information in the TOC through the controls in the “Numbering & TOC” section.

As most of the commands in the unswthesis.layout file are copied from the AMS Book style they should also be similar to the standard Book layout.

Good to know that it works on someone else’s machine!
23:21, 16/11/2007
Hey,

Just a few comments and questions. First, thanks! this is working great for me (i’m also using a mac). Second, a tip for others – I wanted to have an appendix section but found it a bit difficult to layout correctly. I figured out that I could insert a LaTeX command after the bibliography (”appendix”) and it would start treating files based on the chapter template as appendices. Third, a question, when trying to navigate the whole document in Lyx it lists out all the sections correctly, but doesn’t include the “chapter” titles which makes it a bit confusing to know when each chapter starts/ends. Also, I wanted to try and have another level deeper show in the table of contents and wasn’t sure how to do that. Any suggestions?

Thanks!
14:44, 22/11/2007
Hi Ryan, thanks for the comments.

Regarding the appendix, you can achieve the same effect by selecting `Documents > Start Appendix Here` from LyX’s menu while your cursor is placed somewhere after the bibliography.

I’m not sure how to address the content navigation issue but displaying deeper levels in the table of contents can be done using the `Document > Settings… > Numbering & TOC` dialog. There’ more detail in section 3.3.4 of the LyX User Guide in the `Help` menu.
18:02, 29/03/2008
I’m back and getting close to finishing – but I’m having problems adding the abstract and some acknowledgments. I’ve tried specifying the abstract style and some of the others like “dedicatory” and “thanks” but those don’t seem to work either.

Unrelated – but I also had issue with any of the styles for definitions, algorithm, etc – so i just didn’t use them, but might make sense to remove those styles if they don’t work.
wessam
10:43, 07/04/2008
Trying to open the main.lyx under Lyx 1.5.4 (using MikTex on Vista) fails for some reason “undefined control error” – 1.5.3 works fine though.

Also, if you’re a complete newbie – you can quickly edit the layouts and tex files in OpenOffice 2.4.
wessam
20:50, 10/04/2008
If someone gets an undefined control error upon viewing the main.lyx, this prob means you dont have all the latex pkgs installed – Ubuntu 7.10 users install texlive-latex-extra & texlive-latex-recommended pkgs, win users make sure you do a complete install. Don’t forget to reconfig and restrt lyx.
Brett
19:47, 18/04/2008
I’m writing my undergrad thesis at unsw in Latex, do you know what bibliography package and style I should use to get something like [sch04] appearing in text, with the bibliography appearing like that in this sample thesis? http://www.cse.unsw.edu.au/export/sites/..
jont
06:34, 25/04/2008
I had the undefined control error with 1.5.4 on Windows.
changing newpage% to newpage in the layout file got rid of the error and allowed me to render the file. Not sure (yet) what side effects that may generate :-) Anyone any thoughts?
jont
07:16, 25/04/2008
ooops, it was not that! but commenting out the graphics line that gave me the workround.
abe
20:23, 27/05/2008
Hi Mark,
just gotta say thank you for the work. It just make life so much easier without need to worry about formatting!

got some questions also, is there anyway I could easily modify the section style? I was trying to modify the Align/AlignPossible attributes, but looks like it only changes how lyx display the section title, but not the final pdf.

  1. Redefine some of the section styles.


Style Section
Align Left (wanna align left)

and is there any way to put a horizontal line on top of each page, below the page no, and above all the text? not very sure what style it is called!

Cheers
19:06, 28/05/2008
Hi abe, glad you are making use of it.

There are essentially two parts to the `unsw.layout` file: the “preamble” which contains all the LaTeX commands that determine how the PDF will look, and the “LyX layout” which matches LyX environments and commands to LaTeX environments and commands.

If you only modify the LyX layout part you will only change how the document is display within LyX. To get the changes you want in the PDF you will have to figure out want the appropriate LaTeX commands are.

I can’t really help much since I copied the LaTeX commands in the “preamble” section of `unswthesis.layout` from a LaTeX UNSW thesis class I found on CTAN (details are in the post). You’ll have to poke around in the “preamble” section, consult Google, a TeXpert or a good book on LaTeX to figure out how to make the changes you want. I’m not enough of an expert to help without doing that kind of research myself. Sorry!
Abe
13:54, 16/07/2008
Hi Mark,
thanks for your explanation :-)

I’ve found that for the second question about putting a line on top of each page, it could be easily done by changing the headings style to “fancy” under Document->Settings->Page Layout… in case someone is looking for it. I’ve read from the mailing list that you could further customize what you want in the headers by using preambles like:
lhead{Text on the left top}
rhead{Text you want on the right top}
chead{Text you want over the center}
lfoot{left footer}
rfoot{right footer}
cfoot{center footer}

By the way, would you by any chance know what’s the best way of putting another extra abstract page before the TOC, and possibly another Acknowledgment page at the end?
Cheers
wessam
14:49, 21/07/2008
Hi Abe,

Easiest way to add another abstract would be to create a new lyx doc with the UNSW thesis doc class and select Chapter* for the heading type.

Then in main.lyx include the new lyx doc as a child doc before the TOC.
Abe
00:07, 25/07/2008
wessam, thanks for the hint. It looks like the inclusion of an abstract is working. I include a lyx document as child document right after the frontmatter before the TOC. It will appear in the TOC as the first entry with page number in roman style.

However, I still cant’ figure out how to get anything after the mainmatter. I tried to put in an extra ERT, “backmatter”, but still, conventional Arabic page number are still used in all the bibliography and appendix
Edward
06:22, 25/07/2008
Hi, Mark, thanks for the great efforts. I’m also trying to write my thesis using Lyx. Do you mind if I customize your layout and template files and make them publicly available to other students in my school (University of Southern California)?
09:43, 25/07/2008
Hi Edward,

I’m more than happy for you (or anyone) to customise my layout. My layout was only possible due to the work made freely available by others so I have no problem with people building upon my work.

If you put your your modifications up on the web somewhere all I ask is that you link back to this page with an acknowledgement.
12:58, 25/07/2008
@Abe – I had the same thought/issue. The way around it is to use the appendix mark before whatever sections you want to have numbered differently. You can do this using the lyx menu or by using ert appendix (I think)

Another tip I’ve found – I have been keeping my thesis in svn, and my supervisor wanted some formatting changes so I found it easiest to actually move most/all of the formatting stuff into a new file, then simply include that file in the preamble. This helped me to keep changes to the main file separate from formatting changes.
wessam
18:43, 04/10/2008
On a side note, i’ve found it easiest to manage my bibliography using Jabref. If you get stuck with character encoder try file -> database properties.
Satu
11:30, 02/12/2008
Hi Mark,

that’s some great work you’ve done there!

Just one comment – I’m not exactly a LaTeX guru myself, but I think there is a statement missing in unswthesis.layout. It might not affect the functionality of the script at all times, but when I use Lyx 1.5.5 on Mac, I have to add one line to the .layout file, or the PDF creation will fail (see below).

Cheers,
Satu

\ifnum\month=12
\@tempcnta=\year \advance\@tempcnta by 1
\edef\@copyrightyear{\number\the\@tempcnta}
\else
\newcommand{\@copyrightyear}{\number\the\year}
%ADD THE FOLLOWING LINE
\fi
21:39, 02/12/2008
Satu, your timing is perfect!

Yesterday, less than 12 hrs before your comment, I was having this exact problem which caused an error: “an empty output file was created” when trying to produce a PDF from these files and unswthesis.layout on LyX version 1.5.6 on Mac OSX 10.5.5.

Your solution fixed the problem after doing another Lyx Reconfigure.

As for me, I am finally at the stage of being able to indulge in layout modification procrastination! (well apart from a list of minor fixes and edits to make)

cheers,
Nick
Antonio
03:22, 16/12/2008
I have a stupid but important question. I’m preparing my pdh Tesis and i want to write it in Lyx. I thik this template is interesting, but pdf creation doesn’t work. When I press pdf button, it sais:

File does not exist: /tmp/lyx_tmpdir.JL1313/lyx_tmpbuf0/newfile1.pdf

Maybe is the same problem. But I dont knoww how edit the .layout file. When I edit unswthesis.layout with the Texshop editor, and save it into the Layouts folder, I cant select this layout in Document-settings-documentclass.

¿How do you edit it? ¿where do you insert the code?

Thanks
Asad
19:49, 21/12/2008
I am having the same problem as Antonio. Totally new to Latex and lyx so dont know much about it.
Ck
16:38, 25/12/2008
Hi, I’m having the same problem with Lyx and this layout being unable to create output files. Other layouts work ok. Have tried adding the /fi line to no avail. Hope you can help us out soon!
19:26, 25/12/2008
Hi everyone.

Just a quick note to let you know that I’ll look into the problems you are having with the layout in the new year.

Keep in mind that I wrote the layout for my own purposes which was to finalize my PhD a couple of year ago using LyX 1.3. Things have changed with LyX since then so there’s no guarantee that what worked then will work now even though I tested them on LyX 1.5. Caveat emptor and all that.

Merry Christmas!
Ck
12:48, 26/12/2008
Thanks for getting back to us Mark =) Really appreciate that you’ll take a look at it and will look forward to any updates…

Merry Christmas
13:20, 17/02/2009
I finally got some free time to have a look at the problems some of you are having with the `unswthesis.layout`. Unfortunately for those having problems, I cannot reproduce the errors you are getting.

I am using LyX 1.6 for Mac OS 10.5 and the LaTeX I am using is pdflatex from the TexLive-2007 distribution.

I followed the instructions that I wrote above. That is, I downloaded the zip file, placed `unswthesis.layout` into `~/Library/Application Support/LyX-1.6/layouts/` then opened `main.lyx` using LyX and selected `View > PDF (pdflatex)` from the menu. I got no errors and a PDF of the document appeared, correctly formatted, in Preview.

I do not have time to try all the permutations of LyX versions, OSes, TeX distributions, etc so I will rely on others posting here to clearly describe the problems they are having and the systems they are using in the hope that someone else can solve them.

I’m happy if people fork the layout I’ve created here, modify it, get it working for their own set up and then post here a link to their working version.
jose luis
15:15, 09/03/2009
hello, I am from Colombia and I am trying to port your layout to Spanish, that is, i try to replace the words in this as chapter by capitulo(chapter in Spanish) but i get troubles(seems that Latex wait the chapter instead capitulo and throw LaTeX Error: No counter ‘?’ defined in numberwithin{section}{Capitulo} ) , you can help me with something idea about how to modify this, thanks in advance.
peter toth
20:39, 02/04/2009
Hello, I’ve also tried to use your example, but it doesn’t work for me either. If I try to generate pdf from main.lyx, it fails due to can not determine size of graphics. If I just apply the layout onto a new document it fails with the following:
“ The control sequence at the end of the top line
of your error message was never def’ed. If you have
misspelled it (e.g., `hobx’), type `I’ and the correct
spelling (e.g., `Ihbox’). Otherwise just continue,
and I’ll forget about whatever was undefined.”
It gives the same error if I comment out the whole part for making a title in the layout file.
Do you have any idea what can be the problem ?
peter toth
20:41, 02/04/2009
by the way, I’m using Lyx 1.6.1 and winxp.
Kam Fung
07:19, 27/04/2009
Hi Mark,

Just wondering how abstract is inserted. I had a look at your thesis, and it contains an Abstract page. However, it doesn’t show up on my dvi so far. I had a look at the Lyx documentation, and it stated that the Book class ignores Abstract.

Still investigating…
Dude
11:34, 19/05/2009
Has anybody figured out what needs to go in the preamble to make the headings left aligned?

Also how to add dots between titles and page numbers in the TOC?
17:21, 19/05/2009
Sorry I can’t be of more help but I believe most of the questions being asked here are LaTeX questions, not LyX questions, and I am not really an expert in either.

As I pointed out in the post, I built the LyX template from a LaTeX class file I found. If you want to know how to modify the layout of the final PDF you will have to modify the class file. Also, I suspect some of the errors people are encountering are due to variations in the TeX package they have installed.

I don’t have the requisite LaTeX skills to solve these problems so you will be best served by asking a LaTeX forum for help.
Frank
23:03, 09/09/2009
Hi Mark,
Thanks for the great template. It’s working quite well after a few little hitches but I can’t seem to get the Contents to list levels below Sections (i want to list subsections at least). I have tried changing the Document Settings>Numbering and TOC. This seems to be active as reducing levels works.
I have also looked through the layout file for conflicts but don’t see any problems there.
I am on OS X 10.5.6, Lyx 1.6.0

Thanks again

Leave a new comment

  
Remember personal info?

/ Textile
  (Register your username / Log in)

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.

About This Entry

Other Entries

Archives