我使用以下代码在小页面内的图像周围绘制一个框架。如何全局设置它,以及如何单独控制框架线的粗细和颜色。
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\lineskip=-\fboxrule
\fbox{\begin{minipage}
{\dimexpr \textwidth-2\fboxsep-2\fboxrule}
\centering
\includegraphics[width=1.\textwidth]{x.PNG}
\end{minipage}}
\end{frame}
\end{document}
答案1
您需要以通常的方式设置 的值\fboxrule
。要更改颜色,您可以使用\fcolorbox
。
代码
\documentclass{beamer}
\usepackage{mwe}
\setbeamertemplate{navigation symbols}{}
\setlength{\fboxrule}{5pt}
\def\myfbox#1{%
\lineskip=-\fboxrule
\fcolorbox{cyan}{white}{%
\begin{minipage}
{\dimexpr\textwidth-2\fboxsep-2\fboxrule}
\centering
\includegraphics[width=\textwidth]{#1}
\end{minipage}%
}%
}%
\begin{document}
\begin{frame}{}
\myfbox{example-image-a}
\end{frame}
\begin{frame}{}
\myfbox{example-image-b}
\end{frame}
\begin{frame}{}
\myfbox{example-image-c}
\end{frame}
\begin{frame}{}
\myfbox{example-image}
\end{frame}
\end{document}
输出
答案2
替代方案tcbincludegraphics
(来自tcolorbox
)
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{Default}
\tcbincludegraphics{example-image-a}
\end{frame}
\begin{frame}[fragile,t]
\frametitle{Version 1}
\tcbincludegraphics[sharp corners, colback=white]{example-image-a}
\end{frame}
\begin{frame}[fragile,t]
\frametitle{Version 2}
\tcbincludegraphics[sharp corners, colback=white, colframe=blue, boxrule=2mm,
hbox, graphics options={width=.25\linewidth}, left=2cm, right=2cm]{example-image-a}
\end{frame}
\end{document}