Writer: how to associate a margin icon to a paragraph style?

To draw reader’s attention to important paragraph, it is usual to display an icon in the left or right margin. I know of 3 ways of doing that:

1. Table

You create a 2-column table.
The icon is inserted in the first cell and text is written in the right cell.
Each cell can have its own formatting and the icon can be vertically centered against its companion text.
The table border can be used to advertise the extent of the decorated text.

2. Picture anchored at paragraph

A picture is inserted from a file and its position is set from Format->Picture.
For example, anchored “To paragraph”, -1cm “From left paragraph border”, vertically centered.in the paragraph text area

The picture itself may be copied into the document as Graphic999 or linked to the external file.

3. List style

A new list style is created and customised in the Options tab: “Numbering” = Graphics, “Graphics” point to the file. but “Alignment” is limited to positions on the first line (said otherwise, it cannot be vertically centered on the paragraph – it is equivalent to a number or a bullet).

What I need

I want to design a paragraph style which associates some text with a margin icon and be able to change the icon in a single place for all occurrences of this style.

Solutions 1 and 2 above duplicate the picture as many times as there are occurrences, which means the necessity to change the pictures one by one. With solution 3, the icon is considered a character in the first line which changes the vertical height of this first line and causes ugly wrapping around the icon if text is long (unless the icon is flushed in the left margin, but it does not change the first line height issue).

Unsatisfactory solution

Solution 2 above may be mitigated using an indirect link: the file name in the “Picture” tab of the Format->Picture dialog is a “link” file, e.g. pict.lnk.
The real picture is defined from this link with shell command

ln -s the/real/picture.png pict.lnk

When I want to change the icon, I only change the symbolic link.

However, this is not satisfactory:

  1. The link is external to the LO document and there is the risk to forget to transmit it with the document, or even to forget what it’s used for.
  2. Two files must always be kept with the document: the link and the picture files; their number grow with the number of “styles”.
  3. The icon is inserted just like any other character, it is not inherent to the paragraph style.

Is there a solution where a single instance of the picture is kept in the LO document with an easy-to-change field definition?

Of your three indicated options, #2 is the ideal solution, however as is often the case, it is not as simple as placing an image in the margin. The only way I know of to associate a graphic with a text style, is as a background. You could perhaps define your graphic (or link it) as a background to a frame style. This way you only have one additional style to manage. More about this at the end.

Margin Notes a.k.a. marginalia or side notes

Presently this type of facility is only available in DeskTop Publishing applications. LO can be forced into providing a limited mimic of this type of functionality, but it is rather crude. This thread discusses the same sort of issue and provides an example document. A fully-featured facility needs to consider enclosing, anchoring, and reference, very few of which are fully supported. Any proposed implementation requires not only some mechanism for placing content in the margin, but also enclosing multi-type content in a container, anchoring it to a paragraph, and in some circumstances (not yours) supporting a cross-referencing identifier such as for footnotes / endnotes. What you appear to be after is more a graphic-identifier that has elements of an unordered list item / graphic background.

Related bugs and enhancements

Frames can be placed in the margin and even anchored to a paragraph, although bug fdo#32484 indicates that anchoring is not without problems. Frames are also inelegant to use as certain content (e.g., cross-references) are not supported in them as indicated by bug fdo#48534. This is not likely to bother your particular use-case. Enhancement request fdo#44597 has been raised to attempt to get LaTeX-like identified notes in the margin, however this will be dependent upon the prior two bugs being fixed. There is a Marginalia frame style (and paragraph style) that has been created expressly for this particular situation, but again it exhibits problems when used with some language packs e.g., fdo#40073.

Possible solution

As I initially indicated, I think you can achieve what you require using the Marginalia frame style and setting the background to your required graphic. You can even link the graphic if required. This frame style will however be independent of the corresponding paragraph style. Here is what I have achieved in v4.1.0.4 under GNU/Linux:

screenshot of marginalia frame

  1. Page margins are 72pt (1 inch).
  2. The Marginalia frame style is set to be 72x72pt in size. The background is set to use a “Graphic” (PNG) with the “Position” set centred. Borders are turned off. Frame is inserted with the cursor at paragraph beginning. Anchoring is “To paragraph”, set “Left” of the “Left page border”, and “Center” of the “Paragraph text area”.
  3. I have indented (18pt) and set the text in red of the corresponding Marginalia paragraph style for clarity. Before / after spacing is 18pt.

Thanks for this answer.

