4

I have been asked to produce a PDF file with PANTONE spot colors. I used the following code (from a previous post) in XeLaTeX:

\documentclass{article}
\usepackage[pantone]{xespotcolor}
\NewSpotColorSpace{PANTONE}
\AddSpotColor     {PANTONE}  {PANTONE293C} {PANTONE\SpotSpace 293\SpotSpace C} {1 0.68 0.0 0.02}
\AddSpotColor     {PANTONE}  {PANTONE485C} {PANTONE\SpotSpace 485\SpotSpace C} {0 0.93 0.95 0}
\SetPageColorSpace{PANTONE}
\definecolor{PANTONE293C}  {spotcolor} {PANTONE293C,1.0}
\definecolor{PANTONE485C}  {spotcolor} {PANTONE485C,1.0}
\begin{document}
\color{PANTONE293C}
Test (blue)
\color{PANTONE485C}
Test (red)
\end{document}

It works just fine. But now I need to mix the two spot colors. In the package colorspace I found the following code:

\definecolorspace{mymix}{mixed}{PANTONE293C,PANTONE485C}

which normally would allow me to use a 50%-50% mix as follows:

\color[mymix]{.5,.5}

But apparently xespotcolor and colorspace are not compatible, the command \definecolorspace is unknown to the former and when I load both I get error messages.

How can I mix spot colors in xespotcolor?

yannis
  • 2,013
  • 19
  • 18
  • I think xepostcolor can not do this. Soon (already?) l3color will be able to. Otherwise you will need to switch to colorspace and use lualatex (or code the PDF specials yourself). – David Purton Oct 11 '21 at 14:43
  • 1
    xespotcolor doesn't support DeviceN colorspaces needed for this. l3color does it theoretically, but practically there are still a few bugs. – Ulrike Fischer Oct 11 '21 at 19:55

1 Answers1

2

This can be done by l3color, which supports colour spaces with dvips, XeTeX/dvipdfmx and direct PDF output (pdfTeX/LuaTeX). With an up-to-date system

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{uncompress}
\RequirePackage{expl3}
\documentclass{article}
\ExplSyntaxOn
\NewDocumentCommand \definespotcolor { m m m }
  {
    \color_model_new:nnn {#1} { Separation } 
      {
        name = {#2} ,
        alternative-model = cmyk,
        alternative-values = {#3}
      }
  }
\NewDocumentCommand \definecolorspace { m m m }
  {
    \color_model_new:nnn {#1} { DeviceN }
      {
        names  = {#3}
      }
  }
\NewDocumentCommand \definecolor { m m m }
  {
    \color_set:nnn {#1} {#2} {#3}
  }
\NewDocumentCommand \color { o m }
  {
    \IfNoValueTF {#1}
      { \color_select:n {#2} }
      { \color_select:nn {#1} {#2} }
  }
\ExplSyntaxOff

\definespotcolor{fooA}{PANTONE 293 C}{1, 0.68, 0.0, 0.02} \definespotcolor{fooB}{PANTONE 485 C}{0, 0.93, 0.95, 0}

\definecolor{fooA}{fooA}{1} \definecolor{fooB}{fooB}{1} \definecolorspace{mymix}{mixed}{fooA,fooB} \definecolor{mix1}{mymix}{1,0} \definecolor{mix2}{mymix}{0,1} \definecolor{mix3}{mymix}{0.75,0.25}

\begin{document} \color{fooA}abc% \color{fooB}abc% \color{mix1}abc% \color{mix2}abc% \color{mix3}abc \end{document}

will give the desired result.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • I have to do a release of expl3 to fix a couple of bugs, so if you are not at the burning edge you'll need to give it a couple of days for this to work smoothly. – Joseph Wright Oct 12 '21 at 12:12
  • I've chosen to provide a colorspace-like interface here, but that's only to help understand what's going on. I suspect a future design-level interface for l3color will more-or-less expose the code-level interface as-is. – Joseph Wright Oct 12 '21 at 12:14