\tikzmath{함수....?의 구문

\tikzmath{함수....?의 구문

\tikzmath여기서 두 함수 정의 함수 의 구문에 어떤 문제가 있나요 ?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}
\tikzmath{function f(\x) { return sin(\x);
  }

\begin{document}

\begin{tikzpicture}    

  \tikzmath{function g(\x) { return cos(\x);
  };

\end{tikzpicture}

\end{document}

(부드럽게 생각해주세요. 저는 아직 랭크 초보자입니다 TikZ!)

답변1

다음은 약간의 사용 예입니다. 나는 서문이 아닌 사이 \tikzmath에 를 사용한다는 점에 유의하십시오.\begin{document}\end{document}

세미 컬럼 배치 정보: 매뉴얼에는 다음과 같이 명시되어 있습니다.모든 (tikzmath) 문은 세미콜론으로 끝나야 합니다..

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}

\begin{document}

\tikzmath{
    function f(\x) { 
        return sin(\x);
        };
    real \f;
    \f = f(90);
    print \f;
    print \newline; % new line; the next line begins with no indent
    print f(45); % prints "f(45)" verbatim
    % No blank line allowed
    print \par; % new paragraph; the next line begins with an indent
    \f = f(-45);
    print \f;
}

Foo

\begin{tikzpicture}    

\tikzmath{
    function g(\x) {
        return cos(\x);
        };
    real \g;
    \g = g(180);
    };
\node at (0,0) {\g}; % use \g outside of \tikzmath, in a tikz node 
\end{tikzpicture}

\end{document}

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

편집하다:진술이 무엇인지 자세히 알아보세요.

pgf/Ti에 따르면케이Z 매뉴얼에는 명령에 다양한 유형의 명령문이 있습니다 \tikzmath.

  • 할당(예: \a = 3 + 4;또는 let \x = 2*3;)
  • "유형 선언"( int \i;, real \z;또는 coordinate \c;)
  • 반복(예 for \n in {1,...,5} {⟨other statements⟩};: )
  • 조건부(예 if ⟨condition⟩ then ⟨statements⟩ else ⟨statements⟩;: )
  • 함수 선언(예 : 여기에도 명령문이 있고 첫 번째 코드의 두 번째 코드는 함수 선언문에 대한 것임을 function product(\x,\y) {return \x*\y;};참고하세요 )return \x*\y;;

문이 중괄호로 시작하는 경우 {닫는 중괄호 }뒤에 세미열이 와야 합니다.

여기에서는 pgf/Ti의 예를 들어 보겠습니다.케이추가 설명이 포함된 Z 매뉴얼(섹션 58.7파서 외부에서 코드 실행, 현재 매뉴얼의 708페이지):

\begin{tikzpicture}
\draw [help lines] grid (3,2); % a common `\draw` TikZ command,
                               % which ends with a ";"
\tikzmath{ % begin of the \tikzmath command. Not a statemnt
  coordinate \c;               % a statement
  for \x in {0,10,...,360} {   % begin of a statement, no ";" here
    \c = (1.5cm, 1cm) + (\x:1cm and 0.5cm); % a statement inside
                                            % the for statement
    { \fill (\c) circle [radius=1pt]; }; % a second statement
                                         % inside the for statement.
                                         % In it, a common TikZ command
                                         % (`\draw`) which ends as usual
                                         % by a semi-column.
  }; % the end of the for statement. Ended by a semi-column
} % end of \tikzmath command. It's not a statement
\end{tikzpicture}

\draw내부의 Tikz 명령은 \tikzmath중괄호로 둘러싸여 있으므로 for ;끝 뒤에는 닫는 중괄호 뒤에도 \draw있습니다 .;

관련 정보