Computational Economics

computational tools for economists

Adding .cls file to Lyx in Windows 7

leave a comment »


This assumes version 2.9 of Miktex and version 2.0 of Lyx. If you are using an earlier or later versions, replace with the correct version numbers where I’ve used them.

  1. Get a copy of the class file, and copy it into a folder with the same name into C:\Users\\AppData\Roaming\MiKTeX\2.8\tex. So, for eethesis.cls, you should have a folder called eethesis within C:\Users\\AppData\Roaming\MiKTeX\2.8\tex. [AppData does not appear in my pc… Search for “AppData” and find the folder]
  2. Create a new file and paste the following into it:
    #% Do not delete the line below; configure depends on this
    # \DeclareLaTeXClass[xxx]{article (xxx)}
    # Input general definitions

    replacing xxx with the class name (without the .cls extension). In my case, xxx is eethesis, and the code above becomes:

    #% Do not delete the line below; configure depends on this
    # \DeclareLaTeXClass[eethesis]{article (eethesis)}
    # Input general definitions

    Thanks goes out to for this.

  3. Save this file to C:\Program Files\LyX16\Resources\layouts, naming it eethesis.layout.
  4. In a command prompt (type cmd in start menu), type texhash. What you will now see it doing is iterating through several folders for new classes, one of which (C:\Users\AppData\Roaming\MiKTeX\2.8\) is where we copied the eethesis.cls class file into.
  5. Within Lyx, hit Tools > Reconfigure, then restart Lyx.
  6. Open a document and click Document > Settings. Click on ‘Document Class’, expand the drop down menu and you should see ‘article (xxx)’ is visible, and usable, (like below) within the drop down menu.

UCR Thesis Templates in Lyx

1) Copy and paste these into the Preamble

default page size – letter: 8.5in [1.5+6+1]*11in [1.5+8.5+1]

\textwidth = 6.00in
\textheight = 8.50in
\topmargin = 0.75in

2) I get an error when using \thebibliography: \newblock undefined.

Check the following in ucr.cls. Move it to the beginning of the bibliography section.
\def\newblock{\hskip .11em plus .33em minus .07em}

3)I got a LaTeX Error when using \subfig: No counter ‘subfigure@save’ defined.

Delete \usepackage{subfigure} in the Preamble

4) Bibliography/Table/Figure Caption is double-spacing

Add  ssp and dsp ( into a Tex Code box) before and after the BibTex Generated Bib box. Note that ssp and dsp have been defined in ucr.cls.

BibTex Generated Bib

5) Generate bookmarks in the PDF file

Document→Settings→PDF properties: check the boxes under Hyperlinks and Bookmarks dialog

6) Bibliography and Appendix do not appear in the table of contents (TOC)

use the package tocbibind from CTAN, i.e. add \usepackage{tocbibind} to the Preamble

7) Add additional entries to TOC

The following LaTeX command: \addcontentsline{toc}{chapter}{APPENDIX}  will add ‘APPENDIX’ to TOC and refer to the page where you have inserted this command. So this line should be added as ERT to the “page” of the document that you want to appear listed in the table of contents. This can also be used to include unnumbered sections to the TOC. Just insert the line immediately below the section header.

8) Table/Figure caption left-justified and bold

add \usepackage[nooneline, font={bf}]{caption} to the Preamble

9) Footnote spacing

space between footnotes: \setlength{\footnotesep}{2mm}
space between the text body and the footnotes: \setlength{\skip\footins}{1cm}

10) How to stop equation auto numbering in TeX code?

\begin{equation*} … \end{equation*}

11) How to modify Tex code from Mathematica so that it fits the thesis document class?

copy and paste into Notepad, replace \begin{doublespace} and \pmb with blank, replace \end{doublespace} with \par\vspace{5mm}. Break long lines in Mathematica before generating Tex code. In Mathematica, do not write comments in equations.

reading this link for inserting child document:

Method I use: save the code in a plain text file. create a Tex code box, Insert –> file –> Plain Text…


Got the template from Kara; also available online at:

  • Copy the following files to C:\Program Files\MiKTeX\tex\latex\ucr
    • sw20uctd.sty, thmsupp.tex, ucr.cls, uct10.clo, uct11.clo, uct12.clo
  • Next run MikTex ’s Settings and then Refresh FNDB
  • Create the following layout file, ucr.layout, in C:\Program Files\LyX16\Resources\layouts:

      #% Do not delete the line below; configure depends on this
      # \DeclareLaTeXClass[ucr]{article (ucr)}
      # Input general definitions
      # Input lyx algorithm definitions (only if you've installed the algorithm package for Lyx from:
  • Finally, run Tools → Reconfigure in Lyx
  • Next, Import the file uctest.tex into Lyx
    • Remove the Title and Author and, instead, add all the lines from \title to \maketitle into an ERT (a Tex Code box) since the \maketitle command Lyx inserts right after Title or Author causes a premature compilation error where it says \maketitle was not def ’ed; solution was as per here
    • Also, had to add \setlength\headsep{-0.5in} to the Latex Preamble in order to ensure the top margin isn ’t too large, as per:
    • Also, had to change textheight to \textheight = 8.50in in the Latex Preamble from 8.25in
    • Had to comment out \newtheorem{algorithm}[theorem]{Algorithm} in the Latex Preamble, as well, in order to avoid errors when I include algorithms in the paper (since I add the algorithm style msyelf)
    • Finally, Kara wanted me to change to a darker font so I added \usepackage{palatino} to the Latex Preamble, as per

Written by Jingjing Wang

11/29/2011 at 11:38 pm

Posted in LyX

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: