Text FormattingColored boxes spanning over pages of defined width ...

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
konrad
Posts: 5
Joined: Tue Jan 12, 2010 11:24 am

Colored boxes spanning over pages of defined width ...

Post by konrad »

Hi,

I want to put text into a colored box that spans over many pages. I tried the framed-Package and its shaded environment. But with this environment, I can not set the width of the box.
Does anybody know, how I can use a colored box over many pages, where I can set the width of the box as well as the padding of the text in the box?

Thanks
Konrad

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Colored boxes spanning over pages of defined width ...

Post by gmedina »

Hi,

you can define your own environments using the features provided by the framed package. Take a look at the following simple example:

Code: Select all

\documentclass{report}
\usepackage{lipsum}% just to generate some text
\usepackage{framed}
\usepackage{xcolor}

\renewenvironment{shaded}{%
  \def\FrameCommand{\fboxsep=\FrameSep \colorbox{blue!60}}%
  \MakeFramed {\FrameRestore}}%
 {\endMakeFramed}

\newenvironment{shadedi}{%
  \def\FrameCommand{\fboxsep=\FrameSep \colorbox{blue!60}}%
  \MakeFramed {\advance\hsize+2\width\FrameRestore}}%
 {\endMakeFramed}

\newenvironment{shadedii}{%
  \def\FrameCommand{\fboxsep=\FrameSep \colorbox{blue!60}}%
  \MakeFramed {\advance\hsize-7\width\everypar{\parshape 1 1.8cm 4cm}\FrameRestore}}%
 {\endMakeFramed}

\begin{document}

\begin{shaded}
  \lipsum[1-10]
\end{shaded}
\lipsum[1]
\begin{shadedi}
  \lipsum[1-10]
\end{shadedi}
\lipsum[1]
\begin{shadedii}
  \lipsum[1-10]
\end{shadedii}
\lipsum[1]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
konrad
Posts: 5
Joined: Tue Jan 12, 2010 11:24 am

Re: Colored boxes spanning over pages of defined width ...

Post by konrad »

Thank you very much ... that's it!
Post Reply