# 16x16 table filled with hex values in tikz with foreach

I am a beginner to Latex and Tikz. I'm facing the following problem: I want to create a table with hex values from 00 to FF in tikz using for each. However, is there a way to specify hex values with other variables? Currently, the example in TikZ manual uses the existing variables in the loop like this:

\begin{tikzpicture}
\foreach \x in {0,1,2,3}
\foreach \y in {0,1,2,3}
{
\draw (\x,\y) circle (0.2cm);
\fill (\x,\y) circle (0.1cm);
}
\end{tikzpicture}


It uses the x and y variables, but how do I specify my own variable, with hex values for each node?

• You should look up how to use counters, and then perhaps use the moreenum package to convert counter values to hex. Commented Dec 11, 2016 at 16:53

I'd suggest keeping yourself and TeX in decimal, and converting to hex as needed for presentation:

\documentclass{standalone}
\usepackage{fmtcount} % for hex conversion
\newcounter{somevalue}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\foreach \row in {0, ..., 15}
{
\foreach \col in {0, ..., 15}
{
\node[xshift=\col cm, yshift=-\row em]

• pgfmath knows about hex numbers hex(x) and Hex(x) can do the conversion on integers Commented Dec 11, 2016 at 17:27
• Thanks for your answer. When I add draw to the \node, the table is not rendered properly. Could we use grid for a proper table? I cannot make the borders overlap correctly with xshift and yshift. Commented Dec 11, 2016 at 17:55