1

I translated a German text that contains many equations with Fraktur symbols. Here is an example:

example of equation with Fraktur symbols

Now I want to replace the symbols in the equations with the corresponding Latin letters, but also format the Latin letters in bold/italic (vector notation).

It's easy to find/replace the symbols, but Word doesn't want to simultaneously apply the bold/italic format inside of equations (it works in normal text).

Is this possible? Maybe with VBA? Any suggestions?

Setup: Microsoft® Word 2019 MSO (Version 2403 Build 16.0.17425.20176) 64-bit

Edit 1: This technique helps a lot already: Find and replace text by equation in Word 2019

0

1 Answer 1

1

The problem here seems to be that whenever you insert a regular letter character (let's say A, normally code point U+0041, decimal 65) in an Equation, the Equation editor (a) uses the Cambria Math font, (or possibly another Math font) and (b) converts it to the MATHEMATICAL ITALIC CAPITAL A, Unicode code point U+1D434, a Unicode Plane 1 character. If you apply Bold to that, it will be replaced by the MATHEMATICAL BOLD ITALIC CAPITAL A (U+1D468).

In my view, Word's Find/Replace dialog should really do all that for you, but it doesn't, as you have seen, so the question is how to make it do it.

If you only have a small number of replacements to make (say A,B,C) you could continue using the Find/Replace dialog but insert the correct Mathematical Bold Italic character in the Replace with box. In the case of A you can do that by typing 1D468 then press Alt-X. When you do that, Word also checks the Match prefix box in the dialog - that seems to be necessary for the match to succeed. Perhaps something to do with the fact that Word represents these characters using two Unicode surrogate codepoints, e.g. U+D835, U+DC68.

I don't see any way you could use wildcards in Find/Replace for that (finding a Fraktur character, yes, but inserting the correct replacement, not so much).

So the alternative is to use code. Simplest is probably to do 26 replacements like this:

Sub replaceUCFrakturs()
' Replace uppercase Mathematical Fraktur characters with A,B,C Bold/Italic equivalents
Dim i as Long
Application.ScreenUpdating = False
On Error GoTo problem
With ActiveDocument.Content.Find
  For I = 1 to 26
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ChrW(55349) & ChrW(56683 + i)
    .Replacement.Text = ChrW(55349) & ChrW(56423 + i)
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchPrefix = True
    .MatchCase = True
    .MatchWholeWord = False
    .MatchKashida = False
    .MatchDiacritics = False
    .MatchAlefHamza = False
    .MatchControl = False
    .MatchByte = False
    .MatchWildcards = False
    .MatchSoundsAlike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
  Next
End With

problem:
Application.ScreenUpdating = True
End Sub

The other programmatic approach would probably be to look for all the Fraktur characters in a single pass, then replace each one by the correct replacement. The code is a bit more complicated and I think the above is probably simpler to modify and use.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .