[Tex/LaTex] Using a new document class/template with LyX

document-classeslyxlyx-layoutstemplates

I tried googling this elsewhere but I'm new to LaTeX and extremely confused about certain things. Basically I downloaded MikteX and I'm using the latest version of Lyx with it. Now all I basically know how to do is make pretty looking mathematics and add contents pages/titles/references/etc.

I'm looking to make a dissertation and my unviersity provides a template, ociamthesis.cls (available for download at that link).

So, what exactly do I need to do (and please be super specific as I am totally clueless to all the jargon I read).

Basically, I need to download ociamthesis.cls in the first line of that webpage. Does it matter where I save it? What exactly do I do next?

Best Answer

A layout in LyX is analogous to document classes in LaTeX. Since the provided document class (ociamthesis.cls) is not covered by an existing LyX layout, you have to create your own, by following these instructions (also available under Help > Customization; section 5.3 The layout file format):

  1. First you have to install the LaTeX class so that it works with LaTeX. A discussion on this is available in Where do I place my own .sty files, to make them available to all my .tex files? that holds also for .cls document class files.

  2. For using this LaTeX class, you'll have to write your own LyX layout. This requires you to find the "basis class" for your new class. The first couple of lines of ociamthesis.cls reveals

    \LoadClass[a4paper]{report}
    

    which implies that ociamthesis.cls is based on (or a descendant of) report.cls - something known to LyX. So you should start with report.layout:

    enter image description here

  3. Open report.layout and change it to resemble

    #% Do not delete the line below; configure depends on this
    #  \DeclareLaTeXClass[ociamthesis]{Oxford Math Inst}
    
    # Read the definitions from report.layout
    Input report.layout
    

    Save this file as ociamthesis.layout in the same folder.

  4. In LyX, follow Tools > Reconfigure, and restart LyX. Now Oxford Math Inst is the text you will see in the Layout > Document > Document-Class drop-down list. With LyX reconfigured, you can now edit ociamthesis.layout and immediately see the effects of it when you recompile. LyX just needed to know where it is located, which took quite a while.

  5. It's clear that the above minimal definition just builds the shell for the newly defined class that is based on report. Now you have to go through ociamthesis.cls and see what else to add to ociamthesis.layout to complete it. For example, since the class report is loaded with the option a4paper, we need to add

    ClassOptions
      Other "a4paper"
    End
    

    after Input report.layout.

  6. A feasible final step is to include the remainder of ociamthesis.cls as part of the LyX layout's preamble:

    Preamble
      \def\logoversion{squarelogo}
      \RequirePackage{graphicx} % needed for latest frontpage logo
      \RequirePackage{ifthen}   % needed for option parsing for logo
    
      \raggedbottom
    
      %define the default submitted text
      \newcommand{\submittedtext}{{A thesis submitted for the degree of}}
    
      %... the remainder of ociamthesis.cls
      %...
      %...
    EndPreamble
    
Related Question