Getting the next letter of the alphabet is no problem in most programming languages I know. However, in LaTeX, it doesn't seem to be that trivial.
I have looked at how to make 26 macros (here at stackoverflow) but that question and its answers does not involve manipulations of the underlying unicode or something like that.
It is fine if the boundary case (e.g. the lowercase “z”) is not handled at all. I was thinking myself of something like the following:
\mydefalphabet abcdefghijklmnopqrstuvwxyz \mydefalphabet
\mydefalphabetshifted bcdefghijklmnopqrstuvwxyza \mydefalphabetshifted
Can I return in this case the symbol at the shifted range when given the nonshifted range perhaps?
The envisioned command would be:
\newcommand\nextletter[1]{
}
And used as $\nextletter{i}$
in math mode. I can then use $\robotindex$
(equal to i
) and $\other{\robotindex}$
in my formulas (with other
equivalent to nextletter
).
Best Answer
Approach 1
This works for miniscule letters in the
a-z
range and has an optional argument (the shifting amount).Code
Approach 2
This approach uses the macros
\myAlphabet
and\myAlphabetShifted
to look for the “next” letter.Code