LaTeX Commands \definecolor and \colorlet of xcolor Package

May. 19, 2025 • Updated May. 23, 2025

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
\documentclass{article}
\renewcommand{\baselinestretch}{2}

\usepackage[svgnames]{xcolor}
\newcommand\myfcolorbox[1]{\fcolorbox{white}{#1}{\phantom{color}} #1\quad}

\definecolor{mycolor1}{rgb}{0.858, 0.188, 0.478}
\definecolor{mycolor2}{RGB}{219, 48, 122}
\definecolor{mycolor3}{cmyk}{0, 0.7808, 0.4429, 0.1412}
\definecolor{mycolor4}{gray}{0.6}

\definecolor{mycolor5}{HTML}{00F9DE}

% Both "ForestGreen" and "NavyBlue" are built-in colors
% from the `xcolor` package with the `svgnames` option
\colorlet{mixedcolor1}{ForestGreen!70} % ForestGreen(70%)
\colorlet{mixedcolor2}{ForestGreen!50!NavyBlue}% ForestGreen(50%) + NavyBlue(50%)

\begin{document}

\noindent
\myfcolorbox{mycolor1}\\
\myfcolorbox{mycolor2}\\
\myfcolorbox{mycolor3}\\
\myfcolorbox{mycolor4}\\
\myfcolorbox{mycolor5}\\
\myfcolorbox{ForestGreen}\\
\myfcolorbox{mixedcolor1}\\
\myfcolorbox{mixedcolor2}\\

\end{document}

image-20250519171243808


References