Is it possible to use a new color without defining a new color like \definecolor{mycolor}{HTML}{a65dbd}
? It is indeed cumbersome to use when the color is used only once, and can easily lead to conflicts if multiple parts of the file use the same color name for different colors (in particular, no error is given if we use \definecolor{mycolor}
twice, so the colors only appears to be wrong for no apparent reason).
As HTML colors are easy to copy/paste between programs, I'd love to be able to do something like:
\textcolor{HTML(00AA00)}{\textbf{This is not working}}
MWE:
\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{verbatim}
\definecolor{mycolor}{HTML}{a65dbd} % Equal to RGB(166,93,189).
\begin{document}
\noindent
\textcolor{mycolor}{\textbf{This is my color but annoying to use.}}\\
\textcolor{red!65!green!36!blue!74!}{\textbf{This is better but not accurate nor easily copy/pastable.}}\\
\textcolor[HTML]{a65dbd}{\textbf{This is working, but not generalizable (tikz, tabularray\dots).}}\\
\verb|\tikz \node[text=[HTML]{a65dbd]{This is not working};|
\end{document}
EDIT
Phelype proposed in comments to use \textcolor[HTML]{00AA00}{...}
, unfortunately it does not generalize to other commands. For instance, this is not working in tikz, nor in tabularray cell colors:
\tikz \node[text=[HTML]{a65dbd]{This is not working};
Wouldn't it be possible to define a generic color taking arguments (like green!50!white
which works for both tikz, tabularray, textcolor...) but taking as input an HTML color description?
EDIT
I created a feature request here https://github.com/latex3/xcolor/issues/13 but if someone has a solution is the meantime, I'd be interested to hear it.