매크로 값에서 tikzpicture의 샘플 설정

매크로 값에서 tikzpicture의 샘플 설정

전 세계적으로 tikzpicture당 샘플 양을 설정하려고 합니다.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfmathdeclarefunction{gauss}{2}{%
  \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
%\samplesize = <number>% How do I get this one to work?
\begin{document}  
\section{Gaussian distribution}

\begin{tikzpicture}
\begin{axis}[
      hide y axis,
      axis lines*=center, 
      axis on top,
      no markers, 
      domain=2.5:25.5, 
      samples=\samplesize,
      xlabel=\empty, 
      ylabel=\empty,
      every axis x label/.style={at=(current axis.right of origin),anchor=west},
      every axis y label/.style={at=(current axis.above origin),anchor=south},
      height=5cm, width=12cm,
      xmin = 4, xmax=24,
      xtick={14}, ytick=\empty,
      enlargelimits=false, 
      clip=false,
      grid=major
  ]
  \addplot [fill=cyan!20, draw=cyan!80, domain=4:7] {gauss(14,3.41696)} \closedcycle;
  \addplot [very thick,cyan!50!black] {gauss(14,3.416969)};
\end{axis}
\end{tikzpicture}
\end{document}

\valueTeX 기본 카운터, , \def, \let, \newcommand등과 함께 작동하도록 할 수 없습니다 .

답변1

\newcommand이를 위해 사용할 수 있습니다 . 예:

\newcommand\samplesize{100}

또한 기본적으로 standalone클래스는 섹션 제목을 처리하지 않는 것 같지만 추가하면 varwidth=true작동합니다. (비록 그것은 \section아마도 완전한 문서의 유물이었을 것입니다.)

전체 코드:

\documentclass[varwidth=true]{standalone}
\usepackage{pgfplots}
\pgfmathdeclarefunction{gauss}{2}{%
  \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}

\newcommand\samplesize{100}

\begin{document}  
\section{Gaussian distribution}

\begin{tikzpicture}
\begin{axis}[
      hide y axis,
      axis lines*=center, 
      axis on top,
      no markers, 
      domain=2.5:25.5, 
      samples=\samplesize,
      xlabel=\empty, 
      ylabel=\empty,
      every axis x label/.style={at=(current axis.right of origin),anchor=west},
      every axis y label/.style={at=(current axis.above origin),anchor=south},
      height=5cm, width=12cm,
      xmin = 4, xmax=24,
      xtick={14}, ytick=\empty,
      enlargelimits=false, 
      clip=false,
      grid=major
  ]
  \addplot [fill=cyan!20, draw=cyan!80, domain=4:7] {gauss(14,3.41696)} \closedcycle;
  \addplot [very thick,cyan!50!black] {gauss(14,3.416969)};
\end{axis}
\end{tikzpicture}
\end{document}

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

관련 정보