Month: August 2011

Let’s say we have a custom new Latex class called “newclass.cls” which we want to be able to use with Lyx under Windows.

Copy the new Latex class file “newclass.cls” into the MikTeX directory within your user settings folder like so: C:\Users\UserName\AppData\Roaming\MiKTeX\2.8\tex\latex\newclass\newclass.cls. Remember to replace UserName with your own Windows user name.

Update the MikTeX list of classes by clicking the Windows Start button and typing cmd into the search box. When the black command line window displays, type texhash and hit Enter.

Next we need to create a layout file for Lyx to work with. This file contains instructions on how to roughly format a document when displayed within the Lyx program itself. More importantly, the layout file points to the Latex class for generating the final output. It is helpful to start by just modifying an existing layout file which is similar in purpose to the Latex class we are trying to add. For example, if our new Latex class is a template for an article, we might want to start by copying article.layout from C:\Program Files (x86)\LyX20\Resources\layouts and pasting it into C:\Users\UserName\AppData\Roaming\LyX2.0\layouts. Rename the file to match your class name, say, “newclass.layout”

Open up your new layout file, and look at the second line. Replace it with:# \DeclareLaTeXClass[newclass]{Title of Class}
Enter your class name within the [] brackets, and enter whatever descriptive name you want to call the class within the {} braces.

Open Lyx, and click Tools > Reconfigure. Restart the Lyx program when it prompts you to do so.

That’s it! When you start a new document in Lyx, your new class should appear within the drop-down box for Document Class in the Document Settings window (Document > Settings).