Richard Kimberly Heck rikiheck at lyx.org
Tue Jan 19 21:36:04 UTC 2021

On 1/18/21 11:14 PM, Anthony Macks wrote:
> Dear LyX users,
>
> I have created a new environment by adding the following to my preamble.
>
> \newcounter{YourTurn}[section]
> \newenvironment{YourTurn}[1][]{\refstepcounter{YourTurn}\par\medskip
>      \noindent \color{green}\textbf{Your Turn ~\theYourTurn. #1}
> \rmfamily\color{black}}{\medskip}
>
> I would like to add this environment to the drop down list in the menu.
>
> I know I have to edit a .layout file, but I am unsure as to what to do.

If this is just for one document, you can enter the necessary layout
code under Document> Settings> Local Layout.

Something like this should work:

Format 66

Counter YourTurn
Within Section
End

Style YourTurn
LaTeXType Environment
LaTeXName YourTurn
LabelType Static
LabelCounter YourTurn
\newcounter{YourTurn}[section]
Preamble
\newcounter{YourTurn}[section]
\newenvironment{YourTurn}[1][]{\refstepcounter{YourTurn}\par\medskip
\rmfamily\color{black}}{\medskip}
EndPremable
End

That is pretty basic but should get you started.

The preamble code specified is just copied from yours: LyX will
automatically insert it, so you now don't need it in your regular
premable. The advantage is that LyX will insert it *only* if you use
this environment.

See the Customization manual, section 5.2, for more details. Better yet,
look at some of the modules and layout files that ship with LyX. The
best say to understand the syntax is to see it in action.

If you might want to re-use this, you can put it into a module and put
the module into the layouts/ folder of your user directory. You'll then
need to reconfigure for it to show up. Modules also need a header, like:

#\DeclareLyXModule{Formula}
#DescriptionBegin
#An environment for numbered formulas.
#DescriptionEnd

Riki