# Add a specific space on top and bottom of a fbox

I have a figure which rounded by fbox, I am wondering how can I add a space only at the top and bottom of the image since \setlength{\fboxsep}{6pt}add space around the whole figure.

Thank you

Two methods for adding a top and bottom padding inside a \fbox:

• If the figure is an image included by \includegraphics then option trim can be used to add the padding.

• A general method puts the contents of \fbox in a box and increases its height and depth.

Example file:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\setlength{\fboxsep}{0pt}
\fbox{%
% Negative trim values add space.
% The amount is scaled with the image (scaled here by option "width").
\includegraphics[width=60pt, trim=0 -40pt 0 -40pt]{example-image.pdf}%
}

\fbox{%
% box register 0 is a local scratch register
\sbox{0}{\includegraphics[width=60pt]{example-image.pdf}}%
% The height and depth of the box are increased.
\ht0=\dimexpr\ht0 + 10pt\relax
\dp0=\dimexpr\dp0 + 10pt\relax
\usebox{0}%
}
\end{document}


Frame separation cannot be set in each side. Round the image also with a \parbox, then you can add any vertical (or horizontal) space around the image.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\fbox{\parbox{5cm}{\bigskip%
\includegraphics[width=\linewidth]{example-image}\bigskip}}
\end{document}


A bit overkill for a simple frame, but alternatively, you can use longfbox:

\documentclass{article}
\usepackage{longfbox}

Or tcolorbox, or mdframed ...