我正在使用 Overleaf 中的课程编写讲义report
。我想添加之前在另一个文档中制作的图表(名为图 1.2.1),并将其上传到main.tex
。我使用了import
,结果发生了这种情况。
这是我当时的代码:
We call set $C$ the graph of the function $y=f(x)$. The figure below is a graph of the function $f(x)=x^2$ defined over all real numbers.
\import{figures/}{fig 1.2.1}
这是我的代码fig 1.2.1.tex
。
\documentclass{standalone}
%maths
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
%tikz
\usepackage{tikz}
\usepackage{scalerel}
\usepackage{pict2e}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\usetikzlibrary{patterns,arrows.meta}
\usetikzlibrary{shadows}
\usetikzlibrary{external}
\usetikzlibrary{arrows,positioning,shapes,backgrounds,fit}
%pgflots
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{statistics}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{every axis/.style={scale only axis}}
%colors
\usepackage{xcolor}
\usepackage{nicefrac}
\begin{document}
\pgfplotsset{
standard/.style={
trig format = rad,
axis x line = middle,
axis y line = none,
every axis x label/.style={at={(current axis.right of origin)},anchor=west},
every axis y label/.style={at={(current axis.above origin)},anchor=south},
}
}
\begin{tikzpicture}
\begin{axis}[standard, width=10cm, height=8cm,
xtick={\empty},
ytick={\empty},
xticklabels={\empty},
yticklabels={\empty},
xlabel={$x$},
ylabel={$y$},
samples=1000,
xmin=-3, xmax=3,
ymin=-1, ymax=2]
\node[anchor=center,label=south west:O] at (axis cs:0.12,0.07){};
\coordinate (start_y) at (axis cs:0,-0.15); %y axis
\coordinate (end_y) at (axis cs:0,1.5);
\node[anchor=center,label=$y$] at (axis cs:0.175,1.44) {};
\draw[-stealth] (start_y) -- (end_y);
\addplot[domain={-2.1:2.1}]{0.3*x^2};
\draw (0.8,1.3) node [draw = rectangle, rounded corners] {\small Ran$(f)$};
\node (A) at (0.511,1.258) {};
\draw[-stealth](A) to [out=-2.4,in=0.1] (0,1.1);
\node[inner sep=0pt] (B) at (-1.632, 0.8) {};
\filldraw [black] (B) circle (1pt) node[left] {point $(x,y)$};
\node[inner sep=0pt] (Bx) at (-1.632, 0) {};
\node[inner sep=1pt] (By) at (0, 0.8) {};
\filldraw [black] (Bx) circle (1pt) node[below] {$x$};
\filldraw [black] (By) circle (1pt) node[right] {$x^2$};
\node[inner sep=0pt] (C) at (1.3662, 0.56) {};
\filldraw [black] (C) circle (1pt) node[right] {point $(x,y)$};
\node[inner sep=0pt] (Cx) at (1.3662, 0) {};
\node[inner sep=1pt] (Cy) at (0, 0.56) {};
\filldraw [black] (Cx) circle (1pt) node[below] {$x$};
\filldraw [black] (Cy) circle (1pt) node[left] {$x^2$};
\draw[-stealth] (Bx)--(B) node [midway, left] {$f$} ->(By) node [midway, above] {$f$} ;
\draw[-stealth] (Cx)--(C) node [midway, left] {$f$} ->(Cy) node [midway, above] {$f$};
\draw (1.5,-0.3) node [draw = rectangle, rounded corners] {\small Dom$(f)=\mathbb{R}\; (\text{all real numbers})$};
\draw[-stealth] (1.95,-0.2) -- (2,0);
\node[right] at (1.65, 0.8) {$y=f(x)$};
\draw (2.5,1.05) node [draw = rectangle, rounded corners] {\small graph $C$};
\draw[-stealth] (2.075,1.05)--(1.871,1.05);
\end{axis}
\end{tikzpicture}
\end{document}
1.2.11.2.1 出现在图表之前,我找不到删除它的方法。
TikZ
如果我的代码给您带来任何困扰,我深感抱歉。由于我最近才开始探索和的世界pgfplots
,因此非常欢迎对我的代码提出任何建议和更正。
附加信息:我的包裹main.tex
\usepackage[utf8]{inputenc}
%maths
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
%tikz
\usepackage{tikz}
\usepackage{scalerel}
\usepackage{pict2e}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\usetikzlibrary{patterns,arrows.meta}
\usetikzlibrary{shadows}
\usetikzlibrary{external}
\usetikzlibrary{arrows,positioning,shapes,backgrounds,fit}
%pgflots
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{statistics}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{every axis/.style={scale only axis}}
%colors
\usepackage{xcolor}
\usepackage{nicefrac}
%format
\def\thesection{\arabic{section}}
\def\thesubsection{\arabic{subsection}}
\def\thesubsubsection{\arabic{subsubsection}}
\setlength\parindent{10pt}
\usepackage{enumitem}
\usepackage{bm}
\usepackage{standalone}
\usepackage{import}
\usepackage{float}
答案1
我认为您的代码不能正常工作 :) 首先,在图中您有,这是错误的。如果您想指定形状,则 的draw=rectangle
参数应该是颜色名称。但是,是默认值,因此如果您没有更改默认值,您可以直接执行。draw
draw, rectangle
rectangle
draw
其次,我还必须补充\usepackage{amsmath, amssymb}
一点。main.tex
也就是说,它看起来import
不喜欢文件名中的空格,如果我将文件重命名fig1.2.1.tex
并进行main.tex
相应的更改,它似乎可以正常工作。