# Text wrapping around figure in header

I am facing an issue when creating a custom class.

### The objective

I am writing a custom class as a template for faction sheets for the Dune boardgame. One of the official sheets (and therefore the look I am going for) is as follows: As you can see on the top left, near the image, the text wraps nicely around the faction logo. I want to achieve the same effect.

### My solution

Here you will find my current class that achieves pretty satisfactory results. In this implementation of the class, you can see a few problems though. In lines 12, 14 and 16 you can see the manual setting of horizontal space, so that the text would not overlap with the image. The output of that document is as follows While the result is not bad, it's not as smooth as the original one.

### Where I think the problem lies

In the class file you will find the following

\pagestyle{fancy}
\fancyhf{}

\begin{tikzpicture}[remember picture, overlay]
\filldraw[fill=FT@maincolor, draw=FT@maincolor!80]
([yshift=1.5cm,xshift=1cm]current page text area.north west) rectangle
([yshift=0.4cm]current page text area.north east);
%
\node at ([yshift=-1.65cm]current page.north)
{\color{white}\bfseries\LARGE\MakeUppercase{\textsf{\FT@name}}};
\node at ([xshift=1.5cm]current page text area.north west)
{\includegraphics[width=4cm]{\FT@logo}};
\end{tikzpicture}
}


I am putting the faction logo in the header of the document and I can't seem to find a way to wrap text around it automatically. So my question then is: how can I achieve the text wrapping in every page? Right now I have to add some spacing on each first column of every page and that can get a little annoying and definitely not scalable.

• You could use \parshape together with \afterpage, but only if every page starts with a new paragraph. Paragraphs are usually formatted on the previous page and split at the page boundary. Jan 16 '21 at 17:02
• New pages will start with either a new environment or as a continuation of the previous one (which is basically a description, just reskinned). Only the very first would be a paragraph with no environment around it.
– gjkf
Jan 16 '21 at 17:09
• Also, \parshape and \shapepar only affect one paragraph, so you will have to replace blank lines with \\[\parskip] for the first few lines. Jan 16 '21 at 17:15
• I tried doing just that and the result for the first paragraph is pretty good (I had to do it on the document but I can live with that). For the description environment though, it seems that the parshape command changes the dimensions of the whole environment, not just one item: [look here[(0x0.st/-ir5.png)
– gjkf
Jan 16 '21 at 17:52
• Ok, I added a blank line and a \parshape=1 1cm 9cm just before the next item and it worked! I still don't like that I have to do it manually each time though
– gjkf
Jan 16 '21 at 18:00

The following uses \everypar and \afterpage to apply \parshape to the first paragraph on every page. It may be incompatible with other uses of \everypar. These can generally be fixed on a case-by-case basis.

\documentclass{article}
\usepackage{afterpage}
\usepackage{lipsum}% MWE only

\makeatletter
\newcommand{\AtBeginPage}{\if@firstcolumn
\global\everypar{\parshape=5
2em \dimexpr \columnwidth-2em\relax
1.5em \dimexpr \columnwidth-1.5em\relax
1em \dimexpr \columnwidth-1em\relax
0.5em \dimexpr \columnwidth-0.5em\relax
0pt \columnwidth
\global\everypar{}}\fi
\afterpage{\AtBeginPage}}
\makeatother

\begin{document}
\AtBeginPage
\noindent\LipsumPar{1}

\LipsumPar{2}

\LipsumPar{3}

\LipsumPar{4}

\LipsumPar{5}
\newpage
\noindent\LipsumPar{5}

\LipsumPar{6}
\end{document}

• While this is amazing, there's a slight problem: when a new page happens and the description environment is broken in the 2 pages, the description overlaps the image, not caring about the parshape. Here you can see what I mean: i.imgur.com/0DMrPIo.png
– gjkf
Jan 17 '21 at 11:46
• Actually, it does not seem to work at all. At a new page (whether or not I use \newpage or just add some text). I tried also removing the environment and just using sections like in your example, no luck on the second page. The problem lies with the usage of multicol it seems.
– gjkf
Jan 17 '21 at 14:39
• You can break a paragraph without making it look like a new paragraph {\parfillskip=0pt\parskip=0pt\par}\noindent. Not sure what multicols is doing; I know it actually creates a single column then splits it in half, as opposed to creating each column separately. Jan 17 '21 at 20:59
• Hmm will look into it. The same problem arises with twocolumn as an option to the document class. I also tried removing the description, having all text, but the problem persisted with twocolumns. Will have to look into it I think, I need a way to check if I am in the first or second column (and that works reliably)
– gjkf
Jan 18 '21 at 11:34