[Tex/LaTex] How to redefine one-letter commands

macros

I want to change the function of some commands consisting of only one letter, such as \e or \i, and make them abide by MY rules. (Mouhahaha!) I have done this before with other commands like \in or \=, but it seems that one-letter commands are special for some mysterious reason.

In particular, I'd like to make a new command \i to use it in math-mode, but this produces an error.

Here is just a part of my document:

\documentclass[12pt]{article}

%   % symbols
\let\i\undefined
\newcommand{\i}{\mathrm{i}}


% begin languages
\usepackage[LGR,T1]{fontenc}


\begin{document}

$\i$ $i$ i

\end{document}

I get the error

Command \i invalid in math mode

The .pdf file is, nevertheless, produced and \i appears as the greek letter beta. I tried other ways (which now I cannot recall) that had \i to appear as a dotless i instead of beta.

And why don't I get the same error with \e that also has a predefined meaning?

Best Answer

There is nothing special about one letter commands you can (re)define them the same as multiletter commands. The point is that most of them are already defined and unless you are certain that you are not breaking latex, redefining latex's internals is not normally recommended.

You did not show any reproducible code to show the error that you showed in your previous question. Your actual redefinition redefined \i and it would have worked in math mode at that point. However \i is (normally) an encoding-specific command and probably some package you loaded reset those commands at \begin{document} so over-writing your definition.

But the solution is not to ask how to redefine latex's inner workings without breaking it, just use a different name.

Related Question