# How to redefine one-letter commands?

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?

• Didn't the two answers and several comments stating Don't do that in your other question make you a bit suspicious thinking about Why shouldn't i do it? instead of Now, ireally want to do that and mess up everything. – Johannes_B Dec 12 '15 at 18:03
• – Johannes_B Dec 12 '15 at 18:07
• Diacritics are done using one letter comands (at least some), so that functionality will be gone. – Johannes_B Dec 12 '15 at 18:19
• I usually recall the (true) case of a colleague who asked my why the name of his coauthor was not accepted by LaTeX. Well, the coauthor was Turk and his name contained “ç”, but my colleague had redefined \c. – egreg Dec 12 '15 at 19:00
• no an example would start \documentclass and have the minimal number of packages needed and then would have code that caused tex to give the error message. Without that you are asking us to debug unseen code. – David Carlisle Dec 12 '15 at 22:55

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.

Consider the following document:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\renewcommand{\i}{\mathrm{i}}

\begin{document}

El mínimo de la función $f(x)=1+x^{2}$ es $1$.

\end{document}


Run LaTeX over it to get

! LaTeX Error: \mathrm allowed only in math mode.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.10 El mí
nimo de la función $f(x)=1+x^{2}$ es $1$.


This is just an example of why you don't want to redefine \i. There are many other situations where redefining an internal gives seemingly mysterious errors.

Another example (similar to one presented to me by a colleague)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}

\renewcommand{\c}{\mathrm{c}} % a constant

\begin{document}

\title{Mínimo de una función}
\author{Leonardo Castro and Şaban Atatürk}
\maketitle

El mínimo de la función $f(x)=\c+x^{2}$ es $\c$.

\end{document}

• This is indeed enlightening! However, in your (first) example there is no \i in math mode. But if you do put \i into the dollars LaTeX gives the error Command \i invalid in math mode and ignores the new definition you have assigned to it. How can you make LaTeX understand you don't care about its previews meaning? – Jim Dec 12 '15 at 20:00
• @Jim In the first case, \i in math mode does not raise an error. The examples want to show that one doesn't want to redefine these commands. – egreg Dec 12 '15 at 20:20