Centering lines vertically and horizontally

Hi all!

I’m trying to vertically center lines of text within cells, plus horizontally center them by the longest line. The text should be left-justified. This way, both long names and short names will look good on the labels I’m printing.

The goal:
Screenshot 2023-10-31 172323

The sticker sheet manufacturer provided a template, which was originally a table in a docx file, though it’s now saved as odt.

But I’ve run into a dead-end, where I either can’t get the text to word-wrap, or I can’t keep it from floating to the top of the cell. (Sorry, I’m a new user so I can only embed one image)

The frames which won’t word-wrap, are set to center by row, as character. And the frames that float are set to center to character and follow text flow. Size is auto-size.

My text style is frame contents, with a font change, hyphenation enabled, and justified with snap to grid.

Table style is vertical alignment centered, with “allow table to split” disabled.

I’m unsure if I should really be using Labels, not Writer. Or if I do stay with Writer, which style I need to dig into. Feedback or fixes would be super appreciated! I’ve attached the file in case there’s some other goofery I’ve committed besides what the style info shows.

blank labels.odt (12.6 KB)

Oh and version is (X86_64)!

1 Like

I can’t keep it from floating to the top of the cell.

Try Format > Anchor > As Character. Then paste your frame in the cell and it will solve this problem because LO will now treat the frame as character.

However you’ll have to choose between automatic frame size (which means you’ll need to manually wrap/hyphenate the contents) or manual size if you want to use wrapping and hyphenation.


Sorry, I phrased my post badly! I’ve tried frames anchored “as character”, which, yup, does require manual hyphenating. Though that’s easier to handle than the text flying up and away, I’m still curious if there’s any way to have it automatically wrap as well.

Try using a single page for each card with the width/height ratio of the card.

Each page should contain a frame anchored as character. Frames do limit themselves to the size of the page, so your wrapping issue is solved.

Then print your pages using LO’s ability to print multiple pages per sheet.

This is actually a cleaner method and you can use styling to define your cards unlike tables which cannot be currently styled in LO.

Why do you use frames inside a table? This is “double-kill”. Tables allow to “structure” space into separate homogeneous rectangles in columns and rows. Frames are a way to “escape” the organisation created by text flow or table grid. So using both in the hope to make them cooperate is a bit contradictory.

