[Tex/LaTex] Wrap around a logo at bottom right of page

graphicswrapfigure

I have a square logo placed on the bottom right of every page (placed using absolute positioning and tikz) and it's fairly big. I want it so that text flows / wraps around the logo – is it possible to this?

For example, I want to have something like the following where (a is text and l is logo)

+--------------+
| aaaaaaaaaaaa |
| aaaaaaaaaaaa |
| aaaaaaaaaaaa |
| aaaaa +------+
| aaaaa | llll |
| aaaaa | llll |
+------ +------+

Edit, here is an example of what I have with overlapping text and logo:

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{tikz}
\usepackage{lipsum}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]
  \node [shift={(-2 in, 2 in)}] at (current page.south east) {
    \rule{2in}{2in}
  };
\end{tikzpicture}

\lipsum[1-8]

\end{document}

This generates the following document

overlapping logo

You will notice that the block on the bottom right overwrites some of the text and I would like to avoid that by having it wrap around it. The logo is large, so I do not want it taking up the footer space.

Best Answer

You can use \parshape to specify an irregular paragraph shape to which the subsequent paragraph should adhere to. This only holds for the subsequent paragraph, and should be redefined for the following one. This is viable since the image is small enough that so that at most two paragraphs would probably be "affected" by the addition of the logo.

Since \parshape applies to a specific paragraph, and paragraphs depend on the document contents, it would be very difficult to automate this procedure. Remember that you are producing the logo as a tikz overlay, so TeX would have no idea that there's "something" at the time of typesetting. However, on a manual basis, there is no problem in wrapping around the logo.

Here is an MWE:

Wrapping around a logo on page in SE corner

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{tikz}% http://ctan.org/pkg/pgf
\usepackage{lipsum}% http://ctan.org/pkg/lipsum

\begin{document}

\begin{tikzpicture}[remember picture,overlay]
  \node [shift={(-2 in, 2 in)}] at (current page.south east) {
    \rule{2in}{2in}
  };
\end{tikzpicture}

\lipsum[1-6]

% Special paragraph formatting
\parshape=2 % 2 lines will be affected
0pt \linewidth % One regular line
0pt \dimexpr\linewidth-2in-1ex\relax % one (and remaining paragraph) reduced line
\lipsum[7]

% Special paragraph formatting
\parshape=5 % 5 lines will be affected
0pt \dimexpr\linewidth-2in-1ex\relax % Four reduced lines
0pt \dimexpr\linewidth-2in-1ex\relax
0pt \dimexpr\linewidth-2in-1ex\relax
0pt \dimexpr\linewidth-2in-1ex\relax
0pt \linewidth % one (and remaining paragraph) at regular width
\lipsum[8]

\end{document}

\parshape=<n> <i1> <l1> <i2> <l2> ... sets the line indents and line widths for the following <n> lines in a paragraph. If the paragraph continues past <n> lines, it uses the last set <i> <l> pair.

  • For the first paragraph with adjusted formatting, two lines are formatted (\parshape=2): First line has indent 0pt and line width \linewidth while the second and subsequent lines have indent 0pt and line width \linewidth-2in-1ex, which leaves a 1ex gap between the logo boundary and the text.

  • For the second paragraph that requires adjusted formatting, five lines are formatted (\parshape=5): Four lines have indent 0pt and line width \linewidth-2in-1ex, and the last and subsequent lines have indent 0pt and line width \linewidth, restoring the traditional paragraph shape.