
실제 값을 반환하는 매크로를 만들고 싶습니다. 예를 들어, 다음과 같은 의사 코드를 갖고 싶습니다.
\documentclass{article}
\usepackage{etoolbox}
\usepackage{calculator}
\newcommand{\scale}[3]{%
\ifnumgreater{#1}{10}
{\return{#1}}
{\ifnumgreater{#2}{10}
{\return{#2}}
{\return{#3}}
}
}
\begin{document}
\begin{tikzpicture}[scale=1]
%* Polar Ray - Centerline - Origin at (0,0), 45degs from horizontal to a length of \scale
\draw [red,dashed] (0,0) -- ++(45:\scale{9}{12}{10});
\end{tikzpicture}
\end{document}
궁극적으로 다이어그램의 형상을 평가하기 위해 이러한 종류의 매크로를 여러 개 갖게 될 것입니다 tikz
. 감사해요
답변1
TikZ 라이브러리를 function
사용하여 선언된 구현 중 하나는 다음과 같습니다 .math
\documentclass[tikz]{standalone}
\usetikzlibrary{math}
\tikzmath{function myscalefun(\a,\b,\c) {
if \a>10 then { return \a; } else {
if \b>10 then { return \b; } else {
return \c; }; };
};}
\begin{document}
\begin{tikzpicture}[scale=1]
\clip (0,0) rectangle (15.5,9);
\foreach \r in {8,...,15} {
\draw[gray!20] (0,0) circle (\r);
\node[above] at (\r,0) {\r};
}
\draw (0,0) -- ++(45:{myscalefun(9,12,10)});
\draw (0,0) -- ++(30:{myscalefun(11,12,10)});
\draw (0,0) -- ++(15:{myscalefun(9,8,9)});
\end{tikzpicture}
\end{document}