I am newbie in Tikz. I would like to place a png or pdf image on another pdf figure using Tikz overlay.Unfortunately i don't have any Tikz code for both the figures.
I have looked at this answer using How to put a PDF figure on top of another one using Tex Commands
, Drawing Image on Tikz and the closest example Image inside another image.
My question is to overlay images at correct locations keeping the aspect ratios of two figures using Tikz ?.
I have used overpic
package and Tikz
here in MWE(not working correctly now)
Here is the minimal working example. The caption for Tikz is not placed properly. any idea why ?
For a quick preview of output at writelatex
\documentclass[12pt]{article}
\usepackage{mwe,tikz}
\usepackage[percent]{overpic}
\pagestyle{empty}
\begin{document}
\begin{figure}
\centering
\begin{overpic}[scale=0.75]{example-image-a}
\put(3,3){\includegraphics[scale=0.21]{example-image-b}}
\end{overpic}
\caption{Using Overpic}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[overlay]
\node at (1,1) {\includegraphics[scale=1]{example-image-a}};
\node at (1.5,1) {\includegraphics[scale=0.25]{example-image-b}};
\end{tikzpicture}
\caption{Using Tikz Overlay}
\end{figure}
\end{document}
Result:
overlay
is not required in this case. You can put "things on top of other things" simply drawing them in the appropriate order. Theoverlay
keyword is used to mean that the resulting tikzpicture has to be overlayed by the surrounding text or other pictures. More formally, it causes the resulting picture to have zero size. Simply removeoverlay
and it would work.at
are refered to the node'sanchor
which is its center by default. You can setanchor=south west
to specify the coordinates of the lower left corner, for example.overlay
removed,node[ anchor=north east]
applied. How to set the co-ordinates for image-b ?