LyXEnvironment that enumerate and start with a word

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
roken
Posts: 3
Joined: Fri Jan 24, 2025 1:57 pm

Environment that enumerate and start with a word

Post by roken »

Hello, i am new to LyX and trying to do something i think is pretty basic but can't seem to find how.
I like how the environment "Section" has a counter on it, so that when creating a new section, it is numeralised automatically.
I would like to have the same to make a sheet of maths exercices, so an "exercice" environnement, with a counter integrated in it, but instead of being "1." or "2." at the begging of the line, it's "exercice 1" or "exercice 2". Can't seem to find how to do it, but it would be useful, so that if i add exercices in between, i don't have to re enumerate the whole thing.
Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Stefan Kottwitz
Site Admin
Posts: 10307
Joined: Mon Mar 10, 2008 9:44 pm

Re: Environment that enumerate and start with a word

Post by Stefan Kottwitz »

It depends on how you are doing that environment. But you can redefine how the counter is printed, like \renewcommand*{\theexercice}{exercice \arabic{exercice}}.

Stefan
LaTeX.org admin
roken
Posts: 3
Joined: Fri Jan 24, 2025 1:57 pm

Re: Environment that enumerate and start with a word

Post by roken »

Thanks.
How do you create an environment. There is a 4 step guide on how to on this site -> https://tex.stackexchange.com/questions ... 779#129779 (first anwser), but it seems complicated, i have to copy and modify some files, is there a way to do it in LyX UI?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10307
Joined: Mon Mar 10, 2008 9:44 pm

Re: Environment that enumerate and start with a word

Post by Stefan Kottwitz »

I don't use the LyX UI myself, I prefer LaTeX. As I also see in the link you provided, it get's difficult with LyX if a document is not standard.

With LaTeX, I would use the exam class (looks easy to work with), such a template, or the xsim package (looks difficult to learn).

Stefan
LaTeX.org admin
Torael
Posts: 3
Joined: Mon Aug 12, 2024 7:47 pm

Re: Environment that enumerate and start with a word

Post by Torael »

In fact it is not as difficult as you might think. You need to load the "Customisable lists (enumitem)"-Module via Document -> Settings -> Modules -> List Enhancements.
Then you can put this in your Preamble:

Code: Select all

\setenumerate{label=exercise \arabic*}
(Mention, that LyX gives you an error, if you're defining a numeration without using it. So you should comment it out, if you put in your standard-Preamble)

edit: Enumitem can do much more than you actually need in this situation. Maybe the LyX-User's Guide (Section 3.3.7) has enough to solve your problem in an even easier way. (But only if you don't want to have all numerations in this way.)
Post Reply