\fbox 沒有填充

\fbox 沒有填充

嗨,我想\fbox{}figure.因為圖形分配了白色部分,所以我想為其添加邊框以獲得更好的視圖。但我認識到這\fbox{}會在圖形中添加我不喜歡/想要的填充。我想要圖形“結束”的邊框(或+1px)。

為了說明目的,這是我的程式碼:

\documentclass{report}
\usepackage{xcolor}
\newcommand\crule[3][black]{\textcolor{#1}{\rule{#2}{#3}}}
\begin{document}

  \crule[yellow]{2cm}{1cm} 

  \fbox{\crule[yellow]{2cm}{1cm}}

\end{document}

給了我這個:

顯然,在我的正確程式碼中有一些東西。就像這個\fbox{\includegraphics[width=0.28\textwidth] {img/file.ext}}黃色盒子一樣。

有什麼想法如何去除框架內的填充嗎?

答案1

邊界由\fboxsep長度決定:

\documentclass{report}
\usepackage{xcolor}
\newcommand\crule[3][black]{\textcolor{#1}{\rule{#2}{#3}}}
\begin{document}

\crule[yellow]{2cm}{1cm}

\setlength{\fboxsep}{0pt}\fbox{\crule[yellow]{2cm}{1cm}}

\end{document}

在此輸入影像描述

相關內容