5

I am trying to reproduce this image. This is what I have so far but I don't know where to start in putting the arrows on my graph. All suggestions welcome.

\documentclass{article}
\usepackage{tikz}
\begin{tikzpicture}[scale=.6,cap=round]
\tikzset{axes/.style={}}
  % The graphic
 \draw[style=help lines,step=1cm, dotted] (-7,-7) grid (7.0,7.0);
 \begin{scope}[style=axes]
 \draw[->] (-7.5,0) -- (7.5,0) node[above] {$x$};
 \draw[->] (0,-7.5)-- (0,7.5) node[left] {$y$};
     \foreach \x/\xtext in {-6/-12, -5/-10, -4/-8, -3/-6, -2/-4,    1/2, 2/4, 3/6, 4/8, 5/10, 6/12}
 \draw[xshift=\x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
      {\scriptsize $\xtext$};
     \foreach \y/\ytext in {-6/-12, -5/-10, -4/-8, -3/-6, -2/-4,    2/4, 3/6, 4/8, 5/10, 6/12}
 \draw[yshift=\y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
     {\scriptsize $\ytext$};
 \filldraw[black] (2,5.5) circle (3pt) node[fill=white,left=3pt] {$$};
 \draw[domain=-4.1:2.9,smooth,variable=\x,black,<->,thick] plot ({\x},{.5*(3+4*\x)});
 \node at (-5.5,-4) [fill=white] {$f(x)=2x+3$};
 \draw[dashed] (2.5,0)--(2.5,6.5)--(0,6.5);
 \draw[dashed] (1.5,0)--(1.5,4.5)--(0,4.5);
 \end{scope}
 \end{tikzpicture}

\end{document}

This outputs:

enter image description here

BUT I am trying to reproduce:

enter image description here

5

You might either use shapes.arrows or just draw thick lines with arrow heads. The following example illustrates both options.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows,matrix,positioning}
\begin{document}
\begin{tikzpicture}[scale=.6,cap=round]
\tikzset{axes/.style={}}
  % The graphic
 \draw[style=help lines,step=1cm, dotted] (-7,-7) grid (7.0,7.0);
 \begin{scope}[style=axes]
 \draw[->] (-7.5,0) -- (7.5,0) node[above] {$x$};
 \draw[->] (0,-7.5)-- (0,7.5) node[left] {$y$};
 \foreach \x/\xtext in {-6/-12, -5/-10, -4/-8, -3/-6, -2/-4,    1/2, 2/4, 3/6, 4/8, 5/10, 6/12}
 {\ifnum\x=2
  \else
     \draw[xshift=\x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white,font=\scriptsize]
      {$\xtext$};
  \fi     
 }    
 \foreach \y/\ytext in {-6/-12, -5/-10, -4/-8, -3/-6, -2/-4,    2/4, 3/6, 4/8, 5/10, 6/12}
     \draw[yshift=\y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white,font=\scriptsize]
     {$\ytext$};
 \filldraw[black] (2,5.5) circle (3pt) node[fill=white,left=3pt] {};
 \draw[domain=-4.1:2.9,smooth,variable=\x,black,<->,thick] plot ({\x},{.5*(3+4*\x)});
 \node at (-5.5,-4) [fill=white] {$f(x)=2x+3$};
 \draw[dashed] (2.5,0)--(2.5,6.5)--(0,6.5);
 \draw[dashed] (1.5,0)--(1.5,4.5)--(0,4.5);
 \end{scope}
 \draw[cyan,thick] (0,5.5) -- (-1,5.5) node[left,font=\scriptsize](11){11};
 \node[single arrow,cyan,minimum height=1.5cm,rotate=-90,fill,transform
 shape,anchor=east,opacity=0.3] at(11.north){};
 \node[single arrow,cyan,minimum height=1.5cm,rotate=90,fill,transform
 shape,anchor=east,opacity=0.3] at(11.south){};
 \draw[red,thick] (2,0) -- (2,-9.8);
 \node[text=red,fill=white,font=\scriptsize] (4) at (2,-1.5) {4};
 \node[single arrow,red,minimum height=1.5cm,rotate=0,fill,transform
 shape,anchor=east,opacity=0.3] at(4.west){};
 \node[single arrow,red,minimum height=1.5cm,rotate=180,fill,transform
 shape,anchor=east,opacity=0.3] at(4.east){};
 %
 \matrix[matrix of math nodes,nodes={text width=11mm,align=right,inner sep=3pt,
 text height=1.5ex,text depth=.25ex,draw=gray!40,ultra thin},draw,inner
 sep=0pt] (mat)
 at (1.1,-11){
 |[fill=green!40!gray,align=left]| x & 3.9& 3.99 & 3.999 & |[text=red!90,align=center]| 4 & 4.001 & 4.01 & 4.1\\
 |[fill=green!40!gray,align=left]| f(x) & 10.8 & 10.98 & 10.998 & |[text=cyan!90,align=center]| 11 & 
 11.002& 11.02& 11.2 \\
 };
 \draw[thin,gray!40] (mat.west) -- (mat.east);
 \node[left=2mm of mat-1-1,text width=2cm,font=\itshape]{Limit};
 \node[left=2mm of mat-2-1,text width=2cm,font=\itshape]{Numerically};
 \draw[line width=1mm,-latex,red!90] ([xshift=3mm,yshift=8mm]mat-1-2.north west)
 node[xshift=-2mm,anchor=south west,align=left,font=\scriptsize]{These input values\\
  approach 4 from the left.}
 --([xshift=2mm,yshift=8mm]mat-1-5.north west);
 \draw[line width=1mm,latex-,red!90] ([xshift=-2mm,yshift=8mm]mat-1-5.north east)
 node[xshift=2mm,anchor=south west,align=left,font=\scriptsize]{These input values\\
  approach 4 from the right.}
 --  ([xshift=-1mm,yshift=8mm]mat-1-8.north east);
 \draw[line width=1mm,-latex,cyan!90] ([xshift=3mm,yshift=-8mm]mat-2-2.south west)
 node[xshift=-2mm,anchor=north west,align=left,font=\scriptsize]{These output values\\
  approach 11 from the left.}
 --([xshift=2mm,yshift=-8mm]mat-2-5.south west);
 \draw[line width=1mm,latex-,cyan!90] ([xshift=-2mm,yshift=-8mm]mat-2-5.south east)
 node[xshift=2mm,anchor=north west,align=left,font=\scriptsize]{These output values\\
  approach 11 from the right.}
 --  ([xshift=-1mm,yshift=-8mm]mat-2-8.south east);
\end{tikzpicture}
\end{document}

enter image description here

BTW, you forgot \begin{document} and \end{document} in your example and it would really help if you provide the table and everything that needs to be typed in the future.

  • Marmot, I can not thank you enough!!! I will have to spend quite a bit of time studying this program. Very helpful. I could have created a tabular table but you used a matrix which I never would have thought of. I will note your request in the future. – MathScholar Nov 7 '18 at 1:03
  • I will upvote it but I don't know how. I am looking for the field to upvote and I can not find. Please advise I will do it! – MathScholar Nov 7 '18 at 1:46
  • 1
    I think I found it! – MathScholar Nov 7 '18 at 1:50
  • Hi Marmot, I've tried using the \matrix code above in another Example but when I compile and it is exactly as you wrote I get the Error message "Single ampersand used with wrong catcode” . Can you advise why? – MathScholar Nov 9 '18 at 21:48
  • @MathScholar Well, I don't know what you're doing, but two things that may help: (1) add ampersand replacement=\& to the options and replace all & by \& in the matrix. In beamer, you may have to add fragile to the frame options, Need to run now! – marmot Nov 9 '18 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.