# How to create (1) a new Environment for LyX's Environment drop-down menu, (2) a new Text Style

My two part question pertains to LyX.

1. How do you create a new "Environment" ("Paragraph Style") for LyX's Environment drop-down list (Standard, Itemize, Enumerate, Chapter, Section, Subsection, Quote, Lyx-Code, etc.)?

2. How do you create a new "Text Style" (LyX top menubar > Edit > CharStyle:Code, CharStyle:Emph, Etc, "CharStyle:NewTextStyleHere")?

I would like to use, eg, the Book(KOMA-script) Document Class, but be able to add to it (1) new Environments (say, eg, a "SubSubparagraph" style, and (2) new Text Styles (say, eg, a "DiminishedFontSize" text style). This would greatly extend the usability of a document class within LyX.

The first part of my question is very similar, if not identical, to Dave Jarvis's question on page: Create new paragraph style in LyX

Jarvis provides a good example of the kinda of step-by-step instructions that he and I are looking for in an answer. Thank you.

-

It sounds like Herbert's answer is a complete answer to part 1. Is that right?

For the second part, I think you need what Lyx confusingly calls inset layouts (why not the disagreement with the terminology in the menus?). A minimal example (texted for Lyx 1.6.8):

#\DeclareLyXModule{Example text style}
#DescriptionBegin
#DescriptionEnd
#Author: Charles Stewart

InsetLayout Foo
LyxType           charstyle
LabelString       stylefoo

LatexType             Command
LatexName             stylefoo
Font
Size          Large
EndFont

Preamble
\newcommand\stylefoo[1]{\textit{\texbf{#1}}}
EndPreamble

End


Save this file to style-eg.module in the layouts subdirectory of the Lyx user directory (which is shown by the About menu item).

Then add it to lyxmodules.lst, e.g., using:

localhost:.lyx cas\$ cat >> lyxmodules.lst
"Example text style" "style-eg" "Style example for tex.sx qn." "" "" ""


Add the "Example text style" to your modules using the Modules tab under Document > Settings, and your text style should appear in the submenu. What I have defined will make the font a little bigger in the window, and will wrap the styled text in its Latex output in a \stylefoo command, whose definition above is added to the preamble.

-