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. Jan 11, 2011 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, 2011 at 15:06
  • 1
    @Matt: look at the package mdframed. you'll get the documentation with running texdoc mdframed
    – user2478
    Jan 11, 2011 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. Jan 11, 2011 at 18:20
  • @Jaun: Done....
    – Matt Groff
    Jan 11, 2011 at 21:19

2 Answers 2


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

\usepackage{blindtext}% only for demo
%  \mdfsetup{innerleftmargin=10pt,innerrightmargin=10pt}%

        {my caption for this float}{myLabel}

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

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


alt text

alt text

  • 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, 2011 at 21:00
  • @Matt: run the update manager of MiKTeX
    – user2478
    Jan 11, 2011 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.
    – user2478
    Jan 11, 2011 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, 2011 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, 2011 at 22:20

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


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .