# How to change the default border color of fbox? [duplicate]

I have a lot of figures inside an fbox. Unfortunately the default black is too strong for my advisor and I need to change the default border color to something more soft.

I've done my research and so far all other answers suggest do solve the problem by not using fbox and switching to other packages. That's something I'd like to avoid, unless absolutely necessary.

Surely there is an option for something so basic in the fbox package itself?

## marked as duplicate by Zarko, Phelype Oleinik, Stefan Pinnow, Sebastiano, CarLaTeXAug 19 at 6:35

• Welcome to TeX.SX! What do you mean by "fbox package"? – TeXnician Aug 18 at 12:19
• fbox is not a package but a simple command. You could redefine it, but this would affect all uses of fbox. – Ulrike Fischer Aug 18 at 12:20
• @UlrikeFischer How would one do so? – user8272359 Aug 18 at 12:51
• @BambOo I specifically linked to that post already and commented that it is not what I want. – user8272359 Aug 18 at 12:52
• It is not beacause some things that you saw there are not what you want that every piece of information from this post isn't relevant for you or anyone else. If you look deeper into details, the linked post has been deemed a duplicate of a previous one where a solution using only the color package was proposed as \newcommand{\myfbox}[2]{\textcolor{#1}{\fbox{\normalcolor#2}}}. By the way we cannot say what packages are allowed or not if you do not give us a list – BambOo Aug 18 at 13:01

You can try this. It will also set the background to white, normally this should be not a problem.

\documentclass{article}

\usepackage{xcolor}

\renewcommand\fbox{\fcolorbox{red}{white}}
\begin{document}

\fbox{text}

\end{document}


• To me, this is a good answer, so +1, but looking at the OP's comments, he/she probably won't see it that way. – BambOo Aug 18 at 13:05
• This is exactly what I want: a way to set the "default border color of fbox". I understand that maybe my terminology was wrong due to being a latex novice, but this user seemed to be able to see through that. I'm sure the ever flowing visitors from Google will agree with me that it is a relevant problem that has not been answered as desired by most before, and will be happy to see this answer here. – user8272359 Aug 18 at 15:51

Without setting the background color, one can save the current text color and apply it when the text of the \fbox is typeset, changing color for typesetting the rules.

\documentclass{article}
\usepackage{xcolor}
\usepackage{etoolbox}

\makeatletter
\let\cfbox\fbox
\let\c@frameb@x\@frameb@x
\pretocmd{\cfbox}
{\leavevmode\begingroup\colorlet{currentcolor}{.}\color{red}}
{}{}
\patchcmd\cfbox{\@frameb@x}{\c@frameb@x}{}{}
\patchcmd{\c@frameb@x}
{\box\@tempboxa}
{\color{currentcolor}\box\@tempboxa}
{}{}
\apptocmd{\c@frameb@x}{\endgroup}{}{}
\makeatother

\begin{document}

text \cfbox{text} text

\fcolorbox{green}{blue}{text \cfbox{text} text}

\end{document}


I'd prefer a different command to redefining \fbox. If you instead want to use \fbox, just remove the \let\cfbox\fbox line and change \cfbox into \fbox in the remaining places.