[Tex/LaTex] How to draw a colored framebox without filling the background

boxescolorframed

I like to draw a \fbox{..} which is colored. The xcolor package gives

\fcolorbox{<frame color>}{<background color>}{<text>}

But this forces me to set a background color. I like to have the background not filled at all, but simply the frame drawn in a color. Setting it to the paper color (white normally) would be a workaround but doesn't work for shaded backgrounds.

Is there another macro for this or a possibility to set <background color> to transparent or have it ignored?

PS: I like to do this without using anything as big as TikZ or PSTricks. This is actually for use in a package and shouldn't force users to also load these packages.

Best Answer

Would setting the color before a framebox and resetting it to the normal text color inside and after the framebox work for your application?

\documentclass{article}
\usepackage{xcolor}

\begin{document}
\newcommand{\cfbox}[2]{%
    \colorlet{currentcolor}{.}%
    {\color{#1}%
    \fbox{\color{currentcolor}#2}}%
}

\cfbox{red}{In red box} Normal black text

\color{blue} A paragraph with blue text and \cfbox{orange}{some words} in an orange box. 
\end{document}

colored framebox