I’m using both \fbox and \boxed but for different uses. When I use \fbox, I need it to have \fboxsep set to -0.5pt, but when I used \boxed I want a \fboxsep of 2pt.
Is there a way to do that?
EDIT: As I was asked for my usage, I defined this in my preamble
\setlength\fboxrule{0.5pt}
\setlength\fboxsep{-0.5pt}
\newcommand{\schema}[1]{\fbox{\includegraphics[width=\linewidth]{#1}}}
This is in order to include schemes drawn on a white background in a colored background area (typically one from tcolorbox) and have them neatly separated by a thin black margin.
OTOH, I used \boxed around all types of mathematical formulas.


\myboxxed as {\setlength\fboxsep{2pt}\boxed{#1}}– David Carlisle Apr 18 '21 at 18:31Overfull \hboxinstead, because I use\fboxaround figures that are\linewidthwide. See my above edit. – Archange Apr 18 '21 at 20:14\noindent\fbox{\gincludegraphics[width=\dimexpr\linewidth-2\fboxsep-2\fboxrule]{...}}??? – David Carlisle Apr 18 '21 at 20:50Your solution is mostly fine, excepted I don’t want/need
\fboxsepthere because this would now be0ptanyway (I need absolutely no space between the figure and the rule). But thanks for this, I’ll adjust my code with it. :)So my original question is still valid, just replace
– Archange Apr 18 '21 at 21:07-0.5ptwith0ptand that’s it. ;)\fboxsepto 0pt is fine but setting it negative does not do anything useful. – David Carlisle Apr 18 '21 at 21:09