How to typeset theorems and definitions?

How to typeset theorems and definitions in LibreOffice Write, something similar to what ‘amsthm’ package provides for LaTeX (LaTeX/Theorems - Wikibooks, open books for an open world)? Is there extension or style for that?

As a minimum I would like to have nicely typeset definition, lemma or theorem with name and clearly distinguished from the rest of the text.

I would like to have definitions and theorem automatically numbered, possibly within section (i.e. .), and possibly with some separate styles (like lemmas and theorems) numbered with the same counter (the same continuous numbering).

LO comes with a component named Math, which you access with Insert>Object>Formula. It is rather simplistic but will do for most simple formulas. If you really need elaborate formatting, there are extensions to design formulas with the TEX macro language. Search the extensions site.

Automatic numbering is easy. The formula out of Math comes in a frame anchored by default As character. Change this anchor mode To paragraph to be able to position it more freely. You can then Inset>Caption on the frame. Doing this, you can choose from the built-in categories, Drawing, Figure, Illustration, … or create your own category like Formula, Theorem, Lemma.

Each category name has an associated counter. If you press the Options button in the dialog, you can select a number mode: document if level is [None], chapter is level is 1, … You can’t number by section if you use this word in its LO Writer meaning (not common sense where section = chapter, sub-chapter, …). A section is a part of page where you have a number of columns different from the enclosing page.

How a formula, theorem or lemma is distinguished from the rest of the test is only a matter of paragraph, character and frame styles. You define them according to your taste. Learn what they can offer to you in the Guides. There is one for Writer and one for Math.

Avoid the beginner’s pitfall: refrain from manually formatting your document, this is fine for experimenting but creates a formatting hell when it comes to an elaborate and highly-crafted document.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

There are many ways how a user may want formulas embedded and numbered: By a classification, by chapter, by both…

You can set simple example formulas using the Math component (getting little OLE objects), and combine them with one or another kind of capture - using a little table per formula e.g. as is included with the standard AutoText (Fn+F3), using a specific paragrapph style, even using a TextFrame per formula.

Assuming you got 4 “templates” this way for Def, Theo, Lemm, Continuous e.g with the respective captures and surroundings: Create an AutoText item from each template and use it the next few daecades.

(I personally never took the time for developing a really satisfying toolbox of the kind, and now I’m retired and don’t need that very much any more - but you may do better.)

===Editing half an hour later===
Sorry! I just made (with V 7.0.0.2RC) a little example document to demonstrate the descibed usage of AutoText items. Alas! I ran ionto a bug thats for the moment too complicated for me to report it.
You should probably expect problems.
===Editing again===
Repeated parts of the effort in V6.4.4 and got the expected results now. I attach the new demo hoping it may help somebody: ask259220formulasFromTemplatesAsAutoText.odt
===Editing 2020-10-19 about 20:15 UTC===
Meanwhile used the autotext items contained in the above attachment with V7.0.1.2 more than once, and they worked as expected. Probably no bug alert needed.