
Esta podría ser una publicación muy problemática, lo siento de antemano.
Estoy intentando dibujar una figura usando tikz para un manuscrito y cuando lo usé, la primera vez funcionó muy bien. Pero ahora agregué algunas funciones en mi archivo de "comandos" y desde entonces, cuando ejecuto mi documento: no se detecta ningún error, pero la figura simplemente no aparece: en cambio, hay una página completamente en blanco y no entiendo por qué. ...
Aquí está mi código reducido que muestra el 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}
El problema es que estoy obligado a compartir mi archivo de comandos personalizado... Ya que es importante para resolver el problema. La función creada se muestra en la sección "Algunas funciones gaussianas" del archivo.
%!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}
Pido disculpas de antemano por esta configuración confusa, espero que alguien todavía pueda ayudarme con este problema.
Gracias,
Respuesta1
El espacio puede importar. Tienes un espacio espurio en la definición de tu función Gauss:
\pgfmathdeclarefunction{gauss}{1}{ %<------- here is a space (matters)
\pgfmathparse{3*exp(-(#1/3.85)^2)} %<---- here too (probably harmless)
}
Deberías cambiar eso a
\pgfmathdeclarefunction{gauss}{1}{%
\pgfmathparse{3*exp(-(#1/3.85)^2)}}
Puedes ver lo que sucede si usas números diferentes para las muestras:
\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}
Los espacios se acumulan y sacan tu imagen de la página:
Respuesta2
Demasiado largo para comentar, el ejemplo puede reducirse a
Las dos primeras líneas de la imagen hacen que el contenido desaparezca. Aunque no sé 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}
Y por @hpekristiansen más abajo a esto:
\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}