### Who is online

In total there are 21 users online :: 1 registered, 0 hidden and 20 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Bing [Bot] and 20 guests

## Background color of an environment

Add tags LaTeX specific issues not fitting into one of the other forums of this category.

### Background color of an environment

Hi,

Till now, I figured out how to change color in minipage, but it isn't really what I need. It's OK for small blocks of text, but if the text is larger than a page or two, it's a problem since no text break across the pages can't be done.

To put simple: Is there a way to change background color of an environment? E.g. I have \quote environment that I want to have light grey background. How can this be achieved?

meho_r

Posts: 823
Joined: Tue Aug 7th, 2007

### Re: Background color of an environment

You can use the framed package. Here you have a simple example:
Code: Select all  •  Open in writeLaTeX
\documentclass{article}\usepackage{framed}\usepackage{lipsum}\usepackage[dvipsnames]{color}\definecolor{shadecolor}{named}{Melon}\begin{document}A very long description list:\begin{shaded}\begin{description}  \item[First item] \lipsum[1-3]  \item[Second item] \lipsum[4-6]  \item[Third item] \lipsum[9-12]\end{description}\end{shaded}\end{document}

I copy here the head of framed.sty. To my knowledge, except that, there is no avalaible guide on the macros defined in the package:

Code: Select all  •  Open in writeLaTeX
% framed.sty   v 0.8a   21-Jul-2003% Copyright (C) 1992-2003 by Donald Arseneau% These macros may be freely transmitted, reproduced, or modified% provided that this notice is left intact.% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Create framed or shaded regions that can break across pages using % \begin{framed} ... \end{framed}    -- ordinary frame box (box at margin)% \begin{shaded} ... \end{shaded}    -- shaded background (into margin)%    ... leftbar ...                 -- line on left side% \begin{MakeFramed}{settings} ... \end{MakeFramed}%                        -- generic frame (for new environments)%% The "framed" environment puts the text into "\fbox" with the% settings "\fboxrule=\FrameRule" and "\fboxsep=\FrameSep".% You can change these lengths (using "\setlength") and you% can even change the definition of "\FrameCommand" to use% much fancier boxes.%% In fact, the "shaded" environment just redefines "\FrameCommand"% to use "\colorbox{shadecolor}" (and you have to define the% color "shadecolor": \newcolor{shadecolor}...).%% A page break is allowed, and even encouraged, before the framed% environment.  If you want to attach some text (a box title) to the% frame, then the text should be inserted by \FrameCommand%% The contents of the framed regions are restricted: % Floats, footnotes, marginpars and head-line entries will be lost.% (Some of these may be handled in a later version.)% This package will not work with the page breaking of multicol.sty,% or other systems that perform column-balancing.%% The MakeFramed environment does the work.  Its "settings" argument% should contain any adjustments to the text width (applied to \hsize,% and using the "\width" of the frame itself) as well as a restore' % command -- \@parboxrestore or \FrameRestore or something similar.% % Expert commands:% \MakeFramed, \endMakeFramed: the "MakeFramed" environment% \FrameCommand: command to draw the frame around its argument% \FrameRestore: restore some text settings, but fewer than \@parboxrestore% \FrameRule: length register; \fboxrule for default "framed".% \FrameSep: length register; \fboxsep for default "framed".% \FrameHeightAdjust: macro; height of frame above baseline at top of page% % This is still a pre-production' version because I can think of many% features/improvements that should be made.  Nevertheless, starting % with version 0.5 it should be bug-free.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Juanjo

Posts: 656
Joined: Sat Jan 27th, 2007

### Re: Background color of an environment

Thanks a lot, Juanjo.

I tested it with \usepackage[svgnames]{xcolor} instead of \usepackage[dvipsnames]{color} and it's working fine. This will make many things easier. Although framed is pretty limited (e.g. footnotes are lost) it can be put in good use.

meho_r

Posts: 823
Joined: Tue Aug 7th, 2007