# Using a new document class/template with LyX?

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 which can be found here: http://www.maths.ox.ac.uk/help/faqs/latex/thesisclass

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?

-
Have a look here. This seems to be basically the same situation. –  vaettchen Dec 22 '13 at 5:26
Thanks for the help although I am still confused. There are no words for how clueless I am about Lyx right now. Looking at that answer, I have some questions. What is my existing class's layout file? What directory do I need to save it in? Then the editing bit he talks about I don't even know where to begin... so yeah, pretty damn clueless. –  user43058 Dec 22 '13 at 13:35
This is very detailed and closer to your situation. It's for a Mac but should work very similarly for Linux. –  vaettchen Dec 22 '13 at 14:16
I appreciate your help. So, just to make this really explicit: All I do is save the file "ociamthesis.cls" in miktex>tex>latex then leave it, or do I go one further and save it in the folder miktex>tex>latex>lyx? After that, i try to save the file "ociamthesis.cls" again but this time I change the ".cls" into ".laylout" then save it in the folder lyx>resources>layouts? then i reconfigure lyx then restart lyx and then the oxford thesis should be a document class? –  user43058 Dec 22 '13 at 14:32
I'm sorry I don't know Windows / MikTex well enough to give advice. I'm sure the Apple version can be translated into the Windows world but I don't know how. –  vaettchen Dec 22 '13 at 17:10

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:

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

-
Give some feedback if you experience problems. I've never transformed a .cls to a .layout. –  Werner Dec 24 '13 at 8:09