Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Scenario

I want to create a warning box (or pitfall box) that satisfies the following creteria:

  1. It can be broken across pages.
  2. It can contain images, displayed equations, begin{minipage}, \begin{multicols} and \lstinputlisting.
  3. It occupies the whole width of the page.
  4. It is enclosed by a red frame.
  5. It looks like the following figure but the background color should be yellowish.

Bird's View

alt text

Zoomed-in View

alt text

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted
\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{pifont,mdframed}

\newenvironment{warning}
  {\par\begin{mdframed}[linewidth=2pt,linecolor=red]%
    \begin{list}{}{\leftmargin=1cm
                   \labelwidth=\leftmargin}\item[\Large\ding{43}]}
  {\end{list}\end{mdframed}\par}

\begin{document}
\blindtext
\begin{warning}
\blindtext
\end{warning}
\blindtext[2]
\begin{warning}
\blindtext[2]
\end{warning}

\end{document}
share|improve this answer
    
thank for introducing mdframed.sty. I will figure out the other settings to make adjustments. –  xport Jan 11 '11 at 8:38
add comment

Shortcoming

  1. The figure has not been vertically centered.
  2. The lack of red frame.

Screenshot

alt text

Minimal Code

\documentclass[dvipsnames,cmyk]{article}
\usepackage[a4paper,margin=2cm]{geometry}
\usepackage{lipsum,graphicx,xcolor,framed}

\renewenvironment{leftbar}[1][\hsize]%
{%
        \def\FrameCommand%
        {%
             \includegraphics[width=1cm]{pitfall}%           
             \fboxsep=\FrameSep\colorbox{cyan!5}%
        }%
        \MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}%
}%
{\endMakeFramed}


\def\dummy{bla bla bla bla bla bla bla bla bla bla bla bla bla bla.}
\begin{document}
\lipsum[1]

\begin{leftbar}[0.5\linewidth]
\noindent\dummy
\[
\int_a^b f(x)\,\textrm{d}x=F(b)-F(a)
\]
\dummy
\end{leftbar}

\lipsum[1]
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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