12

Is there a LaTex-style way to get the complementary color?
For example, a corresponding command in the xcolor package?

enter image description here

\documentclass[]{book} 
\usepackage{xcolor}
\definecolor{Acolor}{named}{red}
\definecolor{Bcolor}{named}{yellow}

\begin{document}
\colorbox{Acolor}{text} $\leftrightarrow$ \colorbox{gray}{complementary color here}

\colorbox{Bcolor}{text} $\leftrightarrow$ \colorbox{gray}{complementary color here}
\end{document}

1 Answer 1

20

Defining "complementary color" is not so easy ;-) (it depends on the model, you should have a look at section 6.3 of the xcolor manual), but in a pinch, you can use the syntax -color as seen here (page 4 of the same manual):

enter image description here

So, your example:

\documentclass[]{book}
\usepackage{xcolor}
\definecolor{Acolor}{named}{red}
\definecolor{Bcolor}{named}{yellow}

\begin{document}
\colorbox{Acolor}{text} $\leftrightarrow$ \colorbox{-Acolor}{complementary color here}

\colorbox{Bcolor}{text} $\leftrightarrow$ \colorbox{-Bcolor}{complementary color here}
\end{document}

enter image description here

...and just for fun:

\documentclass[]{book}
\usepackage{xcolor}
\definecolor{Acolor}{named}{red}
\definecolor{Bcolor}{named}{yellow}
\definecolor{yellowrgb}{rgb}{1,1,0}
\definecolor{yellowcmyk}{cmyk}{0,0,1,0}
\definecolor{yellowHsb}{Hsb}{60,1,1}

\begin{document}
\colorbox{Acolor}{text} $\leftrightarrow$ \colorbox{-Acolor}{complementary color here}

\colorbox{Bcolor}{text} $\leftrightarrow$ \colorbox{-Bcolor}{complementary color here}

\colorbox{yellowrgb}{text} $\leftrightarrow$ \colorbox{-yellowrgb}{complementary color here}

\colorbox{yellowcmyk}{text} $\leftrightarrow$ \colorbox{-yellowcmyk}{complementary color here}

\colorbox{yellowHsb}{text} $\leftrightarrow$ \colorbox{-yellowHsb}{complementary color here}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .