# Picture & box overlap

In my code, I have:

\newcommand{\headwarning}[1]%
{\needspace{4\baselineskip}\colorbox{darkboxcolor}{\parbox{\linewidth}{\color{lighttextcolor}\textbf{#1}}}\nopagebreak[0]\vspace{0mm}}%
\newcommand{\warning}[1]%
{\vspace{2px}{\textbf{#1}}\vspace{4px}}


Colors are defined elsewhere. And in the text section:

\begin{wrapfigure}{r}{3cm}
\begin{tabular}{@{}c@{}}
\textcolor{blue}{\rule{3cm}{3cm}} \\% Dummy image replacement
\end{tabular}
\end{wrapfigure}

\warning{Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}


But the headwarning box covers the picture on the right. How can I shorten this box correctly?

As an end result, I'm after something like this:

-
Instead of providing code snippets, it is always best to compose a MWE that illustrates the problem including the \documentclass so that those trying to help don't have to recreate it. –  Peter Grill Oct 31 '11 at 17:29
You can't use wrapfigure with a boxed paragraph. Once it is inside a box (like \colorbox or \parbox) the paragraph shape can't be changed. I you want a warning box with a headline, image and body text then you should do that manually. (I also don't understand your usage of tabular here.) –  Martin Scharrer Oct 31 '11 at 17:34
@MartinScharrer: I think the tabular was a workaround to not having he figure. However, an easier method is to use the [demo] option, as in usepackage[demo]{graphicx} instead of making a dummy tabular to represent the picture. Then you can just use \includegraphics as normal. –  Peter Grill Oct 31 '11 at 17:47
The idea was to have heading and text on the left side and picture on the right side. But the color behind heading is not stopping before the picture but covers it. Can you give me any suggestion how to do this? I want text to flow on the left side and some pictures on the right (text should flow around the picture) but the background of the heading should be on the left of the picture it doesn't matter how long the heading is for instance 15 lines. –  B. T. Oct 31 '11 at 17:51
Something like this: !image –  B. T. Oct 31 '11 at 18:04

You could use the soul package to do the highlighting:

\documentclass{article}
\usepackage{wrapfig}
\usepackage{xcolor}
\usepackage{soul}
\usepackage[demo]{graphicx}

{\noindent\hl{#1}}

\newcommand{\warning}[1]%
{\vspace{2px}\noindent\textbf{#1}\vspace{4px}}

\begin{document}

\begin{wrapfigure}{r}{3cm}
\includegraphics[width=3cm,height=3cm]{dummy}
\end{wrapfigure}

\headwarning{Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}

\warning{Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}
\end{document}

-