# Inserting image in an image

I form the following slide by taking the image file from a pdf file [Page 13, Example 1, JS]. I dont want the white parts to appear. Is it ppossible to patch those parts by using the background from some other parts of the image? For instance, as in the following one.

It would be very great to learn how to place $1$ as text after then.

Another way of doing this would be parsing the original image and then joining appropriate parts.

Here is my MWE.

\documentclass[10pt]{beamer}

\usepackage{amsthm}

\usetheme{Warsaw}
\usecolortheme{seahorse}

\begin{document}

\begin{frame}{}{}

\begin{example}

\begin{figure}[htb]
\centering
\includegraphics[page=13,clip,trim=112mm 194mm 59mm 45mm]{stewart-ccac.pdf}
\caption{}
\label{s2ss1exm1fig1}
\end{figure}

\end{example}

\end{frame}

\end{document}

• – Ignasi Sep 19 '17 at 11:40

1. If you want to annotate a specific part of your image, you can put an \includegraphics inside a TikZ node and then draw over it.
In TikZ, you can use nodes to place almost anything (in particular, text) in the position you want. The following code adds some dummy texts to your plot:

\documentclass[]{beamer}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.9\textwidth]{96D5S.png}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[draw] at (0.72,0.5) {some text};
\node[draw] at (0.4,0.91) {some text};
\end{scope}
\end{tikzpicture}
\end{document}


which yields the following image:

Inside the scope, (0,0) is at the lower left of the picture and (1,1) is at the upper right. The only side-effect of this method is whenever you choose to scale the image differently, you have to correct the coordinates for your annotations.

1. If you want to remove the white area around the numbers that you specified in your image, I think it is more logical to use a photo editor to do so. Otherwise, I suggest you creating the plot in TikZ from scratch. To do so, you should define the behavior of your function. In the following code, I demonstrate the plot of y=cos(x) using TikZ. You can simply change your equation for your case.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}

\begin{figure}[h]
\centering
\begin{tikzpicture}
\begin{axis}%
[grid=both,
minor tick num=4,
grid style={line width=.1pt, draw=gray!10},
major grid style={line width=.2pt,draw=gray!50},
axis lines=middle,
enlargelimits={abs=0.2},
axis background/.style={fill=green!5}
]
\node[draw] at (1.5,-.2) {0.5};
\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}


This code creates the following image:

For your beamer document, you can just keep the figure block.

My solution is the following. However, I dont know why I have to use \vspace{-1pt} and \hspace{-1pt}.

\documentclass[10pt]{beamer}

\usepackage{amsthm}

\usetheme{Warsaw}
\usecolortheme{seahorse}

\begin{document}

\begin{frame}{}{}

\begin{example}[4 Pieces]

\begin{figure}[htb]
\centering
\includegraphics[page=13,clip,trim=321pt 553pt 171pt 130pt]{stewart-ccac.pdf}
\end{figure}

\end{example}

\end{frame}

%%

\begin{frame}{}{}

\begin{example}[X Pieces]

\begin{figure}[htb]
\centering
\includegraphics[page=13,clip,trim=321pt 627.5pt 171pt 131pt]{stewart-ccac.pdf}\vspace{-1pt}\\
\includegraphics[page=13,clip,trim=321pt 603.3pt 280.3pt 167.5pt]{stewart-ccac.pdf}\hspace{-1pt}\includegraphics[page=13,clip,trim=321pt 603.3pt 280.3pt 167.5pt]{stewart-ccac.pdf}\hspace{-1pt}\includegraphics[page=13,clip,trim=345pt 603.3pt 171pt 167.5pt]{stewart-ccac.pdf}\vspace{-1pt}\\
\includegraphics[page=13,clip,trim=321pt 591.2pt 261pt 191.65pt]{stewart-ccac.pdf}\hspace{-1pt}\includegraphics[page=13,clip,trim=376.4pt 591.2pt 225.2pt 191.65pt]{stewart-ccac.pdf}\hspace{-1pt}\includegraphics[page=13,clip,trim=364pt 591.2pt 171pt 191.65pt]{stewart-ccac.pdf}\vspace{-1pt}\\
\includegraphics[page=13,clip,trim=321pt 553pt 171pt 203.8pt]{stewart-ccac.pdf}
\end{figure}

\end{example}

\end{frame}

\end{document}