# Generate the n-th letter of the alphabet in a tikz loop [duplicate]

The following code draws 10 nodes, labelled from 0 to 9.

\documentclass[a4paper,10pt,landscape]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \i in {0,...,9}{
\node (i) at (\i, \i) {\i} ;
}
\end{tikzpicture}
\end{document}


Instead, I would like the nodes to be labelled from a to j.

Is there a function which, given an integer n, returns the n-th letter of the alphabet? I would like my loop to be as follows:

\foreach \i in {0,...,9}{
\node (i) at (\i, \i) {\someMagicalFunction{\i}} ;
}


## marked as duplicate by Kpym, user13907, user31729, Mike Renfro, Svend TveskægJul 31 '15 at 15:43

One possibility:

\documentclass[a4paper,10pt,landscape]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach [count=\i] \j in {a,b,...,j}{
\node (\i) at (\i, \i) {\j} ;
}
\end{tikzpicture}
\end{document}


percusse mentions the alphalph package in a comment, and its \alphalph does exactly what you want. Note that \alphalph{0} creates no output.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{alphalph}
\begin{document}
\begin{tikzpicture}[scale=0.2]
\foreach \i in {1,...,100}{
\node (\i) at (\i, \i) {\alphalph{\i}} ;
}
\end{tikzpicture}
\end{document}


• Can you maybe add the alphalph package from Heiko for converting more complicated cases? – percusse Jul 31 '15 at 10:54
• Thanks, I used alphalph which is the easiest to read. – Tom Cornebize Jul 31 '15 at 11:43

This would be my first try, using a counter (no need of additional packages):

\documentclass[a4paper,10pt,landscape]{article}
\usepackage{tikz}
\newcounter{cnti}
\begin{document}
\begin{tikzpicture}
\foreach \i in {0,...,9}{

• @percusse yes, I see. I just fired texdoc alphalph --- thanks! – Rmano Jul 31 '15 at 11:21
• Your answer produces an output which is exactly what I want. However, the code is not very nice to read, since we have to create a counter. This is why I accepted @torbjørn-t's answer with alphalph function. – Tom Cornebize Jul 31 '15 at 11:46