## UBC thesis under LyX; manuscript-based thesis under LaTeX

A year ago when I finished my dissertation at UBC I posted a complete set of LaTeX files for generating a manuscript-based thesis (bibliographies separate for each chapter, etc) in which each chapter is a separate file in LaTeX. (This is useful for being able to compile each chapter into its paper form from the same file.) [Update: 2011: I believe UBC has recently eliminated the manuscript-based thesis option]

But I had given up on the hope of writing the whole dissertation in LyX. I am now posting a (trivial) LyX layout file that can be used with Michael McNeil Forbes’ ubcthesis class to write your entire dissertation/thesis in LyX, rather than LaTeX source code.

So, at least if you are not doing a manuscript-based thesis, you can write it all in LyX. This is all you need:

Download and unzip my ubcthesislyx.zip [Updated May 2013].  In the resulting folder you can, if you wish, update the  ubcthesis.cls and genthesis.cls and the other files (linked from the UBC grad studies page).  In any case, you can now just launch ubcsamplelyx.lyx in LyX and bingo! You can see the resulting sample PDF.

The trick here is that most of the extra defined stuff for ubcthesis is not dealt with in the .layout file, and therefore by LyX. Instead, most of these definitions come in the LaTeX preamble and are kept for simplicity in the LyX preamble. So visit Document-Settings-Preamble within LyX to change all the front matter settings.

Let me know if you make use of it (or make improvements), please.

This entry was posted in software and tagged , , , , . Bookmark the permalink.

### 44 Responses to UBC thesis under LyX; manuscript-based thesis under LaTeX

1. VR says:

Hi there,

I did as you said and replaced genthesis.cls, ubcthesis.cls and the sample.bib files. Upon replacing and trying to render a PDF or DVI with just the default data, I get a latex stack error.

Any idea why?

Thanks!

Varun

2. cpbl says:

Hi VR. Have you had luck with this? It seems to compile fine for me (I’m using GNU/Linux, but it shouldn’t make any difference). I’ve updated the files and fixed one bug (duplicate bibstyle). If you make any progress/improvements, please contribute them…

3. AW says:

I am having the same difficulty as VR (although I did not replace any files).

Lyx report:

Error:
TeX capacity exceeded, sorry [input stack size=5000].

Description:
\begin{thebibliography}{1}

If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

—–

Running OS X. Thank you for your support.

• cpbl says:

Sorry — it seems odd that there’s something in there not working on Mac which works on GNU. Michael Forbes is running Mac, so maybe we will sort it out. His plan now is to house the LyX and LaTeX versions in one distribution, to simplify things. Feel free to help figure out what’s going on (e.g. try removing the bibliography or etc? look up any special setup or problems for LyX on Mac). But this was all meant to provide a turnkey solution…

Update: Michael says “remove dependence on babel in LyX setup” seems to work.
So.. maybe try: Tools->Preferences->language-> then uncheck the “use babel” box.

[Update: 2010 Sept: links in post updated. Should work flawlessly.]

4. Nathalie says:

Hi,
thank you for your template, but it does not resolve my problem!
I’m writing my PhD thesis and after about 3000 words, I cannot compile LyX to get the pdf version.
Here is my error message from LyX :
TeX capacity exceeded, sorry [input stack size=5000].
If you really absolutely need more capacity, you can ask a wizard to enlarge me.

Here is my preambule:
% * * * * * * * * * * * définition des marges % supprime les hoffsets \setlength{\hoffset}{-1in} \setlength{\voffset}{-1in}


%pr mettre section avec autre police \titleformat*{\section}{\fontfamily{pzc}\selectfont\bfseries\LARGE} 

• cpbl says:

Bonjour Nathalie,

