Graphics, Figures & TablesCan TeX specify a line color in CMYK?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Caslon Palatino
Posts: 4
Joined: Sun Dec 19, 2021 11:53 pm

Can TeX specify a line color in CMYK?

Post by Caslon Palatino »

Can TeX specify a line color in CMYK?
Steps to Reproduce
1. Declare {xcolor} package with [cmyk] color mode option.
2. Define custom color: vermillion
3. Draw line for rectangle with custom color.
BUG: Line color is black, not custom color.

Code: Select all

% File name: TitlePageBorder.tex
% LaTeX version: LaTeX2e
% TeX compiler: lualatex
% Updated: 4/2/2022

% Preamble -------------------------------------------------------
\documentclass{article}

\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{fontspec} % Supports OpenType fonts (*.OTF).
\usepackage[cmyk]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}

\geometry{paperwidth=105mm,
	       paperheight=160mm,
 	       textwidth=216pt,   % 216pt ~=  76mm
	       textheight=320pt   % 320pt ~= 113mm
         }

% Declare title font.
\newfontfamily{\MyPerpetuaTitlingMTFont}[Ligatures = {Common, Rare}]{Perpetua Titling MT} 

% Define custom color: myVermillion 
% Vermillion values at: https://www.colorhexa.com/e34234

\definecolor{myVermillion}{cmyk}{10, 90, 90, 0}

\begin{document} %  ----------------------------------------------
	\begin{titlepage}		
		\begin{center}
							
			% Typeset title page border: rectangle. 
			\begin{tikzpicture}[overlay,remember picture]
				\draw [line width=1.5pt, color=myVermillion]
				($ (current page.north west) + (1cm,-1cm) $)
				rectangle
				($ (current page.south east) + (-1cm,1cm) $);			
			\end{tikzpicture}
			
			% Typeset title page text.
			\vspace*{50pt}			
			\fontspec{Perpetua Titling MT Bold}\par
			\fontsize{18pt}{20pt}
			\selectfont			
			{CENTERED TITLE}%				
		\end{center}
	\end{titlepage}
\end{document} %  ------------------------------------------------

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Can TeX specify a line color in CMYK?

Post by rais »

It's not a bug, you just need to rescale your values...(x)color expects values from 0 to 1 for each color channel in the cmyk model, so

Code: Select all

\definecolor{myVermillion}{cmyk}{0, 0.71, 0.77, 0.11}% 0% C, 71% M, 77% Y, 11% K
should give you the original Vermillion definition...well, at least it's reddish, not black;)

KR
Rainer
Caslon Palatino
Posts: 4
Joined: Sun Dec 19, 2021 11:53 pm

Can TeX specify a line color in CMYK?

Post by Caslon Palatino »

Many thanks, Ranier. Expressing the color percentages as decimal fractions worked. TEXstudio now draws the rectangle with the desired vermillion color.

% Define custom color.
% Vermillion values at: https://www.colorhexa.com/e34234
% NOTE XCOLOR package CMYK colors must be defined as percentages expressed in the range 0-1, where 1 = 100%.
\definecolor{myVermillion}{cmyk}{0, 0.709, 0.771, 0.11}

Sincerely yours,

Kyle
Post Reply