What you need is to define these new environments to your LyX document.
You have already done it with the above settings written in your preamble, but LyX doesn't know anything about it yet.
In LyX, go to Document->Settings->Local Layout and inside the text box enter the following:
Format 60
Counter xsimExercise
Within section
End
Counter exercise
Within section
End
Style xsimExercise
Category Reasoning
Margin First_Dynamic
LatexType Environment
LatexName xrcs
NextNoIndent 1
ResetArgs 1
Argument 1
LabelString "(string)"
Decoration Minimalistic
EndArgument
AddToToc Exercises
IsTocCaption 1
LabelSep xx
ParIndent MMM
ParSkip 0.4
ItemSep 0.2
TopSep 0.7
BottomSep 0.7
ParSep 0.3
Align Block
AlignPossible Left
LabelType Static
LabelCounter xsimExercise
LabelString "xsimExercise \thexsimExercise"
Font
Shape Up
Size Normal
EndFont
LabelFont
Shape Up
Series Bold
EndFont
RefPrefix xrcs #label prefix when iserting a label
Requires xsim
End
Style Exercise
Category Reasoning
Margin First_Dynamic
LatexType Environment
LatexName exercise
ParagraphGroup 1
NextNoIndent 1
ResetArgs 1
Argument 1
LabelString "(string)"
Decoration Minimalistic
EndArgument
AddToToc Exercises
IsTocCaption 1
LabelSep xx
ParIndent MMM
ParSkip 0.4
ItemSep 0.2
TopSep 0.7
BottomSep 0.7
ParSep 0.3
Align Block
AlignPossible Left
LabelType Static
LabelCounter exercise
LabelString "exercise \theexercise"
Font
Shape Up
Size Normal
EndFont
LabelFont
Shape Up
Series Bold
EndFont
RefPrefix exer
End
Click Validate and apply. Now you should see two new environments in the top left combo box:
![enter image description here](https://i.stack.imgur.com/xlhZX.png)
![enter image description here](https://i.stack.imgur.com/KsOGH.png)
A brief explanation about this code block:
LyX allows the user to define some new environments and commands to the editor, by means of customization.
The above code block is in fact a layout file that makes such changes.
Format 60
is the format number of the layout file. The format for the present version of LYX is format 60.
Counter xsimExercise
sets a counter for this environment. Add +1 inside sections. If you want both of the environments exercise
and xrcs
to share the same counter, change this to
Counter xsimExercise
Within section
End
Counter exercise
Within xsimExercise
End
Then we define the new environments and the way they look inside the editor with
Style xsimExercise
defintions
End
Take a loot at section 5.3.7 in the manual to better understand those commands.
Then add the code preamble you wrote in the question to the preamble in LyX (Document->Settings->Preamble).
And you are ready to go.
One more thing:
After you are all set with the customization process, in order to make it more user-wide, save the above code block I wrote as a module file (with a module
file extension) such as xsim.module
) and append it the following lines:
#\DeclareLyXModule{Exercise Environments}
#DescriptionBegin
#Defines exercise environments with the xsim package
#DescriptionEnd
<Code block goes here>
Then move this module file to LyX's layouts directory
in Mac OS
/Applications/LyX.app/Contents/Resources/layouts/
in windows (if I am not wrong)
C:/Users/laba/AppData/Roaming/LyX2.3/layouts
and then reconfigure LyX (Tools->Reconfigure) and restart LyX.
Now you should be able to see the new module in the module list available to be used:
![enter image description here](https://i.stack.imgur.com/Ys4hT.png)
The thing is that the cycle
- change module commands
- reconfigure LyX
- restart LyX
- check that you are good with the new configuration
- make some changes again
is very slow. So first make sure you are good with your module you are setting up in the Local Layout, and quickly validate it. Only then make the changes and update the module file in the layouts directory.
Best Answer
iBooks Author added very basic support for LaTeX commands in version 2.0 (October 2012). It’s really converting a small collection of LaTeX commands to MathML using blahtex [sic], and rendering them with WebKit on the iPad. In my brief experiments, it appears to be restricted to inserting inline equations in text boxes.
There’s an Apple Support Base article, iBooks Author: About LaTeX and MathML Support, which describes exactly the commands which iBooks Author can use. It’s a pretty short list.
As far as I know, there is no way to add packages to an iBooks Author file, since it’s not really full LaTeX, and it can’t go looking for extra packages. It’s primarily using WebKit and HTML for the backend, not TeX.
Some other notes from my (admittedly brief) usage:
It doesn’t use proper TeX fonts. I’ve not tried looking about an iBook generated this way on the iPad, but the equation in the Mac preview only uses Lucida Grande (the system default font on OS X). Trying common fonts such as Helvetica, Arial and Times leaves the equation resolutely in Lucida Grande, as do trying the Computer Modern fonts. This may be different on the iPad.
A side effect of this is that the formatting looks really weird. Here’s an example:
There’s a world of difference between that, and what a TeX compiler can draw, I think.
I looked at iBooks Author when they announced LaTeX support last year. I write my lecture notes electronically, and being able to use something like iBooks looked really interesting. I tried using it for my notes, but it broke down very quickly. It doesn’t support very many advanced commands, and I just went back to using PDFs and a PDF annotation app.
If your needs are simple, then iBooks Author may work for you. But for any sort of moderately complicated document, I think you’re better off using LaTeX.
I'll end by noting that Apple's record of updating their Mac software has been poor recently. iBooks Author hasn't been updated in nine months, and I don’t think adding full TeX support is on Apple’s priority list. Given further that iBooks is a properietary file format, I wouldn’t recommend using it for maths if you can avoid it.