PDF 파일의 빈 tikz 그림

PDF 파일의 빈 tikz 그림

굉장히 문제가 될 수 있는 글이 될 수 있으니 미리 죄송합니다.

원고용으로 tikz를 이용하여 인물을 그리려고 하는데, 처음 사용해보니 아주 잘 되더라고요. 그러나 이제 "명령" 파일에 몇 가지 기능을 추가했으며 그 이후로 문서를 실행할 때 오류는 감지되지 않았지만 그림은 표시되지 않습니다. 대신 완전한 빈 페이지가 있는데 이유를 알 수 없습니다. ...

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

문제를 보여주는 축소된 코드는 다음과 같습니다.

\documentclass[a4paper,11pt,twoside]{book}

\include{formatAndDefs}

\begin{document}
\pagenumbering{roman}

\setcounter{page}{0}
\bibliographystyle{StyleThese}
\begin{vcenterpage}
\noindent\rule[2pt]{\textwidth}{0.5pt}

\begin{tikzpicture}[
scale = 0.675
]
\fill[cyan!25] plot[domain=0:8, samples=100] (\x, {gauss(\x)})|- (0,0);
\draw[very thick, orange!60]  plot[domain=0:9.5, samples=100] (\x, {gauss(\x)});
\fill[gray!25] (0,-0.5) -- (0,0) -- (9.5,0) -- (9.5,-0.5) -- (0,-0.5);
\fill[pattern = north east lines] (-0.5,-0.5) -- (0,-0.5) -- (0,4.5) -- (-0.5,4.5) -- (-0.5,-0.5);
\draw[red, dashed, thick, Stealth-Stealth] (-0.25,0) --node[fill=white,scale=0.75]{$h$} (-0.25,{gauss(0)});
\draw[red, dashed, thick, Stealth-Stealth] (0,-0.225) --node[fill=gray!25,scale=0.55]{$R$} (7,-0.27);
\draw[black, dashed, thick, Stealth-Stealth] (0,{gauss(0)}) --node[above,scale=0.65]{$L$} (7,0);
\node[below left, scale = 0.85] at (9,3) {$\boxed{\epsilon \approx \frac{L-R}{R}}$};
\end{tikzpicture}

\noindent\rule[2pt]{\textwidth}{0.5pt}
\end{vcenterpage}
\end{document}

문제는 사용자 정의된 명령 파일을 공유해야 한다는 것입니다. 문제를 해결하는 데 중요하기 때문입니다. 생성된 함수는 파일의 "일부 가우스 함수" 섹션에 표시됩니다.

%!TEX root = Main.tex


%%%%%% FIRST PART%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{breqn}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


\usepackage[left=1.5in,right=1.3in,top=1.1in,bottom=1.1in,includefoot,includehead,headheight=13.6pt]{geometry}
\renewcommand{\baselinestretch}{1.05}

% List of abbreviations
% Do not try putting acronyms in section titles, that would cause infinite loop of pdftex compilation
\usepackage[printonlyused,withpage]{acronym}

% My pdf code

\usepackage{ifpdf}

\graphicspath{{.}{images/}}

% Links in pdf


% Table of contents for each chapter

\usepackage[nottoc, notlof, notlot]{tocbibind}
\usepackage{minitoc}


\usepackage{fancyhdr}                    % Fancy Header and Footer


%%% Fancy Header %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fancy Header Style Options

\pagestyle{fancy}                       % Sets fancy header and footer
\fancyfoot{}                            % Delete current footer settings


\fancyhead[LE,RO]{\bfseries\thepage}    % Page number (boldface) in left on even
% pages and right on odd pages
\fancyhead[RE]{\bfseries\nouppercase{\leftmark}}      % Chapter in the right on even pages
\fancyhead[LO]{\bfseries\nouppercase{\rightmark}}     % Section in the left on odd pages

\let\headruleORIG\headrule
\renewcommand{\headrule}{\color{black} \headruleORIG}
\renewcommand{\headrulewidth}{1.0pt}
\usepackage{colortbl}
\arrayrulecolor{black}

\fancypagestyle{plain}{
  \fancyhead{}
  \fancyfoot{}
  \renewcommand{\headrulewidth}{0pt}
}


%%% Clear Header %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Clear Header Style on the Last Empty Odd pages
\makeatletter