I think you can overcome this easily, as I think it’s a standard LaTeX catch, not a LyX problem (to the extent that that makes any sense). You have done something “wrong”, and likely in your lower-level latex code rather than what LyX lets you do. Just google on the error
or post your question to a latex forum (google groups, for instance). (for instance, see http://www.phys.washington.edu/users/mforbes/projects/ubcthesis/lyx/ for some examples of mistakes people have made to cause this error.)

You can google for standard ways of debugging your .tex code too, like cutting out parts of your file to find out where the offending mistake is…

Good luck!

5. cpbl says:

By the way, there’s no need, especially, to start out with all the front matter and thesis-specific stuff when you’re writing your chapters. If you’re early on in the process, I’d recommend using the “book” class within LyX to begin writing, using bibliographic references, cross-references, etc. It should be relatively easy to switch over to the thesis class later when you’re getting close.

6. Stefan says:

Hey guys,

i download the Lyx-file for my master thesis. I got the error message, that the ubcthesis.cls is not available to Lyx. So i download it but i really don’t know what to do with this file – means where to put and what to do. I use a mac with MacTex framework.

can anybody help?
Stefan

• cpbl says:

The answer lies with MacTeX. I should think a quick Google will find the answer. Please post it (or confirm my guess, below), when you find what works.

I think class files belong in
~/Library/texmf/latex/
on a Mac.

But you might have to run “texhash” on the command line to update the database after adding the .cls file?. Maybe.

• Dale says:

To add to Chris’s post in case anyone else is having this trouble, I’ve just — with some gracious help — started to get sorted out for writing in Lyx/Latex. I managed to compile Christina’s .lyx code by following these steps (my installation is MacTex on a Macbook running OS 10.7.4):

(1) I put the ubcthesis.cls file into MacbookProHD/usr/local/texlive/texmf-local/tex. This folder wasn’t visible to start so I had to switch Finder to show all files. Instructions here: http://www.macworld.com/article/1051830/showallfinder.html
(2) I put Chris’s .layout file into MacbookProHD/Users/[username]/Library/Application Support/LyX-2.0.
(3) Run texhash as root, i.e., open terminal, type “sudo bash”, enter your password, and then type “texhash”.
(4) Reconfigure Lyx, an option in the Lyx menu (next to the apple menu), and restart Lyx.

This was all I had to do. I may discover other glitches as I write my own thesis (e.g., around bibtex) but Christina’s code worked well enough. I’ll endeavour to post here from time to time if I come across anything else that I think may be useful.

• cpbl says:

Well done. I suspect you could have put your .cls into your on texmf, rather than the system/root one, MacbookProHD/Users/[username]/Library/texmf/tex and then run texhash as yourself, rather than as root.

• Dale says:

Right you are, and from what I understand installing in the user rather than the system folder is better practice. So I made the switch and all works equally fine. Thanks for pointing this out.

7. Lili says:

Hi,

My thesis compiled ok but when I submitted it to FOGS they said that the Abstract should go in page ii and I am obtaining some blank pages all around. How can I solve this?

• Christina says:

Perhaps you solved this? Have you selected single or double sided thesis? Double-sided will produce blank pages.

8. fongchunchan says:

Any idea how to change the name of the “Contents” to “Table of Contents” to fit UBC FoGS guidelines. I tried:

But it didn’t work. Thanks

• cpbl says:

Close, not quite.

• fongchunchan says:

Thanks for the reply. But unfortunately it still doesn’t work. I don’t get why I can’t change the fixed string to Table of Contents. Seem so bizarre…

• fongchunchan says:

I figured it out. Has to do with the babel package that gets used somewhere in the tex document. This link has more information. I solved it by including the following lines in the preamble:

\usepackage[english]{babel}

Hope that helps anyone else who has this same problem.

• fongchunchan says:

Oppos forgot to finish the code:

\usepackage[english]{babel}

9. Christina says:

• fongchunchan says:

I just used the ubcsamplelyx.lyx file that is provided in the ubcthesislyx.zip package. The TOC “box” was already added. If you compile that straight up into a pdf, then it should say ‘Contents’ as the header from the TOC section.

• Christina says:

Speaking of TOCs…I’m having trouble getting LyX to treat my Nomenclature (List of Acronyms) properly. Two things: 1) In the TOC the List of Acronyms has the wrong page number – instead of the start page, LyX has listed the finish page (should be ix, says xi); 2) It is adding “List of Figures” as a fancy header on the 2nd page of the List of Acronyms – even though I’ve typed ERT “\thispagestyle{empty}” — this ERT has worked everywhere else in the document that I’ve used it. Any ideas?

10. Christina says:

Update: problem solved. Choose “phd, oneside, intoc” in the LaTeX preamble. Also, you can eliminate the ERT [\addcontentsline{toc}{chapter}] in the front matter (Acknowledgments, Preface, etc) by making those “Chapters” instead of “Chapters*”. Your First Chapter of mainmatter may appear to be Chapter 3 or 4 or 5 (depending on how many frontmatter sections you have) but LaTeX will suppress the frontmatter chapters, so that Chapter 1 – Introduction – will be Chapter 1. And the need for ERT to suppress page styles is also eliminated.

11. Arminta says:

I can’t get the greek letters to show up in my math equations. When I copy the equations into a new LyX file and view it as a DVI the greek letters are there but when I put the equations into the ubc thesis the greek letter don’t show up. Any ideas?
Thanks.

• Arminta says:

It seems to export to a ps2pdf fine (all the greek letters are correct). Not sure why the DVI has problems but as long as I can get a correct pdf, I don’t really care.

