tikz
長さレジスタを使用してリストを生成することは可能ですか?
例えば:
\foreach \x in {0,1,...,6}
次のリストを生成します: "0,1,2,3,4,5,6"
\pas
しかし、レジスタとを使用してリストを生成したいのです\largeur
。
\foreach \x in {0,\pas,...,\largeur}
しかし、これは機能しません。
ムウェ
\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}