\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else%
  \hbox{}%
  \thispagestyle{empty}%              % Empty header styles
  \newpage%
  \if@twocolumn\hbox{}\newpage\fi\fi\fi}

\makeatother


\let\minitocORIG\minitoc
\renewcommand{\minitoc}{\minitocORIG \vspace{1.5em}}

\usepackage{subfigure}
\usepackage{multirow}


\renewcommand{\epsilon}{\varepsilon}

% centered page environment

\newenvironment{vcenterpage}
{\newpage\vspace*{\fill}\thispagestyle{empty}\renewcommand{\headrulewidth}{0pt}}
{\vspace*{\fill}}

% Hyperref code

\ifpdf
  \usepackage[pagebackref,hyperindex=true]{hyperref}
\else
  \usepackage[dvipdfm,pagebackref,hyperindex=true]{hyperref}
\fi

% nicer backref links
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{%
\ifcase #1 %
(Non cité.)%
\or
(Cité en page~#2.)%
\else
(Cité en pages~#2.)%
\fi}
\renewcommand*{\backrefsep}{, }
\renewcommand*{\backreftwosep}{ et~}
\renewcommand*{\backreflastsep}{ et~}

% Change this to change the informations included in the pdf file

% See hyperref documentation for information on those parameters

\hypersetup
{
bookmarksopen=true,
pdftitle="Titre du manuscript",
pdfauthor="Votre nom", %auteur du document
pdfsubject="Description rapide du sujet du manuscrit", %sujet du document
%pdftoolbar=false, %barre d'outils non visible
pdfmenubar=true, %barre de menu visible
pdfhighlight=/O, %effet d'un clic sur un lien hypertexte
colorlinks=true, %couleurs sur les liens hypertextes
pdfpagemode=UseNone, %aucun mode de page
pdfpagelayout=SinglePage, %ouverture en simple page
pdffitwindow=true, %pages ouvertes entierement dans toute la fenetre
linkcolor=linkcol, %couleur des liens hypertextes internes
citecolor=citecol, %couleur des liens pour les citations
urlcolor=linkcol %couleur des liens pour les url
}


%%%%%SECOND PART%%%%%%%%%%%%


%%%%%%%%Geometry
\usepackage{geometry}
\usepackage{layout}
\geometry{hmargin = 2.5cm}
 \usepackage{parskip}

 
%%%Axis
\usepackage{pgfplots}
\pgfplotsset{compat=newest}


%%%%%%%%SPECIAL%%%%%%%%%%%%%
\def\doubleunderline#1{\underline{\underline{#1}}}
\DeclareMathOperator{\e}{e}
\renewcommand{\textbf}[1]{\begingroup\bfseries\mathversion{bold}#1\endgroup}

%%%%%%%%Sections & Drawings
\usepackage{multicol} % Colonnes
\usepackage{enumitem}
\usepackage{pgf, tikz, adjustbox}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{calc}
\usetikzlibrary{spy}
\usetikzlibrary{patterns, matrix, positioning}
\usetikzlibrary{arrows.meta,
                patterns.meta
                }


%%%%%%%%Some Gaussian functions
\pgfmathdeclarefunction{gauss}{1}{
    \pgfmathparse{3*exp(-(#1/3.85)^2)}
}
% Second function
\pgfmathdeclarefunction{gaussian}{2}
{%
    \pgfmathparse{(1/(#1 * sqrt(2 * pi))) * exp((-1 / 2) * (((x - #2)/#1) ^ 2))}%
}
\pgfmathsetmacro{\mean}{7}
\pgfmathsetmacro{\std}{0.3}

\newcommand\encircle[1]{%
  \tikz[baseline=(X.base)] 
    \node (X) [draw, thick, shape=circle, inner sep=0] {\strut #1};}  

       
%%%%%%%%BOXES
\usepackage[most]{tcolorbox}
\usepackage{wrapfig}
\tcbuselibrary{skins}

혼란스러운 설정에 대해 미리 사과드립니다. 누군가가 이 문제를 해결하도록 도와줄 수 있기를 바랍니다.

감사합니다,

답변1

공간이 중요할 수 있습니다. 가우스 함수 정의에 가짜 공간이 있습니다.

\pgfmathdeclarefunction{gauss}{1}{ %<------- here is a space (matters)
    \pgfmathparse{3*exp(-(#1/3.85)^2)} %<---- here too (probably harmless)
}

당신은 그것을 다음과 같이 변경해야합니다

\pgfmathdeclarefunction{gauss}{1}{%
    \pgfmathparse{3*exp(-(#1/3.85)^2)}}

샘플에 다른 숫자를 사용하면 어떤 일이 발생하는지 확인할 수 있습니다.

\documentclass[a4paper,11pt,twoside]{book}

\usepackage{tikz,xcolor,amsmath,amssymb}

\pgfmathdeclarefunction{gauss}{1}{
    \pgfmathparse{3*exp(-(#1/3.85)^2)}
}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows.meta,patterns.meta}

\begin{document}
\foreach\samples in {10,20,...,100}{%
\fbox{\begin{tikzpicture}
%\fill[cyan!25] plot[domain=0:8, samples=100] (\x, {gauss(\x)})|- (0,0);
\draw[very thick, orange!60]  plot[domain=0:9.5, samples=\samples] (\x, {gauss(\x)});
\fill[gray!25] (0,-0.5) -- (0,0) -- (9.5,0) -- (9.5,-0.5) -- (0,-0.5);
\fill[pattern = north east lines] (-0.5,-0.5) -- (0,-0.5) -- (0,4.5) -- (-0.5,4.5) -- (-0.5,-0.5);
\draw[red, dashed, thick, Stealth-Stealth] (-0.25,0) --node[fill=white,scale=0.75]{$h$} (-0.25,{gauss(0)});
\draw[red, dashed, thick, Stealth-Stealth] (0,-0.225) --node[fill=gray!25,scale=0.55]{$R$} (7,-0.27);
\draw[black, dashed, thick, Stealth-Stealth] (0,{gauss(0)}) --node[above,scale=0.65]{$L$} (7,0);
\node[below left, scale = 0.85] at (9,3) {$\boxed{\epsilon \approx \frac{L-R}{R}}$};
\end{tikzpicture}}\par}
\end{document}

공백이 채워지고 그림이 페이지 밖으로 밀려납니다.

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

답변2

설명이 너무 길어서 예를 다음과 같이 줄일 수 있습니다.

그림의 첫 번째 두 줄은 각각 내용을 사라지게 합니다. 이유는 모르겠지만.

\documentclass[a4paper,11pt,twoside]{book}

\usepackage{tikz,xcolor,amsmath,amssymb}

\pgfmathdeclarefunction{gauss}{1}{
    \pgfmathparse{3*exp(-(#1/3.85)^2)}
}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows.meta,patterns.meta}

\begin{document}
\begin{tikzpicture}
\fill[cyan!25] plot[domain=0:8, samples=100] (\x, {gauss(\x)})|- (0,0);
\draw[very thick, orange!60]  plot[domain=0:9.5, samples=100] (\x, {gauss(\x)});
\fill[gray!25] (0,-0.5) -- (0,0) -- (9.5,0) -- (9.5,-0.5) -- (0,-0.5);
\fill[pattern = north east lines] (-0.5,-0.5) -- (0,-0.5) -- (0,4.5) -- (-0.5,4.5) -- (-0.5,-0.5);
\draw[red, dashed, thick, Stealth-Stealth] (-0.25,0) --node[fill=white,scale=0.75]{$h$} (-0.25,{gauss(0)});
\draw[red, dashed, thick, Stealth-Stealth] (0,-0.225) --node[fill=gray!25,scale=0.55]{$R$} (7,-0.27);
\draw[black, dashed, thick, Stealth-Stealth] (0,{gauss(0)}) --node[above,scale=0.65]{$L$} (7,0);
\node[below left, scale = 0.85] at (9,3) {$\boxed{\epsilon \approx \frac{L-R}{R}}$};
\end{tikzpicture}
\end{document}

그리고 @hpekristiansen은 다음과 같이 설명합니다.

\documentclass[tikz, border=1cm]{standalone}     
\pgfmathdeclarefunction{gauss}{1}{     
\pgfmathparse{3*exp(-(#1/3.85)^2)} } 
\begin{document} 
\begin{tikzpicture} 
\fill plot[samples=100] (\x, {gauss(\x)}); 
\draw (0,0) -- (1,1); 
\end{tikzpicture} 
\end{document}

관련 정보