[OS X TeX] math replace

Herbert Schulz herbs at wideopenwest.com
Thu Jun 27 19:20:36 CEST 2013

On Jun 27, 2013, at 9:41 AM, Peter Dyballa <Peter_Dyballa at Web.DE> wrote:

> Am 27.06.2013 um 16:12 schrieb George Gratzer:
>> Is there any intelligent way to do it?
> With regular expressions.
> 	M-x replace-regexp RET \([_^]\)i RET \1k RET
> --
> Greetings
>  Pete


Now I'll show my weak knowledge of regular expressions. I assume this will find






is a grouping that is later referred to as \1 (i.e., the first grouping) and


means either _ or ^. So the regex is saying find all occurrences of _ or ^ followed by i and replace it by the same _ or ^ and k.

Assuming my interpretation is correct this will NOT do what George wants because he explicitly said that the i's were NOT always super or subscripts.

Not only that using $ as the entry and exit for a math expression makes it virtually impossible to know if you are at the start or end of a mathematical expression (then using $$ for displayed equations is even worse).

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)

More information about the macostex-archives mailing list