Formula and text do not align


So, I have this formula but I wanna create it on LibreOffice Math where they are perfect clones of each other. The one on the top is done with regular text (Liberation Serif, Bold, 11, line spacing of 1)
The one on the bottom is done with Math. However, even if I reduce spacing to 0%, the minus signs simply don’t align. What am I missing? The math formula also uses Liberation Serif Bold, 11 (Italic for variables)
Even with line spacing set to 0, the space between the lines in Math formula is larger.

Could you give a better specification of the goal?

Your image seems to be a superposition of two pictures. Which is which?

You have “n-2” and “6” on two lines in the same formula? Do I understand you created one with standard text, the other one with Math?

If so, Writer uses its own “text” spacing rule. Math considers the various elements as graphics objects and positions them with “graphics” rules. Consequently if your complaint is about the position and size of the “minus” sign, there is little which can be done (even the character used for the “minus” sign may be different).

Please explain which “spacing” you tweaked: the one in Format>Spacing? Which Category? Which parameter?

For best advice, attach your document so that we can see both the initial picture and formula expression. Don’t forget to mention OS name and LO version.

Thank you. My goal is to understand how math formulas work and I am missing a few attributes to customize to make it look exactly like if it was created with regular text. I wanna know exactly what I am missing so it doesn’t snowball into bigger issues.

Your image seems to be a superposition of two pictures. Which is which?

You have “n-2” and “6” on two lines in the same formula? Do I understand you created one with standard text, the other one with Math?

Yes, it is two lines, the top line is n−2 and the bottom line is 6.
The one that is shifted down is created through Math.
I only changed the “Spacing” and “Line spacing” options on the “Spacing” category.

Before I move further, could you please confirm that I could adjust the formula to look exactly like its regular text counterpart?
Currently, even with Spacing at 0%, the text in math formula seems to be wider. How do I get it to be like in regular text?

Send the document so that I can experiment with your own data. Personally, I never felt the need to have the exact same look between text and formula object. I consider they leave in different realms. If your goal is to cite “n-2” in text as a reference to the formula, you can insert this short formula, be it a single variable name, (I do so, even if this seems to be overkill in the majority of cases; but it guarantees the same look: same font face, size, angle, weight, …).

There you go :slight_smile:
MATH FORMULA SPACING TEST.odg (14.0 KB)

I thought you were in Writer. You’re in Draw where text is hosted in Text Boxes. Text is managed in a lot more sophisticated way in Writer than in Draw which has only text boxes. Basically, you have what the font metrics offers, not more.

I checked the minus sign is the same: U+2212 MINUS SIGN.

At high magnification (1800%), I see a tiny difference between the text box and the formula. With horizontal spacing set at 0%, the formula is slightly wider, as if some very thin space was added between characters. Line spacing is also affected, in a somehow more pronounced way than horizontal spacing. At 0%, the formula second line is slightly higher than the text box; at 1%, positions are exchanged. The “good” setting seems to be 0.5% but the configuration dialog only accepts integer values.

From my point of view, the difference goes unnoticed under “normal” zoom factor. It all depends on the kind of document you want to create. I’d say the difference does not deserve the effort to attempt to fix it.

So, if I understand you correctly. Setting line spacing to 0 or 1%, and 0% for just spacing is good enough at normal zoom factor, right?
My goal in asking this question was to know what to do if I had to create a formula with, say, 1.15 Line spacing. Now, how should I adjust the percentage values if I don’t understand the relation between two units?
Do you think this is a bug, by the way?
I can see how this could snowball into bigger problems.

I noticed that if i wanted the regular text box to align with the formula vertically (where the formula has its spacing set to 0%), I’d need to set line spacing to the custom value of 4.80 mm

I still don"t understand you exact need. You sent a Draw document. A Draw document displays a collection of graphical shapes not related to each other. Consequently trying to align text overlaid on shapes does not make sense. If your goal is to “match” multi-line text in shapes, you’re doomed to fail. The solution is to split your shapes into single-line ones. Then you can adjust very precisely these elementary shapes to create the illusion of huge composite blocks.

The problem is different in Writer. Writer has a sophisticated management for paragraphs. You can insert formulas in text. Since the majority of formulas are single-line, the frame is anchored As character, making part of the text line, in which case it aligns “naturally” and is entirely managed by Writer.

Multi-line formulas will not be inserted the same. Their anchor will be To paragraph with a wrap mode such that it does not interact with text and some padding space separates the formula from it.

The only reason I see to make text and formula cooperate is a desire to “comment” or annotate lines in the formula. This is clumsy and, sure, it will the snowball. The “correct” way of handling this case is to label the formula lines and reference the label in standard text. There are directives in math allowing to lay out element in a tabular way. This is mainly used for matrices but you can use the feature for other purposes; After all, Math is not a mathematics processor, only a specialised drawing program, and it does not care for the math accuracy of what you describe.

Manage this outside Math:

  • in Draw, use single-line shapes (text boxes or formulas) and position them to you taste
  • in Writer, use also single-line formulas and customise paragraph line spacing
  • or, with Writer frames for multi-line formulas (such as a system of equations or a matrix), put the formula in its own frame, independent of text, and write separately your text

Difficult to answer the question. As far as I know, identity with check boxes was never requested.

For my own needs, I’d say “no”, but you may have other expectations. Once again, describe as precisely as possible a real use case.

Where? In Draw?
What happens if you change font size? I rather recommend you define a style where all parameters are grouped so that everything scales nicely when you change one parameter. In a style, you can use other units such as line height percentage or font size percentage. Another advantage is the fact that applying a style guarantees homogeneity across shapes and automatic update when you modify a style.

So, what I need is simple. I wanna know how these two measurement systems “translate” into each other. I can create single line shapes as you suggested, but isn’t this making things way too uncomfortable?
I want to understand how units work so I can replicate text with certain line and character spacing in Math. If I have two lines on a text box and I need to type text with mathematical formulas, understanding how spacing in math formulas work helps me “match” the exact feel of the text box.
As you said earlier, there seemed to be a think space between characters when you thought you adjusted them correctly. I wanna understand why it happens. :slightly_smiling_face:

Where? In Draw?

Yes, in draw. I have to experiment with different font sizes of course. Where do you recommend I ask around to get to the bottom of this?

The bottom line is Draw and Math are different applications. They use the same basic “tools” for text composition but I guess that Math does extra tricks to make sure “composite elements” such as scalable brackets or integral signs display nicely. These tricks certainly have feedback (retroaction) on the font renderer.

Math has not known any notable evolution for ages. It does not draw as much attention as Calc or Writer. You can consider it as a “pre-historic program” surviving in contemporary technology age.

A definite answer can only be given by a developer if any, a maintainer at least.

I hope one of them reads this topic.

1 Like

Thank you, just to reiterate, I do realize that they are different programs and there is something specific to Math that causes this discrepancy. I wanna know what that is so I can adjust for it. I wasn’t expecting this at all. I thought if it is a “clean” formula with no extra elements, adding a second line would work just like it would with regular text. I do hope they read this as well.