7

How is it possible to wrap text around a symbol? This is my code so far:

\documentclass{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{fourier}
\usepackage{blindtext}

\newcommand{\mybox}[2][\danger]{%
    \colorbox{lime}{\parbox{\textwidth}{%
        {\Huge#1}{#2}%
    }}%
}
\begin{document}
\mybox{\blindtext}
\end{document}
1

3 Answers 3

8

You can use the lettrine package for this, which is usually used for having a large first letter that spans several lines. It needs a bit of adjustment because of the symbol's large depth:

\documentclass{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{fourier}
\usepackage{blindtext}
\usepackage{lettrine}

\newcommand{\mybox}[2][\danger]{%
    \colorbox{lime}{\parbox{\textwidth}{%
        \lettrine[lraise=.2,findent=1pt,nindent=0pt]{#1}{}{#2} }%
    }%
}
\begin{document}

\mybox{\blindtext}
\end{document}

enter image description here

2
  • The optional argument for the \mybox environment makes no sense if you don't use it. Feb 12, 2011 at 14:52
  • @Thorsten: Thanks for the note. I've edited my answer to incorporate the optional argument in the way the Duwee intended.
    – Jake
    Feb 12, 2011 at 14:57
4

Generally speaking, I think it is difficult to do this in LaTeX. There is a shapepar package, which can dig a hole in the text and put something in the hole. But it's not easy to customize the shape of the hole to fit specific symbol.

An example of predefined circle hole:

\documentclass{article}
\usepackage{shapepar}

\begin{document}

\cutout{r}(-4em,5\baselineskip)\shapepar{\circleshape}
cut cut cut cut cut cut cut cut cut cut cut cut cut cut cut cut
cut cut cut cut cut cut cut cut cut cut cut cut\par
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text

\end{document}

This kind of work is easier in ConTeXt, with help of MetaFun. You may refer:

http://mirror.contextgarden.net/general/manuals/metafun-s.pdf


If you just want a rectangle hole, you can use (old) picinpar, (newer) picins and wrapfig for this.

For more simpler situations, lettrine package is enough. Also there are \hangindent, \hangafter commands to get a paragraph of special shape.

3

You could use the wrapfig package for this:

 Environments "wrapfigure" and "wraptable" place a figure or table
 at the side of the page and wrap text around it.

 \begin{wrapfigure}[12]{r}[34pt]{5cm} <figure> \end{wrapfigure}
                    --  -  ----  ---
 [number of narrow lines] {placement} [overhang] {width of figure}%

...

Environments similar to "wrapfigure" and "wraptable" may be easily added,
or invoked by "\begin{wrapfloat}{float_name}"

You must log in to answer this question.