我希望在同一帧中获取彼此相邻的两幅图像。这就是我想要做的:
我有这个:
\documentclass[12pt]{article}
\usepackage[lmargin=.5in, rmargin=1.5in, marginpar=1.3in]{geometry}
\geometry{letterpaper}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{array}
\usepackage{paralist}
\usepackage{verbatim}
\usepackage{subfig}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{todonotes}
\usepackage{pgfplots,tkz-euclide}
\usetikzlibrary{arrows,intersections}
\usetikzlibrary{spy}
\usetkzobj{all}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{}\chead{}\rhead{}
\lfoot{}\cfoot{\thepage}\rfoot{}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb,amsfonts, fancyhdr, color, comment, graphicx, environ}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage[shortlabels]{enumitem}
\usepackage{indentfirst}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=blue,
\newenvironment{Background2}[0]
{ \begin{mdframed}[backgroundcolor=purple!20,
hidealllines=true,
leftmargin=0cm,rightmargin=7.5cm
]}
{ \end{mdframed}}
}
\begin{Background2}
\begin{tikzpicture}[
thick,
>=stealth',
dot/.style = {
draw,
fill = white,
circle,
inner sep = 0pt,
minimum size = 4pt
}
\begin{document}
]
\coordinate (O) at (0,0);
\draw[->] (-0.3,0) -- (8,0) coordinate[label = {below:$x$}] (xmax);
\draw[->] (0,-0.3) -- (0,5) coordinate[label = {right:$f(x) \ \ \cdot m>0 \text{ then the line goes upwards}$}] (ymax);
\path[name path=x] (0.3,0.5) -- (6.7,4.7);
\path[name path=y] plot[smooth] coordinates {(-0.3,2) (2,1.5) (4,2.8) (6,5)};
\scope[name intersections = {of = x and y, name = i}]
\fill[gray!50] (i-1) -- (i-2 |- i-1) -- (i-2) -- cycle;
\draw (0.3,0.5) -- (6.7,4.7) node[pos=0.8, below right] {\large \ \ \ $\frac{\Delta y}{\Delta x}>0$};
\draw (i-1) node[dot, label = {above:$f(x_0)$}] (i-1) {} -- node[left]
{} (i-1 |- O) node[dot, label = {below:$x_0$}] {};
\path (i-2) node[dot, label = {above:$\ \ \ \ \ \ \ f(x_0+\Delta x)$}] (i-2) {} -- (i-2 |- i-1)
node[dot] (i-12) {};
\draw (i-12) -- (i-12 |- O) node[dot,
label = {below:$x_0 + \Delta x$}] {};
\draw[blue, <->] (i-2) -- node[right] {\large $\Delta y>0$}
(i-12);
\draw[blue, <->] (i-1) -- node[below] {\large $\Delta x>0$} (i-12);
\path (i-1 |- O) -- node[below] {$\Delta x$} (i-2 |- O);
\endscope
\end{tikzpicture}
\end{Background2}
\end{document}
答案1
您的代码不起作用,至少在我的计算机上不起作用。您不需要mdframed
对 的背景进行阴影处理tikzpicture
,这可以通过库来完成backgrounds
。
\documentclass[12pt]{article}
\usepackage[lmargin=.5in, rmargin=1.5in, marginpar=1.3in]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,intersections,backgrounds}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{}\chead{}\rhead{}
\lfoot{}\cfoot{\thepage}\rfoot{}
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=blue,}
\begin{document}
\begin{tikzpicture}[
thick,
>=stealth',
dot/.style = {
draw,
fill = white,
circle,
inner sep = 0pt,
minimum size = 4pt
},
background rectangle/.style={fill=purple!20},
show background rectangle
]
\begin{scope}
\coordinate (O) at (0,0);
\draw[->] (-0.3,0) -- (8,0) coordinate[label = {below:$x$}] (xmax);
\draw[->] (0,-0.3) -- (0,5) coordinate[label = {right:$f(x) \ \ \cdot m>0 \text{ then the line goes upwards}$}] (ymax);
\path[name path=x] (0.3,0.5) -- (6.7,4.7);
\path[name path=y] plot[smooth] coordinates {(-0.3,2) (2,1.5) (4,2.8) (6,5)};
\begin{scope}[name intersections = {of = x and y, name = i}]
\fill[gray!50] (i-1) -- (i-2 |- i-1) -- (i-2) -- cycle;
\draw (0.3,0.5) -- (6.7,4.7) node[pos=0.8, below right] {\large \ \ \ $\frac{\Delta y}{\Delta x}>0$};
\draw (i-1) node[dot, label = {above:$f(x_0)$}] (i-1) {} -- node[left]
{} (i-1 |- O) node[dot, label = {below:$x_0$}] {};
\path (i-2) node[dot, label = {above:$\ \ \ \ \ \ \ f(x_0+\Delta x)$}] (i-2) {} -- (i-2 |- i-1)
node[dot] (i-12) {};
\draw (i-12) -- (i-12 |- O) node[dot,
label = {below:$x_0 + \Delta x$}] {};
\draw[blue, <->] (i-2) -- node[right] {\large $\Delta y>0$}
(i-12);
\draw[blue, <->] (i-1) -- node[below] {\large $\Delta x>0$} (i-12);
\path (i-1 |- O) -- node[below] {$\Delta x$} (i-2 |- O);
\end{scope}
\end{scope}
%
\begin{scope}[xshift=9cm]
\coordinate (O) at (0,0);
\draw[->] (-0.3,0) -- (8,0) coordinate[label = {below:$x$}] (xmax);
\draw[->] (0,-0.3) -- (0,5)
coordinate[label = {right:$f(x) \ \ \cdot m>0 \text{ then the line goes downwards}$}] (ymax);
\path (0.3,4) -- (6.7,-0.2) coordinate[pos=0.3] (x-1)
coordinate[pos=0.7] (x-2) ;
\fill[gray!50] (x-1) -- (x-1 |- x-2) -- (x-2) -- cycle;
\draw (0.3,4) -- (6.7,-0.2)
node[pos=0.15, above right,font=\large] {$\frac{\Delta y}{\Delta x}<0$};
\draw (x-1) node[dot](d1){} -- (x-1|-O) node[dot,label=below:$x_0$]{}
(x-2) node[dot](d2){} -- (x-2|-O) node[dot,label=below:$x_0+\Delta x$]{};
\draw[blue, <->] (x-2|-x-1) -- node[right,font=\large] {\large $\Delta y<0$}
(d2);
\draw[blue, <->] (d1) -- node[above,font=\large] {$\Delta x>0$} (x-2|-x-1);
\end{scope}
\end{tikzpicture}
\end{document}
顺便说一句,有很多方法可以改进 中的代码tikzpicture
。下面有一些建议,但尚未完全优化。
\documentclass[12pt]{article}
\usepackage[lmargin=.5in, rmargin=1.5in, marginpar=1.3in]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,intersections,backgrounds}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{}\chead{}\rhead{}
\lfoot{}\cfoot{\thepage}\rfoot{}
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=blue,}
\begin{document}
\begin{tikzpicture}[
thick,
>=stealth',
dot/.style = {
draw,
fill = white,
circle,
inner sep = 0pt,
minimum size = 4pt
},
background rectangle/.style={fill=purple!20},
show background rectangle
]
\begin{scope}
\coordinate (O) at (0,0);
\draw[->] (-0.3,0) -- (8,0) coordinate[label = {below:$x$}] (xmax);
\draw[->] (0,-0.3) -- (0,5) coordinate[label = {right:$f(x) \ \ \cdot m>0 \text{ then the line goes upwards}$}] (ymax);
\path (0.3,0.5) -- (6.7,4.7) coordinate[pos=0.25] (i-1) coordinate[pos=0.7] (i-2) ;
\fill[gray!50] (i-1) -- (i-2 |- i-1) -- (i-2) -- cycle;
\draw (0.3,0.5) -- (6.7,4.7) node[pos=0.8, below right,font=\large]
{$\frac{\Delta y}{\Delta x}>0$};
\draw (i-1) node[dot, label = {above left:$f(x_0)$}] (i-1) {} -- node[left]
{} (i-1 |- O) node[dot, label = {below:$x_0$}] {};
\path (i-2) node[dot, label = {above left:$f(x_0+\Delta x)$}] (i-2) {} -- (i-2 |- i-1)
node[dot] (i-12) {};
\draw (i-12) -- (i-12 |- O) node[dot,
label = {below:$x_0 + \Delta x$}] {};
\draw[blue, <->] (i-2) -- node[right,font=\large] {$\Delta y>0$}
(i-12);
\draw[blue, <->] (i-1) -- node[below,font=\large] {$\Delta x>0$} (i-12);
\path (i-1 |- O) -- node[below] {$\Delta x$} (i-2 |- O);
\end{scope}
%
\begin{scope}[xshift=9cm]
\coordinate (O) at (0,0);
\draw[->] (-0.3,0) -- (8,0) coordinate[label = {below:$x$}] (xmax);
\draw[->] (0,-0.3) -- (0,5)
coordinate[label = {right:$f(x) \ \ \cdot m<0 \text{ then the line goes downwards}$}] (ymax);
\path (0.3,4) -- (6.7,-0.2) coordinate[pos=0.3] (x-1)
coordinate[pos=0.7] (x-2) ;
\fill[gray!50] (x-1) -- (x-1 |- x-2) -- (x-2) -- cycle;
\draw (0.3,4) -- (6.7,-0.2)
node[pos=0.15, above right,font=\large] {$\frac{\Delta y}{\Delta x}<0$};
\draw (x-1) node[dot,label=above right:$f(x_0)$](d1){}
-- (x-1|-O) node[dot,label=below:$x_0$]{}
(x-2) node[dot,label=above right:$f(x_0+\Delta x)$](d2){} -- (x-2|-O) node[dot,label=below:$x_0+\Delta x$]{};
\draw[blue, <->] (d1) -- node[left,font=\large] {$\Delta y<0$}
(x-2-|x-1);
\draw[blue, <->] (d2) -- node[below,font=\large] {$\Delta x>0$} (x-2-|x-1);
\end{scope}
\end{tikzpicture}
\end{document}