Retrieve the color definition in HTML

We can convert the stored version of the color definition (which is expressed in rgb) to HTML with

\newcommand{\colrow}[1]{%
  #1 & \colpic{#1} & \extractcolorspecs{#1}{\model}{\mycolor}%
    \convertcolorspec{\model}{\mycolor}{HTML}\tmp\tmp
}

Also we can squeeze in the definitions of the commands like \somecolorhtml with some extra coding.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz,booktabs,xcolor}
\newcommand{\definemycolor}[2]{%
        \definecolor{#1}{HTML}{#2}%
        \expandafter\def\csname#1html\endcsname{#2\relax} %Which defines \colornamehtml
        }
\newcommand{\colpic}[1]{\tikz \draw[#1,fill=#1,draw](0,0)circle(0.1cm);}
\newcommand{\colrow}[1]{#1 & \colpic{#1} &\csname#1html\endcsname}
\definemycolor{mapblue}{0000FF}%
\definemycolor{maproyalblue}{0088FF}%
\definemycolor{mapskyblue}{00CCFF}%
\definemycolor{mapgreen}{00CC00}%
\definemycolor{mapdandelion}{FFCC00}%
\definemycolor{maporange}{FF8800}%
\definemycolor{mapred}{FF0000}%
\begin{document}
\begin{tabular}{cccc}
\toprule
\multicolumn{1}{c|}{\textsc{Relevance Interval}} &
\multicolumn{1}{c|}{\textsc{Color}} & 
\multicolumn{1}{c|}{\textsc{Picture}} & 
\multicolumn{1}{c}{\textsc{ Color Definition}}\\    \midrule 
0 - 5 & \colrow{mapblue}\\
5 - 10 & \colrow{maproyalblue}\\
10 - 25 & \colrow{mapskyblue}\\
25 - 50 & \colrow{mapgreen}\\
50 - 100 & \colrow{mapdandelion}\\
100 - 200 & \colrow{maporange}\\
>200 & \colrow{mapred}\\
\bottomrule
\end{tabular}
Since we defined the \verb|\colornamehtml| command versions of the colors,
\verb|\mapbluehtml| gives \textcolor{mapblue}{\mapbluehtml}  and 
\verb|\mapdandelionhtml| gives \textcolor{mapdandelion}{\mapdandelionhtml}.
\end{document}

enter image description here

Also, I think a monospaced font would please more in the last column so replacing the colrow command with the following

\newcommand{\colrow}[1]{#1 & \colpic{#1} &\expandafter\texttt{\csname#1html\endcsname}}

would lead to

enter image description here

Tags:

Color

Tables