Option #1 is the one used in LO guides.

Your variant of option #2 implies many manual steps and does not address “user convenience” I had in mind: just style the paragraph and everything is done automatically.

Thinking over it again, my problem is similar to decoration of an unordered list paragraph and closer to option #3. The difference is: a bullet, even if taken from a graphics file, is a character laid out in the normal sequence of glyphs.

(Continuing previous comment)
“Bullet & Numbering”->“Options” tab, “Alignment” parameter could perhaps be extended with “Format”->“Picture”->“Type” tab, “Anchor” parameters to ‘detach’ the bullet from the paragraph.

I even think of possible lay-out designs where the number for an ordered list item paragraph could be vertically centered in the margin.

I do not know if this could be implemented for free in present Writer. However, I am aware this means that a “character” is transformed into a frame and this is not as simple as said.

@ajlittoz, your use case falls in an area that does not neatly come under list, graphic, frame, or table. It seems closest to list for the reasons you indicate, but could be more like a margin note (i.e., a frame) as a facility. Unfortunately though even fdo#44597 is unlikely to provide what you require. The use of tables in the Guide is a workaround as no current facility exists. The heart of the problem is that of a graphic in a style, as you suggest. Do you know of a precedent e.g., Word?

@oweng, I know of nothing similar, but perhaps a very old document processing system (named DPS) developed at University of Maryland to run on Univac hardware under Exec VIII system (that was in the '80s).

Concept was quite different since this application was macro-based, a bit like Tex: a macro could be a rough equivalent to a style or an XML tag.

There was also UNADS (UNivac Advanced Document System), a proprietary software now defunct, which could positively do that, but it was closer to a destop publishing application than a word processor.

fdo#44597 has a wider scope: a margin note contains “variable” text (i.e. every occurrence is original) whereas my case only requests automatic insertion of a fixed graphics or symbol.

@ajlittoz, I asked about precedent because if, for example, the OOXML specification defines this type of relationship (between graphic and paragraph style) then it will need to be implemented for compatibility reasons. You are right that fdo#44597 has a wider scope, but the linking principle (between paragraph and frame style) is the same. You could always raise a new bug and link it with that bug, but you will need to provide plenty of detail to ensure distinction.

Seems I managed solving the case by using paragraph style which uses –

  1. Bulleted list with space character (invisible) as bullet.
  2. Background SVG image (exclamation mark) with custom position/size and placement “left middle”
  3. Negative First line indent (-1,2 cm)
    Currently using LO 6.3.3-0ubuntu0.18.04.1

Here’s a development of the “Marginalia” frame suggestion from @oweng (which looks like the closest possibility, IMO, just now):

Rather than using a graphic (e.g., PNG) with it, what about using an icon- or dingbats font? The advantage this brings over a graphic is twofold (or so it seems to me at the moment):

  1. As of 4.1, LibO can embed fonts, so that takes care of “portability”;
  2. Since this is a font, it is trivial to change the icon/dingbat character with simple find/replace tools on the “font”.

I just tried this using the “Webdings” font (right now I’m on Linux Mint 13 Xfce, LibO

Fairly trivial to implement, and reasonably simple to adjust and maintain.

@ajlittoz - You don’t say what kind of graphic you’re interested in. My hunch, though – given the use case – is that something that meets the need would be found in a dingbat/icon font. Most OS’s come with some dingbats or other installed. There are oodles of possibilities these days, though:

Maybe? Just a thought!

@dajare: my need is basically what you exhibit in your screenshot, like awarning “road-sign” aside a very important remark (usually preceded by word “Important!”) and casual note of interest (e.g. the “information” icon above).

I didn’t think at first of dingbats fonts because I was focused on the theme color icons that ship with Linux distros.
Unicode also defines many (now) standard icon/glyphs.
This is a monochrome (not necessarily B/W) replacement for graphically complex icons.

@dajare (Cont.) - However, this misses my point on automation: I’d like this margin symbol/icon/glyph to be implicitly added as soon as the paragraph style is chosen. In multiple editor context, it seems to me important to ensure consistency in document appearance (kind of QA issue).

If this can be achieved, the way it is implemented (frame or other) no longer matters.

I have the same desires as ajlittoz. This is very important for professional quality technical documentation. To manually place and maintain anything not directly part of or tied to the paragraph style is a maintenance headache, especially through translations.
The only solution I can think of given these limitations is to write a script to post-process a flat ODT file to add in the graphics next to the paragraphs of the correct style.