2

I need to magnify an image which I managed to do it using TikZ

\begin{tikzpicture}[spy using outlines={circle,black,magnification=5,size=1.5cm, connect spies}]
\node {\includegraphics[height=6.85cm, width=0.48\textwidth, keepaspectratio]{figure}};
\spy on (0.15,0.1) in node [left] at (2,1.25);
\end{tikzpicture}

Now I would like to put it side-by-side like this (for two general images)

\begin{figure}[H] \centering
    \subfloat[Subcaption 1]
    \includegraphics[height=6.85cm, width=0.48\textwidth, keepaspectratio]{figure}
    \hspace{2mm}
    \subfloat[Subcaption2]
    \includegraphics[height=6.85cm, width=0.48\textwidth, keepaspectratio]{figure}
    \caption{Caption}
\end{figure}

I tried to replace \includegraphics with the tikzpicture part but is not working like this

\begin{figure}[H] \centering
    \subfloat[Subcaption1]
\begin{tikzpicture}[spy using outlines={circle,black,magnification=5,size=1.5cm, connect spies}]
\node {\includegraphics[height=6.85cm, width=0.48\textwidth, keepaspectratio]{figure1}};
\spy on (0.15,0.1) in node [left] at (2,1.25);
\end{tikzpicture}
    \hspace{2mm}
    \subfloat[Subcaption2]
    \includegraphics[height=6.85cm, width=0.48\textwidth, keepaspectratio]{figure2}
    \caption{Caption}
\end{figure}

How can I solve it?

2

It does work if you add the missing curly brackets around the subfigures.

\documentclass{article}
\usepackage{subfig}
\usepackage{tikz}
\usetikzlibrary{spy}
\begin{document}
\begin{figure}[h] \centering
\subfloat[Subcaption1]{
\begin{tikzpicture}[spy using outlines={circle,black,magnification=5,size=1.5cm, connect spies}]
\node {\includegraphics[height=6.85cm, width=0.46\textwidth,
keepaspectratio]{example-image-duck}};
\spy on (0.15,0.1) in node [left] at (2,1.25);
\end{tikzpicture}}
\hspace{2mm}
\subfloat[Subcaption2]{
\includegraphics[height=6.85cm, width=0.46\textwidth, keepaspectratio]{example-image}
}
\caption{Caption}
\end{figure}
\end{document}

enter image description here

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.