Go to page:

Search:   Help



LyX documentation


Shared groups



Categories: Layouts
<< | Page list | >>

Tips and links related to creating your own LyX layout-files

This page contains tips, notes and links related to creating your own layout-files for LyX.


Pages, sites and other resources related to creating layouts

  • LyX documentation: Help→Customization (chapter 5)
  • Links and examples in the Layouts group in this wiki.
  • Steve Litt's "Quickstart tutorial" and "LyX, LaTeX and TeX" (both available from the tutorials-page) provides an excellent introduction to creating your own layout files
  • A step by step example of how to create a NIH grant template from available LaTeX document classes can be found here


This page answers the FAQ "How do I make LyX recognize a new LaTeX class?" It was created in response to a question in LyxUsersPost:13975

I would like to submit a paper for siggraph, a computer graphics conference, and they defined some guidelines for paper formatting and delivery everybody has to follow.

They even provide some LaTeX class and BibTeX style files (acmsiggraph.zip [www.siggraph.org]) but I would love to write the paper not with LaTeX but LyX.

Can I use LaTeX class files and BibTeX style files in LyX?

Quick'n dirty answer

First you have to install the latex class and bibtex bst so that it works with latex (put in place and run texhash).

[ RedHat 9.0 / Fedora Core 1,2,3 : latex class location is /usr/share/texmf/tex/latex; make a directory inside this directory called acmsiggraph and place acmsiggraph.cls inside. The bibtex .bst location is /usr/share/texmf/bibtex/bst/; make a directory inside this directory called acmsiggraph and insert .bst file. The .bib file location is /usr/share/texmf/bibtex/bib; make a directory inside this directory called acmsiggraph and insert .bib file. Now run "texhash" . This will reconfigure latex and make it available for lyx. ]

Using their BibTeX style should be very easy. After an Tools>Reconfigure from lyx, it should show up in the drop-down list of available bibtex styles and you can select it as usual.

For using their LaTeX-class, you'll have to write your own LyX-layout. (It shouldn't be that difficult...)

Find the basis class for your new class. Lets assume, the LaTeX class amcsiggraph.cls is a descendant of article.cls, then the lyx layout to use is article.layout. Save the following to a file acmsiggraph.layout in your layouts directory (~/.lyx/layouts/ on UNIX, "~/Library/Application Support/LyX-<version>/layouts/" on Mac OS X):

#% Do not delete the line below; configure depends on this      
#  \DeclareLaTeXClass[acmsiggraph]{ACM SigGraph}

# Read the definitions from article.layout
Input article.layout

ACM SigGraph is the text you will see in the Layout>Document>Document-Class drop-down list. (After Tools>Reconfigure and a restart of lyx.)

For a more detailed answer and example files, see the links above.

Quick'n dirty answer extended

Most of the times the previous approach results in an exception when trying to create a pdf. The problem is that many latex layouts (.cls) require certain fields especially at the beginning of the document (e.g. title, author).

If an example .tex is provided I suggest the following approach:

  1. Do steps as in Quick'n dirty
  2. export latex (pdflatex)
  3. compare this file to example tex
  4. add any differences as evil red text (ERT, aka latex code) to your lyx file
    1. You may alternately want to add them to Document->Settings->LaTeX Preamble.
  5. Do step 2-4 until the lyx file compiles

For those who really want to dig in

See the section "The layout file format" (LyX Documentation: Help→Customization, Section 5.3 (tag "sec:TextClass")).

If you want to go a little farther and edit a layout file, you will find there are several common commands:

 Format 4 # Format of this layout file.  11 is maximum readable by version 1.6.  LyX is backwards-compatable, and can read all previous layout formats.

 Input filename.inc # Includes the contents of filename.inc as if you had typed the contents of filename.inc
                    # instead of this line in your layout.

 DefaultModule theorems-ams # Use the ams theorems module by default.
               # Presumably there are various components which import "modules" of additional tex code. For example, if you 
               # use a feature only available in AMSMath, the AMSmath package is included automatically.
               # the module theorems-ams is defined in /usr/share/lyx/layouts/theorems-ams.module on my machine.

 Requires amsmath,amsthm # The main purpose of this command 
  # is to stick the LaTeX code "\usepackage{amsmath}" in the
  # document preamble. (You can see that it does this by using
  # View->View Source and checking "complete source".
  # Note that only supported classes can be included. These are known
  # as features and included in LaTeXFeatures.cpp

 Style MyStyleName
    CopyStyle     YourStyleName
    LatexName     mylatexcommand
    LabelString   "My Style" # For the menu?


Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2011-08-23 15:27 CEST