I have a TeX document with many occurrences of a Greek letter, say \kappa
. Is there a command to change all \kappa
s to another letter, say \omega
all at once, without changing each \kappa
to \omega
manually?
1 Answer
Something as simple as this:
\renewcommand{\kappa}{\omega}
in the preamble?
The only caveat is that it'll no longer be possible to use \kappa
for κ, so if you want to map something else to κ, it won't work. If needed, you can use \let
to “save” the old \kappa
with a different name. E.g., if you wanted to switch \omega
and \kappa
you could do:
\let\oldkappa=\kappa
\let\oldomega=\omega
\renewcommand{\kappa}{\oldomega}
\renewcommand{\omega}{\oldkappa}
Don't just use renewcommand with both the old names, or you'll at best end up with two commands the same, and at worst with circular definitions and neverending compilation process.
-
-
3It might be better to issue
\AtBeginDocument{\renewcommand{\kappa}{\omega}}
if there are packages loaded that (re)define\kappa
. Doubt it, but still.– Werner ♦Mar 16, 2022 at 21:11
\kappa
in your document, changing them to\omega
in your editor should only take a few seconds to type the replacement text. If you redefine the command then any fragments of the document that you move later to a new document or any fragmnts you copy from elsewhere won't get errors but will silently produce the wrong symbols. the document will be "an accident waiting to happen"