Tariq Abdullah wrote:
Hi All,

Can someone describe the contents and purpose of layout file in Lyx.
Try Help->Customization

Why is it necessary to creat/include layout file in addition to .cls file
in Lyx?
Because LyX doesn't understand .cls (or .sty) files. LyX can
tell latex to use some .cls file, but LyX doesn't
understand what the .cls file is for or what opportunities
it offers. This because LyX don't understand all of LaTeX.

Basically, a .layout file is for LyX what a .cls or .sty file is for LaTeX.

A .layout file tells LyX:
* about some document settings & defaults
* about paragraph types
* about character styles
* How these styles should look on the screen, and what latex
  commands must be used to print them.
Note that the layout on screen is quite limited, but there are
almost no limits as to what latex code you can invoke.

It will be of great help if someone can describe the minimal contents of
the layout file in order to use a new class file with Lyx. I have already
checked chapter 5 of "Lyx customization manual". This chapter provides
terribly long details about the layout file.
Please don't refer me to that chapter. -:)
Well, layout files aren't "easy" stuff so if you want to understand,
that file is useful!

Still, a minimal .layout can be small because it can build on
existing layouts. An example that add 3-column paragraphs
to the article class:
--------------------------------------------------
#% Do not delete the line below; configure depends on this
#  \DeclareLaTeXClass[article]{article (with triplecolumns)}

#Test style, adds 3-column paragraphs to the article class.
#The format version
Format 2

#Documents will be articles, with an add-on
Input article.layout

#Let's override a default - we want fancy pages
PageStyle fancy

#The new text style
Style threecol
   #Mostly like standard text
   CopyStyle Standard
   #Implemented with an environment (not a command)
   LatexType Environment
   #The name of this environment
   LatexName threecol
   #Preamble latexcode necessary if this paragraph style
   #gets used in the document
   Preamble
       \usepackage{multicol}
       \newenvironment{threecol}
           {\begin{multicols}{3}}
           {\end{multicols}}
   EndPreamble
End

---------------------------------------------

Of course a truly minimal file can be even smaller, but then
it won't do anything new.  For example:

--------------------------------------------------
#% Do not delete the line below; configure depends on this
#  \DeclareLaTeXClass[article]{article (with nothing extra)}

#Test style, adds 3-column paragraphs to the article class.
#The format version
Format 2

#This will be just like article:
Input article.layout
---------------------------------------------

Making a .layout file for an entirely new document class
isn't much harder than the simple example, but it will
of course be much more work. You have to write
entries for every paragraph type or character style
the new class have.

Helge Hafting

Reply via email to