Box with title as a custom style?

I’m supposed to write a manual and there are three different kinds of highlights required. Notes, Cautions and Warnings. It is supposed to look similar to this mockup:

I try to come up with a style that applies the border (easy) and the word WARNING (fail) to a text selection. My experimentation led to nothing so far. That’s why I turn to you knowledgeable LibreOffice Wizards to point me in the right direction. Any clever idea how to achieve this?

Thank you for your ideas!

LO 7.3.4.2

This isn’t a style related answer so it is a comment.
You could insert a frame without a border (anchor as character) and inside that place the frame with the border (Wrap set to None) and then the frame (without border) with the word WARNING.

Warning79721.odt (12.5 KB)

Select the entire frame from end of previous paragraph to before start of next. Click Tools > AutoText and enter a name e.g. Warning Frame, it will suggest WF as shortcut. Still in the dialogue window, click the button AutoText and select New, then close. Now type WF and press F3 to get another Warning Frame.

1 Like

@EarnestAl’s suggestion is a good starting point but, from my point of view, it has the serious inconvenience that it disrupts the main text flow because it uses frames. Text inside frames no longer bears any ordering relationship with the main flow argumentation. This has serious consequences if you want to number your warnings. Consequently, you must avoid frames, at least for the caveat text.

I have reworked a bit EarnestAl’s sample as Warning79721-ajl.odt (26.4 KB).

I use a “standard” paragraph for the literate warning. It is styled Labelled Text (derived from Text Body):

  • border enabled with some padding (0.3cm here) to make sure there will be no overlap by “decoration”
  • spacing above paragraph increased a bit (0.2cm) to make room for the protrusion of the “label”

A “label” is superimposed over the border. This label will be WARNING, IMPORTANT, CAVEAT or whatever. Since this label must be positioned in an “unusual” location (i.e. outside the standard text flow), it will be contained in a frame. I therefore define a frame style Label:

  • anchored To paragraph, autosized (+)
  • position Left to Paragraph text area (but you may adapt to shift the label), Top to Margin so that the frame is already vertically centered on the paragraph border
  • wrap mode is Through and Allow overlap ticked so that the frame doesn’t interfere with warning text
    Since overlap is allowed, the frame interferes with nothing. So it is important to increase paragraph spacing above so that the label does not overlap the preceding paragraph.
  • spacing (in Wrap tab) will have no effect, except left spacing allows to shift the label
    This may prove more convenient than tuning position parameter in the Type tab.
  • no borders

I also defined a paragraph style Frame Label (derived from Frame Contents) for the “label”:

  • specific font face, size and weight
  • no border but left and right padding set to 0.3cm to “erase” the paragraph border and space a bit the “label”
    Although there is no border, padding is still taken into account. This is a handy trick to create space around a paragraph in circumstances where indents or vertical spacing don’t make sense. But here, indents could have been used.

To summarize, I have created:

  • one paragraph style for the warning text Labelled Text
  • one paragraph for the label Frame Label
  • one frame style for the label Label

Since this is a complex group, follow EarnestAl’s advice and create an autotext for the global structure

Notes:

  • (+) I met difficulties with Autosize in the frame. You may have to adjust manually the minimum size in the style to avoid line wrap.
  • Frame styles have weird update behaviour. When you change them, the selected frame doesn’t update immediately. Assign another style to the frame and reassign the modified style. Update occurs.
  • If you want to number your warnings (numbered list), don’t number the “label”: it is in a frame. There is no guarantee that frames will be numbered in text order. Instead, number the text itself.

EDIT 2022-07-24

I found the idea so appealing that I worked it out to make it usable. I incorporated it into one of my templates. Here is an example of the result as it prints:

The same with visual hints and formatting marks to show the “economy” in frames.

Since the construct is complex and errors may easily lurk in if the group is manually added, I created AutoText entries to insert skeleton Caution, Note and Tip groups. When an autotext is activated, all is left is to type the content of the bordered paragraph. Eventually, you double-click on CAUTION to overwrite it with CAVEAT. Everything is already styled as needed.

3 Likes

Good point. Ref tdf#143569 in 7.3.1.3 headings appear in correct order in Navigator, in 7.4.0.1 numbering rearranges to suit order of appearance, not order of insertion. Export to pdf and bookmarked frame text appears at the start of the pdf bookmarks, not in order of appearance so still problematic.

That is pretty awesome @ajlittoz. Thank you. It is my first real foray into AutoText and it works beautifully.

No so beautiful but easy is using ‘Drop Caps’, the position it’s not on the line, but avoids the use of frames.

2 Likes