12. Arminta says:

How do you get the appendicies to show up as “Appendix A” vs. just “A” in the TOC?
Thanks

13. Christina says:

Hi
Assume you are using LyX. If so you need to insert – from the toolbar- an appendix section (much like you choose to insert a biblio). I don’t have access to LyX right now, but going from memory I think that works. If not then you may need ERT to add to the toc that labels the entry {Appendix A}. See code in earlier comment.
Let us know how it goes.

• Arminta says:

Yes, I am using LyX. I have an Appendix in Lyx, that’s not the problem. What happens is that the TOC lists the chapters by numbers (ie. 1 Introduction) then it put “Bibliography” then the appendicies (A Calculations, B Operating Procedure, C …, ect). What I’m looking for is either a title before the appendices (“Appendices” with nothing else on that line) or to list the appendices as “Appendix A Calculations” vs “A Calculations”.
Thanks.

• Christina says:

Ok. Did You try inserting the ERT at each appendix?
Sorry I cannot give better instructions right now. Maybe someone else has LyX available and can comment. If it is still a problem after the weekend I’ll try to help out then once I’m back in front of my computer.

• Arminta says:

I don’t sure which code you are talking about. Can you point me to the right post?
Thanks.

• Christina says:

Hi,
Check my post from January – add contents TOC and see if that gets you anywhere. Full instructions not in that post but best I can do right now.

14. Hi Prof. Christopher,
I get the following message when I compile to pdf:
! Package hyperref Error: Wrong DVI mode driver option `hypertex’,

Whereas when I used the file ubcsamplelyx-auto.lyx I don’t get this message. If there a difference between the two files?
Also, how can I change the front page? Thanks in advance.

• Arminta says:

You can change the front page by going to Document -> Settings -> LaTeX Preamble in LaTex. That shows you the code and it should be well enough documented so you can figure out what to change.

I could only get mine to export as a “ps2pdf”, have you tried that pdf version?

• cpbl says:

Using (resorting to) pspdf doesn’t sound like a great solution to me, since some modern desirable features tend to be offered only using pdflatexl, which does not go through a DVI or postscript stage. Samer, when you are compiling, you should be using pdflatex, not some other route to PDF. Is this option visible in your View menu in LyX? Viewing as PDF via pdflatex works for me on the ubcsamplelyx.lyx file.

15. Viewing as pdfaltex or pspdf does not work for the ubcsamplelyx.lyx. it works on the other file ubcsamplelyx-auto.lyx. Is there a difference between the two files?

16. when I try to view the file as DVI it got the message :

dvips.exe: Windows API error 5: Access is denied.

dvips.exe: Data: C:\Program Files (x86)\MiKTeX\dvips\psfrag
C:\Program Files (x86)\MiKTeX\miktex\bin\dvips.exe: ! Couldn’t find header file: psfrag.pro

Could this be related?

• Jannu says:

I have the same problem with the PDF, but the DVI version works fine. If I’m not mistaken the problem started when I upgraded to Lyx 2. My labmate has a Linux machine and works good for her. I’m using Windows 7.

Hope someone can shed some light on this issue

17. Jotaf says:

Thank you for sharing, this is massively useful! It was easy enough to modify it for my PhD proposal.

• cpbl says:

Congratulations! And thanks for the kind feedback. I trust you will spread work of your success…

18. Priya says:

I changed the coding of hyperref a bit, and it worked for me. Hope it helps the others as well.
Just replace the \usepackage [hypertex, blah blah blah]{hyperref} to the following code.

\usepackage{hyperref}
\hypersetup{
hypertex=true,
unicode=true, pdfusetitle,
bookmarks=true,
bookmarksnumbered=false,
bookmarksopen=true,
pdfborder={0 0 1},
backref=true,
citecolor=black,
filecolor=black,
urlcolor=black
}

Hope it helps! 🙂

• Jannu says:

Thanks Priya, it solved the problem for me too. I also deleted the [2003/11/30] that appeared after {hyperref]

Thanks a million

19. Ben Blumer says:

Thanks for the great layout. I was fully prepared to write a UBC Thesis LyX layout myself, thank you for saving me bundles of time.

BTW, using LyX 2.0.6 with TeXLive 2012, I got the problem described by Samer Atallah (August 7, 2012 at 10:13 pm). Using Priya’s (September 26, 2012 at 12:49 pm) fixed it for me.

20. cpbl says:

@Priya, @Jannu, @BenBlumer: Thanks for the fix! I updated the version in the .zip file with Priya’s change, although I suspect all that was wrong was the bizarre date that Jannu mentions. Not sure how that got in there!