# Creating a shaded box with an outline

EDIT

I'm attempting to create a box with a different background color. However, I've tried this and the box looks unpolished. So I would like to add a line that seperates the two background colors. In other words, the point where the special background color begins and the original document background ends should be seperated by a line that is a third color. I'm wondering how I can accomplish this...

ORIGINAL POST (containing more details)

I don't understand floats very well. I've been using the framed package instead, which is nice because I can easily put a frame around something. There is another behavior included in this package that I'd like to combine. It gives the option to create a shaded environment, which is another way of saying that it changes the background color of the object that I'd like to put a frame around. I really like this, but the edge of the shaded area looks unpolished. So what I'd like to do is to create a float that has a special background color, and I want the edges to have a thin line between the special color and the normal white background that I use for the rest of the document.

I'm using these framed "floats" to display mainly text, so I'd like to know how to combine all of these features. In other words, I'd like to see an example that takes a bunch of text, and gives it a special background with a box that is perfectly aligned at the edge of the background (thus giving it a nice frame). I'd like to see how this can be implemented as a float, as well.

One more thing that isn't necessary, but would be good to know, would be a way to implement similar behavior around an align environment. I don't know if this would require special treatment, but I'd really appreciate it if someone could show me how to do this.

-
You are asking many independent questions: The main question is about getting a “nice” framed box (with your requirements). To make this box a “float” you simply need to enclose it in a figure environment; and once you know how to create your boxes, you can probably put anything (such an align) inside. – Juan A. Navarro Jan 11 '11 at 15:01
Sorry. I guess in that case I would really just like to know how to combine the two "boxes" I talk about. – Matt Groff Jan 11 '11 at 15:06
@Matt: look at the package mdframed. you'll get the documentation with running texdoc mdframed – Herbert Jan 11 '11 at 15:53
As a suggestion, you might want to edit the question to be more focused on the main issue, and with a more general scope (e.g. “How to create framed and shaded boxes“). This way you might get more answers and suggestions. – Juan A. Navarro Jan 11 '11 at 18:20
@Jaun: Done.... – Matt Groff Jan 11 '11 at 21:19

The syntax is \myFloat[optArgs left]{text left}[optArgs right]{text right}{caption}{label} the last two can be empty.

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}% only for demo
\usepackage{xcolor,mdframed,caption}
\makeatletter
\def\myFLoat{\@ifnextchar[{\myFloat@i}{\myFloat@i[]}}
\def\myFloat@i[#1]#2{\@ifnextchar[%
{\myFloat@ii[#1]{#2}}%
{\myFloat@ii[#1]{#2}[]}}
\def\myFloat@ii[#1]#2[#3]#4#5#6{\par\medskip%
%  \mdfsetup{innerleftmargin=10pt,innerrightmargin=10pt}%
\noindent\begin{minipage}[t]{0.475\textwidth}\leavevmode
\begin{mdframed}[#1]#2\end{mdframed}
\end{minipage}\hfill
\begin{minipage}[t]{0.475\textwidth}\leavevmode
\begin{mdframed}[#3]#4\end{mdframed}
\end{minipage}
\ifx\relax#5\relax\else\captionof{figure}{#5}\fi%
\ifx\relax#6\relax\else\label{#6}\fi\par}
\makeatother
\begin{document}

\blindtext
\myFLoat[linecolor=blue,linewidth=2pt,backgroundcolor=yellow]{\blindtext}%
[linecolor=red,linewidth=3pt]{\blindtext}%
{my caption for this float}{myLabel}

as seen in my Figure~\ref{myLabel} it works.

\blindtext
\myFLoat[linecolor=blue,linewidth=2pt,backgroundcolor=yellow]{\blindtext}%
[linecolor=red,linewidth=3pt]{\begin{align}y=\int\limits_1^2 f(x)dx\end{align}}%
{my caption for this float}{myLabelB}

\end{document}


-
I'm having trouble getting mdframed to work. TeXnicCenter keeps giving me a warning: File 'md-tikz-0.mdf' not found.. I don't know if this is a problem of the package, since the version seems to be 0.4a, a problem of MikTeX, or a problem of TeXnicCenter... – Matt Groff Jan 11 '11 at 21:00
@Matt: run the update manager of MiKTeX – Herbert Jan 11 '11 at 21:04
@Matt: if MiKTeX didn't provide the latest version file a bug report to MiKTeX. You also can download the latest version from CTAN:mirror.ctan.org/macros/latex/contrib/mdframed.zip. Where it is saved on your harddisk can be found with kpsewhich mdframed.sty. Update after installing the file name data base from within the MiKTeX setup. – Herbert Jan 11 '11 at 22:13
@Herbert: Thanks! I still have an error with with MDframe2.aux, which is a file that is created by either MikTeX or TeXnicCenter. I'm debating on whether I should contact the author or not... I'm not sure how this file works... I see that it says the GUI framework can't be initialized (pdflatex.exe). – Matt Groff Jan 11 '11 at 22:18
@Herbert: I'm still trying to figure this out. I have the version from January 7, 2011, which should be the latest. – Matt Groff Jan 11 '11 at 22:20

mdframed package is a good suggestion. Also, take a look at this example.

-