Collapse/Expand text in Libreoffice writer?

Hello there, first I would like to say I think this question has been asked before [Text folding, pretty please!] but that was in 2012 [i think, the format’s a bit confusing], it’s almost been 8 years since it’s asked! so basically my question is, is collapsing/expanding text or “Folding” text a feature that’s in the latest version of LibreOffice [I think 6.4.3], or at least is it a feature that will be available in the near future?

The original post explained it quite well, but here’s what I mean by collapsing and expanding text.

So you would have a title, and some text, and a little button next to the Title

And then if you click the button, it would hide all the text that’s parented to the Title:

I think that this is available in the navigator, but I mean in the actual document

Although it certainly is a much desired feature, what would it mean in Writer? Writer is a tool for formatting documents, i.e. it takes a flow of paragraphs of text and formats it into a sequence of pages with nice spacing and other typographical artefacts. When you collapse a group, what should happen? Should Writer reflow the whole document, omitting the collapsed text and thus changing all references, notably the TOC and indexes?

The answer to this question depends on whether you use Writer as a mind-mapping tool or as a generator for a document with variable content.

This must be sorted out before implementing the feature.

My solution is to use the navigator window under the ‘View’ menu. This serves as a seperate window with the table of contents - and you can dart around your document by clicking on the Headings in the Navigator window. Not sure if this helps you - it helped me.

That is actually a great tip, thanks for sharing!

This is a feature (expanding and collapsing text) that I can’t live without and I used it all the time in Word when I was using Windows.
I was disappointed to find out that LibreOffice writer does not have this feature.
The feature is available in an online app called Dynalist and that is what I am using now.
Other option is to use Google Docs and then “view outline”, but there is no way to expand/collapse text in it

This is not an answer please delete and post a new question if you want to know how to see the Headings, images, tables, etc. in Navigator.

Otherwise, please click more just below your answer and click Repost as comment

While writing my comment, a workaround came to my mind.

Writer has a feature called hidden paragraph. It is a special field found in the Functions tab. Depending on the value of a designated variable, it makes the paragraph into which it is inserted hidden (value 1) or visible (value 0).

You can then define the variable somewhere else to toggle the paragraph visibility. This variable may be disguised in a form of a button to make its use more-user-friendly.

Experiment.

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!

In case you need clarification, edit your question (not an answer) or comment the relevant answer.

Ah, so there isn’t a built-in feature for this, that’s a bummer, although, what you said does sound like it might be what I’m looking for, but I’m a bit new to LibreOffice. I found this page [Hiding Text - LibreOffice Help] and I managed to hide text, but I don’t know how to connect it to a button and then make it toggleable, I’ll keep searching on google but if you know it would be greatly appreciated if you could tell me!

I will mark your answer as the correct one since you pointed me in the right direction I think, so thanks :smiley:

Kind Regards

It is very easy to insert a checkbox right before the paragraph you want to expand/shrink. You then connect a macro to the “status changed” event to transfer the mark state to the controlling variable of the paragraph.

This is the idea. Unfortunately I have not yet written any macro and don’t know how to code the connection. Maybe other knowledgeable gurus reading this question and comment could provide a sample.

It’s not really easy for me to understand the importance of being collapsable, but I know the respective tool implemented for web sites. (It’s funny, however, that in en.wikipedia.org e.g. the clickable hide and show are positioned in a way making me think they are for hiding/showing the content itself instead of the index. Being funny is human.)

Anyway: The appropriate means to create collapsable text content might be TextFrame objects. Since @ajlittoz already suggested to use macros, I made a demo showing what I would try if I had a related need at all.

The attached document contains two examples of applicable code.

The even simpler Sub named toggleIsAutomaticHeight can toggle any TextFrame between the states of being reduced to its height set as an absolute value via the Properties, and the state of being expanded to automatic height (showing all content). This macro is assigned to the sensitive area of an included toolbar myExtraToolbar. It will be called for a frame directly selected or for one containing the current text selection.

The slightly more elaborate Sub named toggleFrameIsAutomaticHeightRegardingStyleName will also toggle a frame of reduced height to automatic/full. The reverse action depends on the name of the FrameStyle. If the Sub can extract an explicit minimum height from there, it will be applied. Otherwise the frame’s state should remain unchanged. In the example this maccro is callable from the context menu of a selected frame.

Both macros have an unused optional parameter. It is included to hint that an enhancement can implement a diversification of the action depending on modifyer keys pressed in addition when the macro is called by clicking into a toolbar. Menu items dont pass such information.

Both macros can also be called via the menu, of course.
ask242601toggleFrameHeight_1.odt
Have a lot of fun.