我正在尝试将一个图形放入带有标题的阴影框中,我想要以下结果:
我尝试了这些代码,但没有得到结果,有人能帮助我吗?
哪些代码可以生成该图表?
\shadowbox{
\begin{figure}[ht]
\centering
\includegraphics[width=0.3\textwidth]{frog.jpg}
\caption{Phantom figure}
\end{figure}}
\begin{framed}
\begin{center}
\includegraphics[width=0.3\textwidth]{frog.jpg}
\captionof{figure}{This is foo.}
\label{fig:foo}
\end{center}
\end{framed}
答案1
浮点数不能嵌套在盒子中。看看以下解决方案是否是您想要的:
\documentclass[11]{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{fancybox}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{center}
\setlength{\fboxsep}{12pt}
\shadowbox{\parbox{0.5\textwidth}{
\includegraphics[width=\linewidth]{frog.jpg}
\captionof{figure}{Phantom figure}
}}
\end{center}
\lipsum[2]
\end{document}
或浮点型:
\begin{figure}[ht]
\centering
\setlength{\fboxsep}{12pt}
\shadowbox{\parbox{0.5\textwidth}{
\includegraphics[width=\linewidth]{frog.jpg}
\caption{Phantom figure}
}}
\end{figure}