[Tex/LaTex] Transforming numbers to \alph numbers

macrosnumbering

Is it possible to have a simple command \makeAlph which would do the following :

  • return a when it receives 1
  • return b when it receives 2
  • etc.
  • return nothing (or whatever ; actually that's not important for me) in the other cases
    ?

Thank you.

PS : I know how to do it with counters but this is not what I want.

Best Answer

\documentclass{article}%
\newcommand*\makeAlph[1]{\symbol{\numexpr96+#1}}
\begin{document}

\makeAlph{10}
\makeAlph{22}

This is the first letter of the alphabet : \makeAlph{1}

\end{document}

if you want to allow all numbers then use:

\documentclass{article}%
\newcommand*\makeAlph[1]{%
  \ifnum#1<1\else% do nothing if < 1
    \ifnum#1>26 a\makeAlph{\numexpr#1-26}% start loop
    \else\symbol{\numexpr96+#1}\fi\fi}
\begin{document}

This is the first letter of the alphabet : \makeAlph{1}

\makeAlph{10}  \makeAlph{44}
\makeAlph{-3}
\end{document}