We will be migrating from Ask to Discourse on the first week of August, read the details here

# Writer: referencing the same image again and again

Hello all,

When writing documents with caveats, a small icon commonly draws attention on such paragraphs like the check mark in:

This icon is inserted in front of every flagged paragraphs and there are as many copies as occurrences.

Unfortunately, this doesn't allow to change all occurrences of the icon for another one in a single step. Every occurrence must be changed manually.

Nota: an image cannot be bookmarked or cross-referenced which could have provided a (clumsy and too manual for my taste) solution.

An alternate approach is to use a link to a file. Changing the file content substitutes the icon in one step, but this requires to use a dedicated "frozen" filename to avoid the risk of losing the image or a soft link to the real image. The filename may be somewhat arbitrary and may no longer suggest the role of the file. The most serious inconvenience is the fact the the Writer document is no longer self-sufficient: when it is transferred, the image file(s) must also be transferred.

Is there a way to always reference the same image in a Writer document?

The procedure, if any, must allow:

• the use of the same single image
• replacement of the image by another one with effect on all occurrences
• no disruption on other single-use images

I rule out macros because I want a fully "automated" and "transparent" solution without manual action.

edit retag close merge delete

Of course not a solution, just a workaround.

The repeated images are stored inside as a single file (we make sure to deduplicate the images). You may simply replace the image you want, with another image - you only need to make sure it has the same name. The names in the package are in fact hash codes of the images, so you would need to check which is the many images with meaningless names is the one you wanted...

Ah, I see @Hagar Delest already mentioned file replacement.

( 2021-04-28 18:50:14 +0200 )edit

As a fool-proof method, I refuse to outsmart file structure by playing with supposed non user-accessible contents.

In addition, I didn't mention that the Navigator is full of meaningless Image999 for these decorative icons which do not bring semantic significance to the markup by a paragraph style. They clutter the Navigator and hide the really important images.

The bullet idea below seems promising though there are detail issues.

( 2021-04-28 19:08:18 +0200 )edit

Sort by » oldest newest most voted

Here is the workaround I implemented. I insist on the fact that this is an ugly hack in the absence of a proper reference mechanism. Thanks to all who provided bits of this workaround.

## Picture/icon must be in the margin

This requires a frame so that it can be positioned outside text area. Frame style MarginIcon is created, derived from Graphics so that is anchor mode is To paragraph by default.

Position properties are adjusted to send the frame in the left margin centered vertically against the paragraph.

Size is set for a 1cm square (this is my requirement). Wrap is None with no spacing.

## Picture/icon is a bullet

List style MarginIcon is created where all levels will only differ by the bullet. This allows to manage all pictures/icons with a single style through the use of the Tab key.

Alignment is left 0cm, indent 0cm, Number followed by Nothing.

One image/picture is assigned to each level with Number Graphics, Graphics Select From file. In my case, these are .png files.

Due to a bad behaviour of graphics rendering by Writer (already mentioned on this AskLO site: drawings made in Draw are not displayed "as is" by Writer, but there a ~3% size difference; apparently this happens also on .png files), the bullet size needs to be slightly scaled to avoid interpolation resulting in visible distortion. This is fixed by setting Width and Height by trial and error.

## Internal frame content

To display the image/icon inside the frame, a list item paragraph must be entered. A dedicated paragraph style MarginIcon is created. It is derived from Default Paragraph Style so that any modification on other styles has no effect on it. Font size is set to 2pt to make content nearly invisible if any is typed by mistake.

List style MarginIcon is attached to it in Outline & Numbering tab.

A careful reader will have noticed that all three created user styles have the same name MarginIcon. This is possible because they live in different namespaces: paragraph, frame and list.

## Placing all bits together

1. A frame is created with the cursor in the paragraph to decorate and styled MarginIcon
2. Cursor is put inside the frame and paragraph is styled MarginIcon. Tab is pressed optionally to select the desired icon.
3. VERY IMPORTANT! Writer does not like empty list items. It may remove the number/bullet because a single bullet in a line does not make sense.

To protect against spurious editing causing the bullet to vanish, Insert>Formatting Mark>No-width No Break is added so that the paragraph is not empty. This character has a zero width; it does not change formatting.

