繪製 CMYK 色樣/調色盤

繪製 CMYK 色樣/調色盤

背景

我希望創建一個類似於此處找到的調色板的 LaTeX 版本:https://codepen.io/devi8/pen/nJMGZR。它看起來像這樣:

在此輸入影像描述

我已經設法找到了可以建立的程式碼,但我遇到了兩個問題:

  1. 如何在 MWE 中使用 CMYK 取代 RGB?
  2. 如何將每個框分成兩個框並為每個框添加陰影邊框?

最小工作範例 (MWE)

\documentclass{article}
\usepackage{xcolor,stackengine}

\newcommand\palbox[2]{{\sffamily\fboxsep=10pt\relax\fboxrule=0pt\relax\footnotesize%
  \fcolorbox{gray!50}{gray!10}{%
    \stackengine{8pt}{%
      \colorbox[RGB]{#1}{\rule{60pt}{0pt}\rule{0pt}{60pt}}%
    }{%
      \color{black!60}\stackengine{6pt}{\##2}{\saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
  }%
}}

\newcommand\saycolors[1]{\saycolorsaux#1\relax}
\def\saycolorsaux#1 #2 #3\relax{R:#1 G:#2 B:#3}

\begin{document}
    \palbox{1 103 143}{01678f}\quad
    \palbox{221 109 16}{dd6d10}\quad
    \palbox{18 54 69}{123645}\quad
    \palbox{120 121 124}{78797c}
\end{document}

電流輸出

在此輸入影像描述

所需輸出

兩種 CMYK 顏色並排放置在帶有陰影的框中。

答案1

這不是基於您的程式碼的解決方案,而是基於tcolorbox.我不是顏色系統的專家,所​​以我不知道 CMYK 在這裡是否可以正常工作。

編輯:顏色名稱和 CMYK 代碼現在是分開的。tcbraster將樣本放入列和行中。

在此輸入影像描述

\documentclass{article}
\usepackage{helvet}
\usepackage{array,tabularx,colortbl}
\usepackage[most]{tcolorbox}

\newcommand{\swatch}[5]{%
    \definecolor{c1}{cmyk}{#1}%
    \definecolor{c2}{cmyk}{#3}%
    \begin{tcolorbox}[
        enhanced,
        frame hidden,
        width=21ex,
        clip upper,
        fontupper=\color{gray},
        colback=white,
        fuzzy shadow={0mm}{0pt}{-.5pt}{1pt}{black!60!white},
        tabularx={XX}
    ]
        \cellcolor{c1} & \cellcolor{c2} \\[4ex]
        \multicolumn{2}{l}{\textsf{#5}\rule{0pt}{3ex}} \\
        {\tiny\textsf{#2}} & {\tiny\textsf{#4}}
    \end{tcolorbox}%
}

\begin{document}
\begin{tcbraster}[raster columns=2,raster force size=false]
\swatch{.61,.34,0,.07}{blue1}{.66,.38,0,.14}{blue2}{Blue Jeans}
\swatch{0,.19,.67,0}{yellow1}{0,.24,.73,.04}{yellow2}{Sunflower}
\swatch{.25,0,.51,.17}{green1}{.27,0,.58,.24}{green2}{Grass}
\swatch{0,.64,.57,.07}{red1}{0,.69,.62,.15}{red2}{Grapefruit}
\end{tcbraster}
\end{document}

相關內容