To add to confusion, you applied direct formatting (at least on the second lines of your “labels”. Direct formatting takes precedence over styles which disables the changes you can make in the styles.

In blank labels.odt (13.1 KB), I copied text from the frames to paste it in an empty cell and cleared direct formatting. This text is styled Frame Contents because it originates from a frame. I didn’t modify this but it is advisable to style as Table Contents since it is more logical. I only changed alignment to Center in Frame Contents style. Now your text is horizontally centred in the cell because the offendng direct formatting has been removed.

The reason why your initial approach didn’t work is probably related to the horizontal AutoSize (which is not very reliable from my own experience, at least when paragraph text is expected to wrap). In your second cell, text is wide enough to occupy the whole cell, which cause line wrap in the anchor paragraph.

Anyway, mastering the subtleties of interaction between frames and text (and all the more when a table is involved) is not elementary. So avoid, these high-level features when this is not necessary.

I also note direct formatting in your cells where 'empty) text is 11 and 12pt while style Normal (a signature of old .doc files – not .docx) is configured at 11 pt.


This is really informative, thank you!

Honestly, one of the reasons I combined frames and tables is because Word lets you put text boxes in tables. Not the best logic, in retrospect! But also because I don’t see another way to keep the text left-justified while still centered within the cell.

Belated context: I’m a library worker. These stickers go onto book spines – the entire sticker isn’t always visible. Having the text left-justified ensures the beginning of each line is visible, even if the book is thin. Centering text muddles long names. Imagine that just the highlighted portion is visible.

Screenshot visible

But left-aligning text looks off if the name is short and the sticker on a wider book; the white-space ends up being what’s centered.

So, I’d rather not rely entirely on tables unless tables can center their contents by longest line in a paragraph. But I also can’t use frames exclusively, unless frames can be made rigid enough to ensure each sticker prints properly.

Last time I did any webdesign, I used Bootstrap for responsive containers. It’s not something I’ve used css for personally, but that knowledge is out there. Because I am 1000% a novice, I’m 0% confident in my ability to code myself out of this problem, but would that be the thing to start looking into?

Weird inconsistencies found in the Normal style and direct formatting are from me not restoring to the original template before trying different approaches. Extremely bad habit I need to fix. Good call on the original file not being docx, it was dotm.

Try using your own labels (File → New → Labels).
In these the frame can be centred in the middle.



Now that I better understand your need, I can suggest a workaround. It is only a workaround because the feature as described does not exist in Writer. The workaround requires a lot of manual editing but I think it is equivalent to @PKG’s solution. However, his solution involves nested frames (set by the label wizard) and it leads to the same difficulties already described.

My workaround is based on nested tables.

  • the “outer” table structures your sheet for labels (you can add “shadow” rows and columns to account for extra margins or gutters between labels)
  • you insert a table in every cell
    You can choose between a 1×1-table or a 1c×nr-table. In the first case, you have n paragraphs in the cell. In the second case, you enter a single paragraph in each cell, thus allowing you to easily handle missing data if each line has a specific meaning (author’s name, ISBN, publisher, year, …).

The “inner” tables are constrained in cells of the “outer” table; their width is limited to the cell size. You can set manually the width and require center alignment. Inside the “inner” table, text is left justified. If you tune the table width, the table is centered relative to the widest text and all text inside remains left-justified. See
AskLOTblInTbl.odt (12.6 KB) (first table).

You mention the fact that books have not all the same thickness and you want the beginning of the text to always remain visible. There is perhaps a simpler way of handling your labels: have the text start at a fixed distance from the cell left edge. Then labels are always glued at the same position on the back cover and folded on the spine and front cover. The label will extend a variable distance on the front cover but text will always be positioned correctly on the spine.

This alternative does not need nested tables, frames nor manual tuning. See second table in example file.


Ahhh, thank you so much!! This is basically perfect. I’m so happy!

If you happen to have time, I have four more questions:

  1. With “Keep inside text boundaries” toggled on for frames: longer names seem to respect cell dimensions and padding, except cell borders look thinner within Writer. Does that matter?

  1. Pasting unformatted text into a frame causes the frame to float to the top. If this is unfixable, that’s totally fine. But if there’s a way to paste into a frame without this happening, it’d be good to know?

  2. Shorter names are printing center-right. They look centered in the .odt file though. Any advice on how to troubleshoot that?

  3. To double-check, the way to set up my label sheet is to manually insert a frame into each cell with the direct settings I want (autosize on, border off, etc). Since “anchor to: frame” isn’t an available option when trying to edit frame style from style navigator.

Seriously though, thank you again. This is muuuch better than what we’ve been doing.

I didn’t know nested tables were even an option, that’s good to know! Because the centered nested table isn’t going to center by longest line automatically, I think it’d have the same drawbacks as simply typing into the cell, while, like you say, being more complicated to set up.

Regarding where label placement, you’re totally right! And that’s in fact what we do. It works great for thin books. It’s just on larger books these left-aligned labels look bad. But they’re fully legible, which is what matters most for sure.


Answers to your questions:

  1. Keep inside text boundaries does nothing on cell dimensions or other attributes. When you set vertical dimension to AutoSize, the frame grows downwards. Since you can position a frame anywhere in a page, the growth may cause the frame to extend in the bottom margin or even become clipped at bottom because it grows beyond the bottom limit of the page. Keep within text boundaries will automatically shift the vertical position to avoid this (the position you set is then only a hint for optimal location) or even send the frame on next page.

    In your case, this is not a good idea because this will desynchronise with the label grid.

    Cell borders on your screenshot seem to be only visual clues from View>Table Borders, not real borders. So, this may be a display artefact or a psychological bias.
  2. Pasting unformatted text
    I don’t understand what you mean by “causes the frame to float to the top”. When you paste something into an object, this object becomes selected. Is this what you’re talking about?
  3. Shorter names
    Do you mean you have a difference between screen and print? Otherwise, it can be a consequence of mixing table and frames.
  4. I think that using a frame to constraint some data to a cell won’t work because the frame feature is an “escape” from the current flow constraints. The frame is not limited by the current object, only by the page. To constraint inside a cell, you must use something which is jailed inside the cell. This can be a table or a paragraph.
    In any circumstance, always choose the simplest solution. It usually avoids headaches.
1 Like