J'essaie d'écrire une équation à Word via l'espace de noms OMath, mais je ne peux pas générer des caractères échappés pour générer correctement. Lorsque j'exécute le programme de console ci-dessous, il place correctement le numérateur et le diviseur, mais le caractère "\ delta" échappé, reste exactement tel que tapé, plutôt que de se transformer en symbole grec pour le delta minuscule.OMath buildup() caractères d'échappement
Si je place le curseur juste après le 'a' dans \ delta, et appuie sur l'espace, il convertit. Si je clique sur Professional à partir du ruban, convertit également. Est-ce que quelqu'un peut expliquer comment créer un caractère échappé par programme, et le faire afficher correctement?
static void Main(string[] args)
{
string fName = @"C:\Users\Desktop\Doc_1.docx";
Word._Application myApp = new Word.Application();
myApp.Visible = true;
Word.Document myDoc = myApp.Documents.Open(fName);
Word.Range myFunctionR = myApp.Selection.OMaths.Add(myApp.Selection.Range);
Word.OMathFunction myFunction = myApp.Selection.OMaths[1].Functions.Add(
myApp.Selection.Range, Word.WdOMathFunctionType.wdOMathFunctionBox);
Word.OMathBox myBox = myFunction.Box;
myBox.E.Range.Text = @"\delta = (PL)/(AE)";
myBox.E.BuildUp();
}
Si je colle le MathML de MS Word, il ressemble à ceci:
Correct/Version souhaitée:
<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<mml:mi>δ</mml:mi><mml:mi>
<mml:mi> </mml:mi>
<mml:mo>=</mml:mo>
<mml:mfrac>
<mml:mrow>
<mml:mi>P</mml:mi>
<mml:mi>L</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mi>A</mml:mi>
<mml:mi>E</mml:mi>
</mml:mrow>
</mml:mfrac>
incorrect/Version Programmatic:
<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<mml:mo>\</mml:mo>
<mml:mi>d</mml:mi>
<mml:mi>e</mml:mi>
<mml:mi>l</mml:mi>
<mml:mi>t</mml:mi>
<mml:mi>a</mml:mi>
<mml:mi> </mml:mi>
<mml:mo>=</mml:mo>
<mml:mfrac>
<mml:mrow>
<mml:mi>P</mml:mi>
<mml:mi>L</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mi>A</mml:mi>
<mml:mi>E</mml:mi>
</mml:mrow>
</mml:mfrac>