我需要放大图像,我使用 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}
现在我想像这样将其并排放置(对于两个一般图像)
\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}
我尝试更换\includegraphics
零件tikzpicture
,但效果却不尽如人意
\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}
我该如何解决?
答案1
如果在子图周围添加缺失的花括号,它就会起作用。
\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}