I create equations with random numbers in VBA and for square x in x ^ 2.
I read every square (or text) text in a line.
Then I read each character in the line one at a time and mark the location of ^ ("hats") in each.
It is said that the hats were in positions 4, 8 and 12.
Then I “cut out” the first hat - the position of the superscript is now 4, the position of the remaining hats is now 7 and 11. I chop off the second hat, the character at the top index is now 7, and the hat has moved to 10. I chop off the last hat. The top character is now at position 10.
Now I select each character in turn and change the font to superscript.
That way, I can populate the whole table with algebra using ^, and then call the procedure to remove it.
For large degrees, such as x for 23, I build x ^ 2 ^ 3, and this procedure is performed.
source share