声明函数时,\y 为无法识别的命令

声明函数时,\y 为无法识别的命令

我目前正在写论文,在编译包含声明函数的 tikz 文件时遇到了问题。当我使用独立文档时,图表可以顺利编译。问题似乎源于定义函数时 \y 是一个无法识别的命令。

\documentclass[11pt,a4 paper]{book}

%Miscellaneous
\usepackage{geometry}
\newgeometry{inner=3cm,outer=2cm,top=2.5cm,bottom=2.5cm}
\usepackage{siunitx,appendix}
\usepackage{amsmath}
\usepackage[version=4]{mhchem}
\linespread{1.5}
\usepackage{lmodern}
\usepackage{pifont}
\newcommand{\cmark}{\ding{51}}
\usepackage{amssymb}
\usepackage{indentfirst}
\usepackage{enumerate}
\usepackage{eso-pic}
\usepackage{pgfornament}
\usepackage{nameref}
\hfuzz=5pt

%Figures
\usepackage{graphicx,caption,subcaption,float,cite}

%Tikz
\usepackage{tikz,pgfplots,rotating,pgfplotstable}
\usetikzlibrary{arrows,decorations.pathmorphing,shadings,calc,intersections,positioning,pgfplots.groupplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{external} 
\tikzexternalize


%Tables
\usepackage{booktabs,tabularx,multirow}
\usepackage{adjustbox}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newlength\wexp
\settowidth{\wexp}{Exponential}
\newcolumntype{C}{>{\centering\arraybackslash}p{\dimexpr.53\wexp-\tabcolsep}}

\usepackage[Sonny]{fncychap}
\renewcommand{\thefootnote}{\alph{footnote}}


%%%%%FRENCH ABSTRACT%%%%%%%%%%%%%%
\usepackage[french,english]{babel}

%%%%%%TOC%%%%%%%%

\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\usepackage[]{hyperref}
\hypersetup{
    colorlinks,
    citecolor=blue,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}
\usepackage{titlesec}   

\begin{document}

        \begin{tabular}{c c}
        \begin{tikzpicture}[declare function={erf(\x)=(1+(e^(-(\x*\x))*(-265.057+abs(\x)*(-135.065+abs(\x)*(-59.646+(-6.84727-0.777889*abs(\x))*abs(\x)))))/(3.05259+abs(\x))^5)*(\x>0?1:-1);},declare function={erf2(\x,\y)=erf(\x)+erf(\y);},scale=0.8]
        \begin{axis}[title = (a) Original BE for Fermi level, xlabel=BE (eV),ylabel=Intensity (CPS),x dir=reverse,axis y line*=left]% function
        \addplot [domain = -1.1:1.3,red,thick]
        {0.5*209.5*(1+0.354*(x-0.086))+209.5/ sqrt(2*3.141)*0.354*0.143*exp(-(x-0.087)^(2)/(2*0.14*0.14))+0.5*209.5*(1+0.35*(x-0.086))*erf((x-0.086)/sqrt(2)/0.14)+6.17}; \label{P2}
        \addplot [black] table[x={BE},y={Intensity}] {Fermi_start.txt}; \label{P1}
        
        \draw [dashed, thick] (axis cs:0,0)--(axis cs:0,320);
        \end{axis}
        
        \begin{axis}[xlabel=Binding Energy(eV),ylabel=dI/dE,x dir=reverse,,axis y line*=right,
        axis x line=none,ylabel near ticks, yticklabel pos=right,legend style={fill=none,draw=none}]
        \addlegendimage{/pgfplots/refstyle=P1}\addlegendentry{Measured}
        \addlegendimage{/pgfplots/refstyle=P2}\addlegendentry{Fit}
        \addplot [blue,thick] table[x=BE,y=Intensity] {fermi_der_start.txt}; \label{P3}
        \addlegendentry{Derivative}
        \end{axis}
        \end{tikzpicture}
        &
        %SHIFTED
        \begin{tikzpicture}[declare function={erf(\x)=(1+(e^(-(\x*\x))*(-265.057+abs(\x)*(-135.065+abs(\x)*(-59.646+(-6.84727-0.777889*abs(\x))*abs(\x)))))/(3.05259+abs(\x))^5)*(\x>0?1:-1);},declare function={erf2(\x,\y)=erf(\x)+erf(\y);},scale=0.8]
        \begin{axis}[title = (b) Corrected BE for Fermi level, xlabel=BE (eV),ylabel=Intensity (CPS),x dir=reverse,axis y line*=left]% function
        \addplot [domain = -1.2:1.2,red,thick]
        {0.5*209.5*(1+0.354*(x-0.001))+209.5/ sqrt(2*3.141)*0.354*0.143*exp(-(x-0.001)^(2)/(2*0.14*0.14))+0.5*209.5*(1+0.35*(x-0.001))*erf((x-0.001)/sqrt(2)/0.14)+6.17};\label{P4}
        \addplot [black] table[x={BE},y={Intensity}] {Fermi_shift.txt}; \label{P5}
        
        \draw [dashed, thick] (axis cs:0,0)--(axis cs:0,320);
        \end{axis}
        
        \begin{axis}[xlabel=Binding Energy(eV),ylabel=dI/dE,x dir=reverse,axis y line*=right,
        axis x line=none,ylabel near ticks, yticklabel pos=right,legend style={fill=none,draw=none}]
        \addlegendimage{/pgfplots/refstyle=P1}\addlegendentry{Measured}
        \addlegendimage{/pgfplots/refstyle=P2}\addlegendentry{Fit}
        \addplot [blue,thick] table[x=BE,y=Intensity] {fermi_der_shifted.txt};\label{P6}
        \addlegendentry{Derivative}
        \end{axis}
        \end{tikzpicture}
        \\
        \end{tabular}

\end{document}```

相关内容