我在一个单独的文件中绘制了一些图表,当我将其粘贴到另一个文件(“书”)时,现在出现了错误。我在两个文件中都使用了相同的序言:
\documentclass[a4paper,11pt,openany,draft]{book} %draft faz aparecer uns quadrados pretos no fim de alguns mathmode e imagens, então não esquenta se aparecer
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage[a4paper,includemp,includefoot, twoside=true inner=1.25in, outer=0.75in]{geometry} %top=2.5cm,bottom=3cm,left=2.5cm,right=3.5cm %ver as margens e coisa - http://texdoc.net/texmf-dist/doc/latex/geometry/geometry.pdf
\usepackage{marginnote} % tem que rodar duas vezes para ficar direito. A contagem de páginas é diferente da do próprio LaTeX. TEM QUE VER A GEOMETRIA PARA USAR AS MARGIN NOTES.
\usepackage{multicol}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{pifont}
\usepackage[T1]{fontenc}
\usepackage{gensymb}
\usepackage[table, xcdraw]{xcolor}
\usepackage{tikz}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{pgfplots}
\usetikzlibrary{intersections}
\usetikzlibrary{patterns}
\usetikzlibrary{calc,matrix}
\usepgfplotslibrary{fillbetween}
\usepackage[colorlinks=false]{hyperref}
\usepackage{blindtext}
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[scaled]{berasans}
\usepackage[super, square]{natbib}
\usepackage{comment}
\usepackage{polynom}
\usepackage{framed}
\newtheorem{teo}{Teorema}[chapter]
\newtheorem{post}{Postulado}[part]
\newtheorem*{lema}{Lema}
\theoremstyle{definition} \newtheorem*{df}{Definição}
\newtheorem*{prop}{Propriedade}
\newcounter{examplecounter}
\newenvironment{exemplo}{\begin{framed}\noindent \refstepcounter{examplecounter} {\textbf{Exemplo \arabic{examplecounter}.}} }{\end{framed}}
\newenvironment{note}{\par \vspace{10pt} \textsc{Versão Humana}\\ \begin{small}}{\\ \noindent\hrule \vspace{10pt} \end{small}}
%%%%%% TRIGONOMETRICAS - as que precisam e as que não precisam também %%%%%%
\providecommand{\sin}{} \renewcommand{\sin}{\hspace{2pt}\mathrm{sen}}
\providecommand{\cos}{} \renewcommand{\cos}{\hspace{2pt}\mathrm{cos}}
\providecommand{\tan}{} \renewcommand{\tan}{\hspace{2pt}\mathrm{tg}}
\providecommand{\sec}{} \renewcommand{\sec}{\hspace{2pt}\mathrm{sec}}
\providecommand{\csc}{} \renewcommand{\csc}{\hspace{2pt}\mathrm{csc}}
\providecommand{\cot}{} \renewcommand{\cot}{\hspace{2pt}\mathrm{cotg}}
\bibliographystyle{docs/plainnapt}
\captionsetup[table]{skip=10pt}
新代码是:
\begin{exemplo}
%text
\begin{figure}[H]
\centering
\begin{subfigure}[b]{0.4\linewidth}
\centering
\begin{tikzpicture}
\begin{axis}[
unit vector ratio* = 1 1 1,
axis lines = middle,
xtick = {-2,2},
ytick = {-2,2},
xmin = -3,
xmax = 3,
ymin = -3,
ymax = 3,
xlabel = $x$,
ylabel = $y$
]
\addplot[samples=100, domain=-2:2, dashed, name path=A] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-2:2, dashed, name path=B] {-sqrt(-x^2+4)};
\path[name path=xaxis] (\pgfkeysvalueof{/pgfplots/xmin}, -3) -- (\pgfkeysvalueof{/pgfplots/xmax},3);
\addplot[gray, color=lime!60!white] fill between[of=A and B, soft clip={domain=-3:3}];
\end{axis}
\end{tikzpicture}
\caption{$x^2+y^2<4$}
\end{subfigure}
\qquad
\begin{subfigure}[b]{0.4\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
unit vector ratio* = 1 1 1,
axis lines = middle,
xtick = {-2},
ytick = {2},
xmin = -3,
xmax = 3,
ymin = -3,
ymax = 3,
xlabel = $x$,
ylabel = $y$
]
\addplot[samples=100, domain=-3:2, name path=A] {x+2};
\addplot[samples=100, domain=-3:1, color=olive!60!white, name path=B] {3};
\path[name path=xaxis] (\pgfkeysvalueof{/pgfplots/xmin}, -3) -- (\pgfkeysvalueof{/pgfplots/xmax},3);
\addplot[gray, color=olive!60!white] fill between[of=A and B, soft clip={domain=-3:3}];
\end{axis}
\end{tikzpicture}
\caption{$x+2 \le y$}
\end{subfigure}
\\
\begin{subfigure}[b]{0.4\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
unit vector ratio* = 1 1 1,
axis lines = middle,
xtick = {-2,2},
ytick = {-2,2},
xmin = -3,
xmax = 3,
ymin = -3,
ymax = 3,
xlabel = $x$,
ylabel = $y$
]
\addplot[samples=100, domain=-2:2, color=olive!60!white, name path=A] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-2:2, color=lime, name path=B] {-sqrt(-x^2+4)};
\addplot[samples=100, domain=-3:-2, name path=C] {x+2};
\addplot[samples=100, domain=0:5, name path=C_1] {x+2};
\addplot[samples=100, domain=-3:1, color=white, name path=D] {3};
\addplot[samples=100, domain=0:3, dashed, name path=E] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-3:3, dashed, name path=F] {-sqrt(-x^2+4)};
\path[name path=xaxis] (\pgfkeysvalueof{/pgfplots/xmin}, -3) -- (\pgfkeysvalueof{/pgfplots/xmax},3);
\addplot[gray, color=lime!60!white] fill between[of=A and B, soft clip={domain=-3:3}];
\addplot[gray, color=olive!60!white] fill between[of=C and D, soft clip={domain=-3:3}];
\end{axis}
\end{tikzpicture}
\caption{$R \cup S$}
\end{subfigure}
\qquad
\begin{subfigure}[b]{0.4\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
unit vector ratio* = 1 1 1,
axis lines = middle,
xtick = {-2,2},
ytick = {-2,2},
xmin = -3,
xmax = 3,
ymin = -3,
ymax = 3,
xlabel = $x$,
ylabel = $y$
]
\addplot[samples=100, domain=-2:0, dashed, name path=A] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-3:4, thin, dashed, name path=E] {x+2};
\addplot[samples=100, domain=-2:0, name path=B] {x+2};
\addplot[samples=100, domain=0:2, dashed, name path=C] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-2:2, dashed, name path=D] {-sqrt(-x^2+4)};
\path[name path=xaxis] (\pgfkeysvalueof{/pgfplots/xmin}, -3) -- (\pgfkeysvalueof{/pgfplots/xmax},3);
\addplot[gray, color=lime!60!white] fill between[of=A and B, soft clip={domain=-3:3}];
\end{axis}
\end{tikzpicture}
\caption{$R \cap S$}
\end{subfigure}
\\
\begin{subfigure}[b]{0.4\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
unit vector ratio* = 1 1 1,
axis lines = middle,
xtick = {-2,2},
ytick = {-2,2},
xmin = -3,
xmax = 3,
ymin = -3,
ymax = 3,
xlabel = $x$,
ylabel = $y$
]
\addplot[samples=100, domain= -5:0, white, name path=A] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-2:0, dashed, name path=B] {x+2};
\addplot[samples=100, domain=-5:5, dashed, name path=C] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-5:5, dashed, name path=D] {-sqrt(-x^2+4)};
\path[name path=xaxis] (\pgfkeysvalueof{/pgfplots/xmin}, -3) -- (\pgfkeysvalueof{/pgfplots/xmax},3);
\addplot[gray, color=lime!60!white] fill between[of=C and D, soft clip={domain=-3:3}];
\addplot[gray, color=white] fill between[of=B and A, soft clip={domain=-3:3}];
\end{axis}
\end{tikzpicture}
\caption{$R - S$}
\end{subfigure}
\qquad
\begin{subfigure}[b]{0.4\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
unit vector ratio* = 1 1 1,
axis lines = middle,
xtick = {-2,2},
ytick = {-2,2},
xmin = -3,
xmax = 3,
ymin = -3,
ymax = 3,
xlabel = $x$,
ylabel = $y$
]
\addplot[samples=100, domain=-2:0, name path=A] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-5:5, dashed, name path=A] {sqrt(-x^2+4)};
\addplot[samples=100, domain=-5:5, dashed, name path=B] {-sqrt(-x^2+4)};
\addplot[samples=100, domain=-5:5, dashed, name path=C] {x+2};
\addplot[samples=100, domain=-5:1, color=lime!60!white, name path=D] {3};
\path[name path=xaxis] (\pgfkeysvalueof{/pgfplots/xmin}, -3) -- (\pgfkeysvalueof{/pgfplots/xmax},3);
\addplot[gray, color=olive!60!white] fill between[of=C and D, soft clip={domain=-3:3}];
\addplot[gray, white] fill between[of=A and B, soft clip={domain=-3:3}];
\end{axis}
\end{tikzpicture}
\caption{$S - R$}
\end{subfigure}
\end{figure}
%text
\end{exemplo}
但我发现问题出在“exemplo”的环境上。
有人知道如何帮忙吗?
编辑
这是一个“真正的” MWE:
\documentclass{book}
\usepackage{framed}
\newcounter{examplecounter}
\newenvironment{exemplo}{%
\begin{framed}%
\noindent
\refstepcounter{examplecounter}
{\textbf{Exemplo \arabic{examplecounter}.}}
}{\end{framed}}
\begin{document}
\begin{exemplo}
\begin{figure}
\end{figure}
\end{exemplo}
\end{document}