logo

LaTeX에서 색깔 사용하는 법: xcolor 패키지 📂논문작성

LaTeX에서 색깔 사용하는 법: xcolor 패키지

설명

\usepackage{color}

LaTeX\LaTeX에서 색깔을 사용할 수 있는 가장 기본적인 패키지는 color이다. 프리앰블\usepackage{color}를 추가하고 {\color{색깔}내용}과 같이 사용하면 된다. 사용가능한 색깔은 다음과 같다.

colorboxblackcolorboxbluecolorboxcyancolorboxgreencolorboxmagentacolorboxredcolorboxwhitecolorboxyellow \begin{array}{lll} \color{black}\colorbox{black}{\phantom{colorbox}}black& \color{blue}\colorbox{blue}{\phantom{colorbox}}blue& \color{cyan}\colorbox{cyan}{\phantom{colorbox}}cyan\\ \color{green}\colorbox{green}{\phantom{colorbox}}green& \color{magenta}\colorbox{magenta}{\phantom{colorbox}}magenta& \color{red}\colorbox{red}{\phantom{colorbox}}red\\ \color{white}\colorbox{white}{\phantom{colorbox}} \color{black}{white}& \color{yellow}\colorbox{yellow}{\phantom{colorbox}}yellow \end{array}

\documentclass{article}
\usepackage{color}
\begin{document}

This is {\color{red}red} text.

\end{document}

This is red text. \text{This is } \textcolor{red}{\text{red}} \text{ text.}

\usepackage{xcolor}

xcolor를 사용하면 더 많은 색상을 사용할 수 있다.

colorboxblackcolorboxbluecolorboxbrowncolorboxcyancolorboxdarkgraycolorboxgraycolorboxgreencolorboxlightgraycolorboxlimecolorboxmagentacolorboxolivecolorboxorangecolorboxpinkcolorboxpurplecolorboxredcolorboxtealcolorboxvioletcolorboxwhitecolorboxyellow \begin{array}{llll} \color{black}\colorbox{black}{\phantom{colorbox}}black& \color{blue}\colorbox{blue}{\phantom{colorbox}}blue& \color{brown}\colorbox{brown}{\phantom{colorbox}}brown& \color{cyan}\colorbox{cyan}{\phantom{colorbox}}cyan \\ \color{darkgray}\colorbox{darkgray}{\phantom{colorbox}}darkgray& \color{gray}\colorbox{gray}{\phantom{colorbox}}gray& \color{green}\colorbox{green}{\phantom{colorbox}}green& \color{lightgray}\colorbox{lightgray}{\phantom{colorbox}}lightgray \\ \color{lime}\colorbox{lime}{\phantom{colorbox}}lime& \color{magenta}\colorbox{magenta}{\phantom{colorbox}}magenta& \color{olive}\colorbox{olive}{\phantom{colorbox}}olive& \color{orange}\colorbox{orange}{\phantom{colorbox}}orange\\ \color{pink}\colorbox{pink}{\phantom{colorbox}}pink& \color{purple}\colorbox{purple}{\phantom{colorbox}}purple& \color{red}\colorbox{red}{\phantom{colorbox}}red& \color{teal}\colorbox{teal}{\phantom{colorbox}}teal\\ \color{violet}\colorbox{violet}{\phantom{colorbox}}violet& \color{white}\colorbox{white}{\phantom{colorbox}} \color{black}{white}& \color{yellow}\colorbox{yellow}{\phantom{colorbox}}yellow& \end{array}

\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. \text{This is } \textcolor{olive}{\text{olive}} \text{ text.}\\ \text{This is } \textcolor{orange}{\text{orange}} \text{ text.}

\usepackage[dvipsnames]{xcolor}

옵션에 [dvipsnames]를 추가하면 더 많은 색깔을 사용할 수 있다. 옵션과 사용가능한 색깔의 수는 다음과 같다.

  • [dvipsnames]: CMYK 색깔 68개
  • [svgnames]: RGB 색깔 151개
  • [x11names]: RGB 색깔 317개

[dvipsnames]에서 사용할 수 있는 색깔은 다음과 같으며, 나머지는 공식 문서에서 확인할 수 있다.