How to use sections as TOC entries?

Is it possible to generate in Writer a Table of contents with the name of sections?

The answer by @ROSt53 is effectively correct and I have marked it up. What I want to address in this answer is a different aspect of your question: what do you mean by your use of the term “section”? There is a conceptual and practical aspect to any answer to this question that I want to explain.

The TLDR version of this answer is: There is no method I know of for pulling instances of the <text:section> element from a Writer (ODT) document and using them as a basis for generating a table of contents (ToC). A ToC is based on Paragraph styles / automatically inserted bookmarks. Avoid using the section facility in word processing software to break-up content, use a text style instead.

Definition of 'section’

In typography a section was historically a device to divide a lengthy chapter into more digestible pieces (Wikipedia source). A flourish (graphic swirl) or three asterisks were the common method of illustrating a section break. Related to this idea is the use of the section sign § (U+00a7). In the provided source it is worth noting that “in written narrative such as fiction, sections are not usually numbered or named” but instead are “used to signal various changes in a story, including changes in time, location, point-of-view character, mood, tone, emotion, and pace.”

More recently (and generally) documents are considered to be divided into sections according to their “headings and subheadings, which may be used for a table of contents.” Thus, what @ROSt53 has answered is correct in this respect: you need only define your required headings and pull these into your ToC. If you are referring to a section as a formatting mark used to alter page layout (as per MS Word) or the text area of a page (as per LO Writer), that is an altogether different consideration.

MS Word

Since the advent of MS Word and its encoding of a section as a formatting mark most people seem to use this term in similar manner, whether they realise it or not. MS took the concept of a section (that of division) and used it as a way of designating changes in appearance. In simple terms they encoded it to allow for changes in the “layout or formatting of a page or pages in your document” (MS Office Word Help source). More specifically a “section break acts as an embedded code that stores or maintains the properties of the section above it” and combined with page properties allows for changes to: “Page Orientation (Portrait/Landscape); Margins; Columns; Line Numbering; Vertical Alignment; Headers & Footers; Page Numbering; Paper Size; Paper Source” (MS Support source).

In summary, how Word handles sections is broadly unrelated to text elements that might be pulled into a ToC.

LibreOffice

While MS Word and LO treat the concept of a section somewhat similarly, there are differences in implementation. In LO a Page style is the device that allows for changes to page orientation / size, margins, header / footer, page numbering, etc. As the name suggests, it is concerned with the elements of a page, rather than the text. A Page style cannot be used as the basis for a ToC entry.

The Insert / Section… menu item (and corresponding dialog) indicates which aspects can be altered through the use of a section: columns, indents, background, footnotes / endnotes. These represent changes in appearance of the text area of a page and are designated only in the XML (via the <text:section> element), with the one exception of a non-printing character (thin line) as a visual demarcation in the on-screen display. It is worth noting that the insertion of a ToC creates a section. This XML element cannot be used as the basis for a ToC entry.

There is no text (Paragraph / Character / List) style titled “Section” that exists by default. You could create a Paragraph style using this name (e.g., based on the Heading style), however the meaning behind this would remain conceptual (effectively known only to you). It could be a sub-chapter heading, or it could be an over-arching (grouping) heading that contains multiple chapters. The latter I would refer to as a “Part” of a document, thus I would likely have a different conceptual view of what a section heading might be. A Paragraph style can be used as the basis for a ToC entry.

Summary

On re-reading what I have written I am adding this summary for greater clarity. The Section facilities in word processing software (including LO Writer) are primarily concerned with changes in appearance. The idea of a section as a device for conceptual division of content (either historically into smaller pieces or as a way of grouping content), is best done via use of a text style. In some instances a Page style can be appropriate (stronger demarcation, pragmatics of fitting content, etc.) however it is rare to require the use of the Insert > Section… facility in LO.

@oweng - thanks for this great additional explanation!!!

I often wrap lists of short items in sections and I see this division as being both presentational and semantic: my lists’ sections are named according to the content and status of the list; visually, this also allows me to lay out the list on two columns so that it takes up less space. This is both meaningful and æsthetically sound. I have recently noticed that reference lists on Wikipedia are now laid out on two columns when the browser supports the CSS3 multi-column layout module.

Thanks for pointing out a case where the two converge. I don’t deny that there are such cases, however they are less common that the usage of the term “section” when describing documents in general. A section, as you have described it, is also useful for cross-referencing (semantically).

Yes, and in this sense they are also similar to HTML div elements and LaTeX environments.

If you can give each section a heading name it will automatically go into the TOC;. However this depends on how you want to structure your document.

Otherwise I recommend to read the help file and/or

https://help.libreoffice.org/index.php?title=Special%3ASearch&profile=default&search=table+of+contents&fulltext=Search

https://help.libreoffice.org/index.php?search=section&title=Special%3ASearch

All depends very much of what you want to layout and structure your document.