"잘못된 측정 단위(pt 삽입)" foreach 문제

"잘못된 측정 단위(pt 삽입)" foreach 문제

그라데이션을 사용하여 일련의 원을 만들려고 합니다. 생성된 두 번째 페이지에는 /2pt/1pt/2pt만 있고 마지막 /20pt에는 있습니다. 내 foreach 루프에 문제가 있는 것 같지만 무엇인지 모르겠습니다.

\documentclass[tikz]{standalone}
\usepackage{xcolor}

\definecolor{myyellow}{cmyk}{0,0,10,0}

\begin{document}

\foreach \Radius/\j in {6.0/1, 6.05/2,...,8.0/42}
{
    \begin{tikzpicture}[scale=.5]
        \pgfmathsetmacro\k{\j*10}
        \useasboundingbox[fill=black] (-8.2,-8.2) rectangle (8.2cm,8.2cm);
        \fill[fill=myyellow!\k] (0,0) circle (\Radius);
    \end{tikzpicture}
}

\end{document}

오류:

Illegal unit of measure (pt inserted).

<to be read again> 
                   /
l.15 }

답변1

색상 분수에 대해 정수를 사용해야 하며 count바로 이 상황에 사용할 수 있는 옵션이 있습니다.

\documentclass[tikz]{standalone}
\usepackage{xcolor}

\definecolor{myyellow}{cmyk}{0,0,10,0}

\begin{document}

\foreach \Radius [count=\j] in {6.0, 6.05,...,8.0}
{
    \begin{tikzpicture}[scale=.5]
        \pgfmathtruncatemacro\k{\j*10}
        \useasboundingbox[fill=black] (-8.2,-8.2) rectangle (8.2cm,8.2cm);
        \fill[fill=myyellow!\k] (0,0) circle (\Radius);
    \end{tikzpicture}
}

\end{document}

여기에 이미지 설명을 입력하세요

답변2

이렇게 하는 것은 실제로 의미가 없습니다 myyellow!420. 100부터 모든 값은 동일한 색상을 생성합니다.

여기서 그라디언트는 2단계에서 2에서 84까지입니다.

\documentclass[tikz]{standalone}
\usepackage{xcolor}

\definecolor{myyellow}{cmyk}{0,0,10,0}

\begin{document}

\foreach \x in {2,4,...,84}
  {
    \begin{tikzpicture}[scale=.5]
        \pgfmathsetmacro\Radius{(\x-2)/41+6}
        \useasboundingbox[fill=black] (-8.2,-8.2) rectangle (8.2cm,8.2cm);
        \fill[fill=myyellow!\x] (0,0) circle (\Radius);
    \end{tikzpicture}
  }

\end{document}

관련 정보