20

Possible Duplicate:
Is there an \arrayrulecolor-like command to change the rule color of \fbox?

I'm using an \fbox to have a border around a minipage.

\fbox{
\begin{minipage}{0.25\textwidth}
my content
\end{minipage}
}

Is there any way to set the border color of the \fbox?

3
  • You can also use the package tcolorbox. Mar 1 '12 at 20:10
  • Note that the line break after the first { will add a space there. You should add a % direct after it to avoid that. The same might be required after \end{minipage}. Mar 1 '12 at 20:18
  • 2
    @lockstep: I see the connection to the linked question, but because it is not a very good phrased question with only minimalistic answers I'm against closing this question as a duplicate. Mar 1 '12 at 20:20
25

The xcolor package provides \fcolorbox{<frame color>}{<background color>}{<text>}. You can also use my adjustbox package with the cfbox=<color> and minipage=<width> keys:

\usepackage{xcolor}
\usepackage{adjustbox}

% ...

\adjustbox{minipage=0.25\textwidth,cfbox=<color>}{<content>}

% or, if the whole thing should be 0.25\textwidth wide, including the border:

\adjustbox{minipage=0.25\textwidth-2\fboxsep-2\fboxrule,cfbox=<color>}{<content>}

You can define your own command using:

\newcommand\myfbox{\adjustbox{<keys>}}
% usage: \myfbox{<content>}
9

I would recommend the mdframed package, which provides many options- you can frame your environment quite simply, or if you want complicated examples you can use tikz, pstricks.

The documentation has many examples, and you can find questions tagged with mdframed here

https://tex.stackexchange.com/questions/tagged/mdframed

enter image description here

\documentclass{article}

\usepackage{lipsum}
\usepackage[framemethod=default]{mdframed}

\newmdenv[linecolor=red,backgroundcolor=yellow]{myframe}

\begin{document}

\begin{myframe}
\lipsum[1]
\end{myframe}

\end{document}
7
\documentclass{article}
\usepackage{xcolor,lipsum}
\begin{document}    
\fcolorbox{red}{yellow}{\parbox{\dimexpr \linewidth-2\fboxsep-2\fboxrule}{%
\lipsum[1]}}

\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.