길이 레지스터가 있는 pgf 목록

길이 레지스터가 있는 pgf 목록

tikz길이 레지스터를 사용하여 목록을 생성할 수 있습니까 ?

예를 들어:

\foreach \x in {0,1,...,6}

다음 목록을 생성합니다: "0,1,2,3,4,5,6"

하지만 지금은 레지스터를 사용하여 목록을 생성하고 싶습니다 \pas. \largeur

\foreach \x in {0,\pas,...,\largeur}

하지만 이것은 작동하지 않습니다.

MWE

\documentclass{beamer}
\newlength{\slw}\setlength{\slw}{160mm}
\newlength{\slh}\setlength{\slh}{90mm}
\geometry{verbose,papersize={\slw,\slh}}

\mode<presentation>
\usetheme{metropolis}
\usepackage{tikz,pgffor}
\usetikzlibrary{calc}

\newlength\pas
\setlength\pas{10mm}

\begin{document}
\begin{frame}
  \begin{tikzpicture}
    \foreach \x in {0,\pas,...,\slw}
    {
      \node at (\x,0) {\x};
    }
\end{tikzpicture}
  \end{frame}
\end{document}

답변1

예를 들어 사용할 수 있습니다https://tex.stackexchange.com/a/541869/36296cm로 변환하려면

\documentclass[aspectratio=169]{beamer}

\mode<presentation>
\usetheme{moloch}% modern fork of the metropolis theme
\usepackage{tikz}
\usetikzlibrary{calc}

\newlength\pas
\setlength\pas{10mm}

% from https://tex.stackexchange.com/a/541869/36296
\NewExpandableDocumentCommand{\getlengthnumber}{O{pt}m}{%
  % #1 (optional, default pt), #2 = length
  \fpeval{(#2)/(1#1)}%
}

\begin{document}
\begin{frame}
  \begin{tikzpicture}
    \foreach \x in {0,\getlengthnumber[cm]{\pas},...,\getlengthnumber[cm]{\paperwidth}}
    {
      \node at (\x,0) {\x};
    }
\end{tikzpicture}
  \end{frame}
\end{document}

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

관련 정보