我在 latex 中插入了一个图形。但我想将图形的背景设为蓝色。我该如何实现?
\begin{figure} [t]%[htbp]%[f]
\centering
\includegraphics[width= 0.65\linewidth]{./figs/BFSall.pdf}
\caption{\color{blue}(a) BFSa-kNN; (b) BFSb-kNN.}
\label{implementationBFSKNN}
\end{figure}
答案1
mdframed
如果 pdf 的背景是透明的,则该包可以添加彩色背景
\documentclass{article}
\usepackage{xcolor,mdframed}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
\begin{mdframed}[backgroundcolor=blue!50,linecolor=blue!50]
\includegraphics[width=\linewidth]{example-image-a4-landscape.pdf}
\caption{text}
\end{mdframed}
\end{figure}
\begin{figure}[htbp]
\begin{mdframed}[backgroundcolor=blue!50,linecolor=blue!50]
\includegraphics[width=\linewidth]{example-image-a4-landscape.pdf}
\end{mdframed}
\caption{text}
\end{figure}
\end{document}