Math symbols not italic

Upon editing a relatively old manuscript (odt file) with many math objects, I see that the symbols within the existing math objects, such as %alpha and %beta, do not appear as italic (as a variable).

I have tried to set the fonts inside the existing math object of this old file to be the same as in the default math object’s fonts in the new odt file. It seems to have no effect.

When I make a new math object on the old odt file, the symbols appear correctly (in italic); perhaps this is the effect after setting the fonts (I’m not sure).
But the existing math objects do not change. If I add another, for example, %alpha to the existing math object, the resulting alpha is not italic.
So in a single file, I can have two types of math objects, one with italic symbols and the other with not.

Is there any solution, so I don’t need to rewrite all math objects?
Many thanks!

LO version:
Version: 7.3.4.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 12; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Ubuntu package version: 1:7.3.4~rc2-0ubuntu0.18.04.1~lo1
Calc: threaded

OS: Ubuntu 18.04 LTS

There are perhaps two questions in your post.

General behaviour of Math objects in Writer

Every formula inserted in a Writer document is independent from each other and also independent from Math once inserted.

This means that you can’t control formula aspects with Writer styles. Look of formulas does not depend on Writer styles, you need to edit formulas inside Math to change their formatting.

Math “styles” are not forwarded as styles to Writer. So, once again, there is no unique location to change globally the appearance.

As mentioned above, every formula is added as a “foreign” object into Writer documents and loses any link to Math. Changing the “styles” in Math has no effect on existing formulas in Writer.

To change the look of existing formulas, you have no other way than reloading them one after the other in Math and make there appropriate changes. Not user-friendly.

Failure of formatting on new factors

When a formula is reloaded in Math, its “style” configuration is reloaded as well and replaces what you may have changed in Format>Fonts is overridden.

Regarding the %-symbols, I experience a strange thing: AFAIK the Greek letters are taken from font OpenSymbol which comes as a “straight” (Roman) variant. The letters are converted to italic by the font renderer. Despite all my efforts, I can’t get %-symbols not italic.

So, I can’t tell what’s happening in your document. There needs a deeper analysis which can be done only when you provide a sample file with one correctly-behaving formula and a faulty formula. Don’t forget to mention your OS name and LO version (the latter is of utmost importance).

EDIT after analysis

I saved your sample file as .fodt and opened it with a text editor.

In your “old” formulas, Greek letters are tagged as <mi mathvariant="normal">α</mi> while the attribute mathvariant="normal" is not present in “new” formulas. Removing this attributes canonises the Greek variables.

If you’re not weak on the heart, you can try the following:

  1. save your origninal file as .fodt (choose Flat XML ODF Text Document from the Filter: drop-down menu)
  2. open the .fodt in a text editor (not LO!)
    Text editors may complain about line length in the .fodt. Increase the line buffer size (procedure varies with text edditor) so that no truncation occurs otherwise you won’t be able to fix the problem.
  3. replace all == mathvariant="normal"== (== are her only to delimit the target string, don’t insert them in the search box) by nothing, effectively removing it
    Note I have put a prefix space at head of the search string (that’s why I used == to mark the effective start and end of the string)
  4. save the modified file
  5. open the modified .fodt in Writer
  6. if result is satisfactory, save again as .odt (perhaps under a different name so that you keep an unaltered copy of the original file)

Thanks for the tip, Mike.

Hi Ajlittoz,

I understand your first point.

The 2nd point: that is the point, I can’t change the %symbols to non-italic,
thus I don’t know how to convert non-italic ones to italic.
I added the version of LO and OS, but those are not the version of the old file when it was made.
It is the version I’m currently using.

I provided a simple file consisting of two math objects (old: non-italic symbols
, new: italic symbols).
The file itself is a copy of the old odt file (not sure if it’s relevant).
Thanks a lot for the help. :slight_smile:

copy_for_asklibreoffice.odt (20.7 KB)

Hi Mike,
Thanks, I tried it; in my LO the default is already “2”.

