How to Use Colors in LaTeX: The xcolor Package
📂WritingHow to Use Colors in LaTeX: The xcolor Package
Explanation
\usepackage{color}
In LATEX, the most basic package that allows the use of colors is color
. You can add \usepackage{color}
to the preamble and use it as {\color{color}content}
. The available colors are as follows.
colorboxblackcolorboxgreencolorboxwhitecolorboxbluecolorboxmagentacolorboxyellowcolorboxcyancolorboxred
\documentclass{article}
\usepackage{color}
\begin{document}
This is {\color{red}red} text.
\end{document}
This is red text.
\usepackage{xcolor}
By using xcolor
, you can utilize more colors.
colorboxblackcolorboxdarkgraycolorboxlimecolorboxpinkcolorboxvioletcolorboxbluecolorboxgraycolorboxmagentacolorboxpurplecolorboxwhitecolorboxbrowncolorboxgreencolorboxolivecolorboxredcolorboxyellowcolorboxcyancolorboxlightgraycolorboxorangecolorboxteal
\documentclass{article}
\usepackage{xcolor}
\begin{document}
This is {\color{olive}olive} text.\\
This is {\color{orange}orange} text.\\
\end{document}
This is olive text.This is orange text.
\usepackage[dvipsnames]{xcolor}
By adding [dvipsnames]
to the options, you can access a wider array of colors. The options and the number of available colors are as follows:
[dvipsnames]
: 68 CMYK colors[svgnames]
: 151 RGB colors[x11names]
: 317 RGB colors
The colors available in [dvipsnames]
are as follows, and the rest can be found in the official document.