Note this is Unicode nonsense because this WORD JOINER U+2060 is intended to prevent two characters from being separated (no line wrap). Here I use it stand alone.

This tedious set up needs to be done only once. Next time, you just copy and paste the previous frame, eventually changing the ...

more

Do it this way:

1. Create a new bullet style. Name it whatever you like, e.g. Again-list.
2. Create a new paragraph style. Name it whatever you like, e.g. Again.
3. In this new style, determine from which it inherits properties and what will be next. Also change its properties so that the word "Note" has the appropriate format. Then, on the Outline & Numbering tab, set the Numbering style Again-list in the list, open its settings, and on the Image tab, click Add & Resize to create a bullet from your own image.
4. Click on that new bullet and write down everything.

From now on, the paragraph that you format with the Again style will contain your image. If you want to change this character everywhere, you just change the style accordingly.

And that's probably all

The best thanks for the answer is clicking on the picture so that it turns green

more

This is a good suggestion but does not fit well in my workflow (because of incomplete requirements in my question):

• a list style takes over left indent and first line indent and conflicts with same paragraph attributes
• right indent become impossible to set (I experienced instability in the past with it)
• the "bullet" is anchored As character

In the case of an image, it will force space above or below the line which is not always wanted. Instead, I prefer this icon to be vertically centered across the paragraph, which is not possible with a bullet anchor mode.

• the bullet is positioned inside the border of the paragraph while I prefer it to be in the margin, outside the border because the image is off-text in my case while a bullet is part of the text and set inside text area

But this confirms that Writer already has some mechanism ...(more)

( 2021-04-28 18:14:03 +0200 )edit

To give you a better idea of the goal, here is a more personal example:

( 2021-04-28 18:19:34 +0200 )edit

That bullet style inside a frame?

The frame and the style being stripped down to bare bone so that only the bullet remains.

( 2021-04-28 18:31:02 +0200 )edit

Path to explore. Seems to be a promising workaround (workaround only because of the complexity).

From quick experiment, requires to modify the frame style (perhaps creating an ad hoc one), to create a dedicated list style and a dedicated paragraph style. To avoid fancy formatting initiative from Writer, the paragraph should contain at least one space (with empty paragraphs the bullet is not guaranteed to remain there). Quite tricky to position accurately because of the "safety" character. Clipping sometimes occurs (only noticeable at high magnification).

Need to study it carefully. Will report here.

( 2021-04-28 18:54:33 +0200 )edit

At some point there is an action needed.

Except changing the pic file in the /pictures folder of the odt package, I don't see any other way. Or that would require a field that supports more than mere text.

more

Not acceptable. I ruled out macros. I don't want to interfere in any way with the file structure either. What I'm looking for must be done from the UI or some hacky configuration in image properties or I keep on my manual procedure.

I fear it is related to some limitation in ODF.

( 2021-04-27 19:00:39 +0200 )edit

It doesn't have to be through a macro. Merely editing the .odt with an archive manager and replacing the relevant pic. But not very user friendly.

I also fear it is an ODF limitation.

( 2021-04-27 19:09:28 +0200 )edit

"Macro" does not mean your proposal is a macro. But it belongs to the same kind of procedure: patching the XML file structure (and ancillary data) outside the style machinery.

Anyway, it does not address the main point: referencing the same picture from several paragraphs/frames. Once this is done, modifying the existing picture is the easy part. I feel referencing could be done with some macro trick but this direct-formatting will create havoc in the file and is probably unstable or extremely vulnerable to editing/file saving.

( 2021-04-27 23:07:10 +0200 )edit

Use a paragraph style's Area set to Bitmap; its style set to Custom position/size, position set to Center Left. Use borders and their padding to make sure that text does not overlap with the image (note that border may be None, it will not prevent padding from working).

Problems:

1. I think that without tricks like having a white/transparent margin as part of the image, you will be unable to not have border touch the image (if you need border)
2. There's a bug that every time you edit the paragraph, the custom size resets to the image's original size (in my 7.1.3.1). I have to reopen the paragraph settings, modify the size, and save. Needs reporting.
3. It will be applied per-paragraph.

Other backgrounds may be also used, like frame's/section's/table's... combinations could provide interesting options.

more