使用 resizeboxx 绘制 tikz 图时出错

使用 resizeboxx 绘制 tikz 图时出错

我的代码应该绘制一个函数和一个切线,但我得到了一个错误。我的想法是,如果我删除了带有闭合花括号的调整大小框,绘图会很顺利,但当我添加它时,我得到了这个错误:

\pgfplots@addplotimpl@expression@curly 的参数有一个额外的}。

我几天前一直试图检测这个问题,但没有成功。

 \documentclass[a4paper,12pt]{article}
\font\tenBbb=msbm10
\usepackage[lmargin=2 cm,rmargin=2
cm,tmargin=2cm,bmargin=2.5cm,
paper=a4paper]{geometry}
\usepackage{pgf,pgfplots,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
\usepackage{pdfrender}
\usepackage[francais]{babel}
\usepackage{color}
\usepackage{pifont}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath,amsfonts,amssymb,mathrsfs}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\usepackage{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz,tkz-tab}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{lipsum}
\usepackage{tikz-3dplot}
\usepackage{tkz-euclide}
\usepackage{siunitx}
\usetikzlibrary{intersections, arrows, calc,through,backgrounds}
\usetikzlibrary{quotes,angles}
\usetikzlibrary{shapes}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usetikzlibrary{arrows.meta}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
    \begin{center}
        \resizebox{12cm}{!}{
        \begin{tikzpicture}
            \begin{axis}[
                xlabel={$x$},
                ylabel={$y$},
                xmin=-9.75, xmax=19.75,
                ymin=-9.75, ymax=25,
                domain=-6:15,
                samples=100,
                axis lines=middle,
                xtick = {-8,-6,-4,...,14,16},
                ytick = {-8,-6,-4,...,20,22},
                grid=both,
                grid style={dotted}
                %width=10cm,
                %height=8cm,
                ]
                \addplot[ thick]{-2 + (x + 4)*exp(-x)};
                \addplot[blue, thick]{-3*x+2};
            \end{axis}
        \end{tikzpicture} }   
    \end{center}
    \end{document} 

相关内容