Figura tikz em branco em um arquivo pdf

Figura tikz em branco em um arquivo pdf

Esta pode ser uma postagem muito problemática, desculpe antecipadamente.

Estou tentando desenhar uma figura usando tikz para um manuscrito e quando usei, na primeira vez funcionou muito bem. Mas agora adicionei algumas funções ao meu arquivo de "comando" e desde então, quando executo meu documento: nenhum erro é detectado, mas a figura simplesmente não aparece: em vez disso, há uma página em branco completa e não entendo por que ...

insira a descrição da imagem aqui

Aqui está meu código reduzido mostrando o problema:

\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}

O problema é que sou obrigado a compartilhar meu arquivo de comando personalizado... Pois é importante para resolver o problema. A função criada é mostrada na seção "Algumas funções gaussianas" do arquivo.

%!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}

Peço desculpas antecipadamente por esta configuração confusa, espero que alguém ainda possa me ajudar com esse problema.

Obrigado,

Responder1

O espaço pode ser importante. Você tem um espaço espúrio na definição da sua função gauss:

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

Você deveria mudar isso para

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

Você pode ver o que acontece se usar números diferentes para as amostras:

\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}

Os espaços se acumulam e empurram sua imagem para fora da página:

insira a descrição da imagem aqui

Responder2

Muito longo para comentários, o exemplo pode ser reduzido a

Cada uma das duas primeiras linhas da imagem faz com que o conteúdo desapareça. Embora eu não saiba por quê.

\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}

E por @hpekristiansen mais adiante:

\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}

informação relacionada