Math equation changed when the doc is saved

I write the equation like

the code is
stack { alignl R = {R} rsub {yaw} {R} rsub {pitch} {R} rsub {roll} = left ({r} rsub {1} {r} rsub {2} {r} rsub {3} right ) # ~= left (matrix {cos left (α right ) cos left (γ right ) + sin left (α right ) sin left (β right ) sin left (γ right ) # cos left (γ right ) sin left (α right ) sin left (β right ) − cos left (α right ) sin left (γ right ) , # − cos left (β right ) sin left (α right ) ## cos left (β right ) sin left (γ right ) # cos left (β right ) cos left (γ right ) , # sin left (β right ) ## cos left (γ right ) sin left (α right ) − cos left (α right ) sin left (β right ) sin left (γ right ) # − sin left (α right ) sin left (γ right ) − cos left (α right ) cos left (γ right ) sin left (β right ) # cos left (α right ) cos left (β right )} right ) }

when this equation is saved and then open again, the equation is changed to

the code is

stack { R = {R} rsub {yaw} {R} rsub {pitch} {R} rsub {roll} = left ({r} rsub {1} {r} rsub {2} {r} rsub {3} right ) # = left (matrix {cos left (α right ) cos left (γ right ) + sin left (α right ) sin left (β right ) sin left (γ right ) # cos left (γ right ) sin left (α right ) sin left (β right ) − cos left (α right ) sin left (γ right ) , # − cos left (β right ) sin left (α right ) ## cos left (β right ) sin left (γ right ) # cos left (β right ) cos left (γ right ) , # sin left (β right ) ## cos left (γ right ) sin left (α right ) − cos left (α right ) sin left (β right ) sin left (γ right ) # − sin left (α right ) sin left (γ right ) − cos left (α right ) cos left (γ right ) sin left (β right ) # cos left (α right ) cos left (β right )} right ) }

We can see that alignl at the beginning is lost at the fist row, in the second row,
~= is changed to = , and the equation is not the state when it is saved

why? any help will be appreciated.

My writer’s version information are
Version: 7.4.2.3 / LibreOffice Community
Build ID: 40(Build:3)
CPU threads: 16; OS: Linux 5.14; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Ubuntu package version: 1:7.4.2~rc3-0ubuntu0.20.04.1~lo1
Calc: threaded

Can’t confirm this with LibO V 7.4.2.3; UI = en-UK, locale = en-Canada on Win 10 (de) either saving to .odt or to .odf(“OpenDocumentFormula”).
In both cases the formula is rendered exactly the same before and after save/reload.

Saves and restores unchanged with LO 7.4.2.3 under Fedora 37, KDE Plasma desktop.

But I find your expression over-complicated for such a simple formula. Don’t use scalable brackets (left x and right x where x is a bracket) when there is no need for, i.e. when the subexpression is only one line high. Also subscript notation can be simplified with _. You can use line breaks to pretty print the formula (its programming, not its rendering) so that it is visually readable.

Why have you put commas between second and third columns in first and second rows and nowhere else?

This is how I edited it:

stack { alignl R = R_yaw R_pitch R_roll = ( r_1 r_2 r_3 ) newline
   ~= left (matrix {cos α cos γ  + sin α sin β  sin γ # cos γ sin α sin β − cos α sin γ # − cos β sin α ##
                    cos β sin γ # cos β cos γ # sin β ##
                    cos γ sin α − cos α sin β sin γ # − sin α sin γ − cos α cos γ sin β # cos α cos β }
right ) }


Note I removed the stack {} operator because you don’t want to create a math “logical” object (like a vector) which would have its components stacked over each other with likely brackets around it. You want a formula which is expanded progressively according to substitution rules. The matrix is the final result and would have been written inline, page width permitting. Consequently, I used function newline.

I save it as *.docx, maybe the the format *.docx in libreO doesn’t support some conversion of docx

I did not use left-right statement, the libreO add it automatically, I save the doc as *.docx

Don’t look for another cause. Math encoding is different between M$ Word and LO Writer/Math. Consequently you have an approximate conversion when reading the document and another one when saving. Since there is no bijection between both encodings, you lose some formatting. Remember that any formatting with any application is guaranteed only when you save native.


Fix: save .odt. But note that your document formatting is already damaged, probably beyond repair by the round-trips you have already done. In many cases, it is much better to restart from scratch, copying existing text as unformatted and restyle the whole document.


If DOCX results from some external constraints bestowed on you by teacher, publisher, recipient, … who absolutely refuse ODF, work internally as ODF (.odt) and send them a converted copy. When they review something in their copy, make the changes in your original without reconverting from .docx otherwise the same loss of formatting will occur. For that, use the track changes feature to quickly identify what was changes.

2 Likes

I save it as *.odt, and changes of equations never happen