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.

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

43 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.
    Adam

    • 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}

    % 3.5 cm en haut
    \setlength{\topmargin}{1.5cm}
    \setlength{\headheight}{1cm}
    \setlength{\headsep}{0.5cm}
    \setlength{\topskip}{0cm}

    % 2.5 cm pour la reliure 2 de l'autre coté
    \setlength{\oddsidemargin}{2.5cm}
    \setlength{\evensidemargin}{2cm}

    % 0.7 cm en bas
    \setlength{\footskip}{1cm}

    % largeur hauteur du texte
    \setlength{\textwidth}{16.5cm}
    \setlength{\textheight}{24cm}

    % * * * * * * * * * * * fancy header
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{} % supprime toutes les entêtes
    \renewcommand{% % modifie l'affichage de \leftmark
    \chaptermark}[1]{\markboth{\fontfamily{pzc}\selectfont\Large\chaptername~\thechapter~:~#1}{}}
    \renewcommand{% % modifie l'affichage de \rightmark
    \sectionmark}[1]{\markright{\fontfamily{pzc}\selectfont\Large\thesection~#1}}
    \fancyhead[LE]{\leftmark} % le chapitre page paire à gauche
    \fancyhead[RO]{\rightmark} % la section page impaire à droite
    \fancyfoot{} % supprime tous les pied de page
    \fancyfoot[LE,RO]{\thepage} % le numero de page en bas à droite ou gauche
    \renewcommand{\headrulewidth}{0.4pt} % eppaisseur du trait de l'entete
    \renewcommand{\footrulewidth}{0pt}

    % redéfini le style plain utiliser pour les titre de chapitre
    \fancypagestyle{plain}{%
    \fancyhf{} % clear all header and footer fields
    \fancyfoot[RE,RO]{\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}}

    % élargir les tableaux
    \renewcommand{\arraystretch}{1.4}

    %titre de chapitre
    \usepackage{titlesec}
    \titleformat{\chapter}[display] {\normalfont\Large\filcenter\sffamily} {\titlerule[1pt]%
    \vspace{1pt}%
    \titlerule \vspace{1pc}%
    \LARGE\MakeUppercase{\chaptertitlename} \thechapter}
    {1pc}
    {\titlerule
    \vspace{1pc}%
    \Huge}[\newpage\null\thispagestyle{plain}\newpage]

    %pr mettre "figure" en gras
    \AtBeginDocument{%
    \renewcommand{\fnum@figure}{{\bfseries\figurename\nobreakspace\thefigure}}
    \renewcommand{\fnum@table}{{\bfseries\figuretable\nobreakspace\thetable}}
    }

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

    Please, what can I do???

    • 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?
    thanks a lot in advance
    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?

  8. fongchunchan says:

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

    \renewcommand{\contentnames}{Table of Contents}

    But it didn’t work. Thanks

    • cpbl says:

      Close, not quite.

      How about

      \renewcommand\contentsname{Table of Contents}

      • 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}
      \addto\captionsenglish{%

      Hope that helps anyone else who has this same problem.

      • fongchunchan says:

        Oppos forgot to finish the code:

        \usepackage[english]{babel}
        \addto\captionsenglish{%
        \renewcommand\contentsname{Table of Contents}}

  9. Christina says:

    I prepared my FoGS-approved UBC PhD dissertation in LyX. I am wondering how you inserted your Table of Contents to start with. I used “insert” “list/TOC” and select TOC. This creates a little box in mythesis.lyx that reads — “Table of Contents” (looks the same font/colour as List of Tables and List of Figures). In the compiled version I get “Table of Contents”. Is that how you created your TOC?

    • 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.

  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,
    breaklinks=true,
    pdfborder={0 0 1},
    backref=true,
    colorlinks=true,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
    }

    Hope it helps! :)

  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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s