The problem is only happening in the existing math object from the file that was made probably a few years ago (as I received the file from someone else, I’m not sure about the history).
Unfortunately, there are many equations; if I could find how to convert them to have italic symbols, at least I don’t need to rewrite the whole equation.

GreekCharStyle property may also be changed dynamically (in addition to the change suggested by @ajlittoz); some basic code like

sub SetMode2
  Obj = ThisComponent.CurrentController.Selection
  ObjModel = Obj.Model
  If (Not IsNull(ObjModel)) Then
    If ObjModel.supportsService("com.sun.star.formula.FormulaProperties") then
      ObjModel.GreekCharStyle = 2
      If (HasUnoInterfaces(Obj, "com.sun.star.document.XEmbeddedObjectSupplier2")) Then
        Obj.ExtendedControlOverEmbeddedObject.Update()
      End If
    End If
  End If
end sub

@mikekaganski I tried to change GreekCharStyle property, save, quit, open the problem file and nothing changed. I think ‘mathvariant=“normal”’ has some overriding effect over the advanced property.

BTW, why did someone forced Greek letters to italics? There are %alpha and %ialpha between which user can choose deliberately. Now both lead to the same result. I think it makes more harm than the previous situation.

In fact, the real flaw is to withdraw %-symbols from the Variables/Functions/Numbers/Text classification. I know that %-symbols are displayed with a specific font (OpenSymbol) and that accepting them in the classification would probably break many existing formulas. So the definitive solution is quite difficult to imagine.

Hi @ajlittoz,

Thanks, it works!
Although, for capital symbols, such as %DELTA, %GAMMA, I saw that these symbols have mathvariant="normal" , in the new math version.
So I kept it like that.
It is still a fast process.
At least it works for now. Many thanks!

Sorry, what specifically do you mean? Do you refer to the Expert Configuration global option that configures the default, of do you refer to my macro (which should do its job on a selected formula right away, no reload required)?

It was a misguided 113276 – Math: Greek symbols and new OpenSymbol font that changed the original 2 into 0 first in 3.3.0 cycle. Then tdf#52225 requested a control; and then tdf#105483 changed the default back to 2.

You may read through those (lengthy) issues, and maybe @Regina can clarify further (see her comment).

@mikekaganski
How to do this exactly?
I’m curious because I never use coding in the LO.
So I even don’t know where to put this code.
Is it a macro?
Could you point me, for example, which literature… thanks…

Yes.

In your Standard library under My Macros and Dialogs that is available from Tools|Macros|Edit Macros...

Yes. I always try to do without macros (no skill in them yet).

Thanks for pointing out this information.

I’ll copy it here for the other readers.

“”"
Math formulas are based on MathML. There one character identifiers are usually rendered in italic in browsers. To get an upright character you need to set explicitly the attribute mathvariant=“normal”. That is attribute ‘nitalic’ in LibreOffice.

LibreOffice has the setting ‘GreekCharStyle’ with modes 0, 1 and 2 to determine how the character set ‘Greek’ is used.

Mode 0: all greek characters are upright
Mode 1: all greek characters are italic
Mode 2: uppercase greek characters are upright, lowercase are italic

The default setting is Mode 2. Your expected behavior corresponds to mode 0.

Depending on the mode, LibreOffice adds the attribute mathvariant=“normal” in MathML to force the character to upright, and adds no attribute in case italic.

In case character set ‘iGreek’ the attribute mathvariant=“normal” is never written, so that all characters are italic.

The character set ‘iGreek’ was introduced to make it easier for the user to force italic in case the user has set Mode 0. ‘%iALPHA’ is essentially the same as ‘italic %ALPHA’.

To change the mode go to Tools > Options > LibreOffice Advanced.
There click on button ‘Open Expert Configuration’.
Search for ‘GreekCharStyle’ (without quotations marks).
Double-click the item and enter ‘0’ (without quotation marks) for to get upright %beta.
OK, OK, OK. Restart LibreOffice.
“”"

once again thanks to @ajlittoz & @mikekaganski