Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

force a figure to be in a certain section when using wrapfigure (again)

1,394 views
Skip to first unread message

Jason Lewis

unread,
Jan 15, 2004, 6:43:13 PM1/15/04
to
Hi,

Further to my last post regarding layout with wrapfigure. I have put together
an example document of the kind of problem I am encountering. There are three
subsections. The first one illustrates what I want, and the second two
illustrate how wrapfig is not acheiving it. This may well be because I am
using wrapfig outside its designed limits.

Anyway, the basic idea is that I want each subsection to have an image in the
right hand side of it. I ALWAYS want the image in that place and if the image
is too tall for the section, i'd like the section have a blank horizontal gap
after it.

I'm open to any suggestions that may help me achieve this.

Thanks... here is my sample latex. Sorry about the wrapping. Not sure how to
counter that. I can email a .gz or something if anyone wants.

Thanks.

Jason
------------------------------ start LaTeX

\documentclass[10pt]{report}
\usepackage{longtable}
\usepackage[a4paper,landscape,margin=1cm,tmargin=0.5cm,bmargin=1.5cm]{geometry}
\usepackage{graphicx}
\usepackage{wrapfig}


\frenchspacing
\begin{document}
\chapter{Food}
\section{Cereals Breakfast}
\subsection{Normal SubSection - This one works nicely}

\begin{wrapfigure}{r}{0pt}
\rule{3cm}{3cm}
\end{wrapfigure}
Byron Bay Macadamia Muesli is handmade and roasted in the hills behind Byron Bay.
Each blend of muesli is organically rich and nutritionally based, bursting
with the
real flavours of certified organic and natural ingredients. Packed in a
resealable,
stand up pouch which is perfect for displaying on the shelf.
RESERVATIVES- WHEAT FREE-NO FLAVOURINGS-GMO FREE-NO ADDED SUGAR-NO ADDED
SALT-HIGH IN FIBRE-HIGH IN MONOUNSATURATES-NO CHOLESTEROL-LOW IN SUGAR
\begin{longtable}[l]{p{7cm}|l|r|l|r@{.}l|l|l|l|l|l|l|l|l|l|l|l|l|l} \hline
BB Natural Bircher Muesli 450g & 80-85\% & 18 & 9261001 & 6 & 98 & &
& & & & & & & & & & \\ \hline
BB Roasted Classic Muesli 450g & 70-75\% & 18 & 9261002 & 6 & 98 & &
& & & & & & & & & & \\ \hline
BB Roast Almond Fig Pear Muesli450g & 70-75\% & 18 & 9261003 & 6 & 98 & &
& & & & & & & & & & \\ \hline
BB Natural Bircher Muesli 2kg & 80-85\% & 5 & 9261101 & 23 & 94 & &
& & & & & & & & & & \\ \hline
BB Roasted Classic Muesli 2kg & 70-75\% & 5 & 9261102 & 23 & 94 & &
& & & & & & & & & & \\ \hline
BB Roast Almond Fig Pear Muesli 2kg & 70-75\% & 5 & 9261103 & 23 & 94 & &
& & & & & & & & & & \\ \hline
\end{longtable}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Short Description SubSection - Id like to force the figure to be
in this section}
\begin{wrapfigure}{r}{0pt}
\rule{3cm}{3cm}
\end{wrapfigure}
Byron Bay Macadamia Muesli is handmade and roasted in the hills behind Byron Bay.
\begin{longtable}[l]{p{7cm}|l|r|l|r@{.}l|l|l|l|l|l|l|l|l|l|l|l|l|l} \hline
BB Natural Bircher Muesli 450g & 80-85\% & 18 & 9261001 & 6 & 98 & &
& & & & & & & & & & \\ \hline
BB Roasted Classic Muesli 450g & 70-75\% & 18 & 9261002 & 6 & 98 & &
& & & & & & & & & & \\ \hline
BB Roast Almond Fig Pear Muesli450g & 70-75\% & 18 & 9261003 & 6 & 98 & &
& & & & & & & & & & \\ \hline
BB Natural Bircher Muesli 2kg & 80-85\% & 5 & 9261101 & 23 & 94 & &
& & & & & & & & & & \\ \hline
BB Roasted Classic Muesli 2kg & 70-75\% & 5 & 9261102 & 23 & 94 & &
& & & & & & & & & & \\ \hline
BB Roast Almond Fig Pear Muesli 2kg & 70-75\% & 5 & 9261103 & 23 & 94 & &
& & & & & & & & & & \\ \hline
\end{longtable}


\subsection{one line of table }

\begin{wrapfigure}{r}{0pt}
\rule{3cm}{3cm}
\end{wrapfigure}
Byron Bay Macadamia Muesli is handmade and roasted in the hills behind Byron Bay.
Each blend of muesli is organically rich and nutritionally based, bursting
with the
real flavours of certified organic and natural ingredients. Packed in a
resealable,
stand up pouch which is perfect for displaying on the shelf.
RESERVATIVES- WHEAT FREE-NO FLAVOURINGS-GMO FREE-NO ADDED SUGAR-NO ADDED
SALT-HIGH IN FIBRE-HIGH IN MONOUNSATURATES-NO CHOLESTEROL-LOW IN SUGAR
\begin{longtable}[l]{p{7cm}|l|r|l|r@{.}l|l|l|l|l|l|l|l|l|l|l|l|l|l} \hline
BB Natural Bircher Muesli 450g & 80-85\% & 18 & 9261001 & 6 & 98 & &
& & & & & & & & & & \\ \hline
\end{longtable}

\end{document}

Donald Arseneau

unread,
Jan 15, 2004, 8:55:06 PM1/15/04
to
Jason Lewis <ja...@NOdicksonSPAM.st> writes:

> Further to my last post regarding layout with wrapfigure. I have put together

> an example document ...

Not using the \wrapfill that I posted yesterday :-(


Donald Arseneau as...@triumf.ca

Jason Lewis

unread,
Jan 15, 2004, 11:05:33 PM1/15/04
to
Hi Donald,

I'll give that a go, sorry. I overlooked it with all the dissapointment of my
first post being utterly unreadable :(

How do I use it by the way?

Jason

Donald Arseneau

unread,
Jan 15, 2004, 11:21:41 PM1/15/04
to
Jason Lewis <ja...@NOdicksonSPAM.st> writes:

> How do I use it by the way?

Put \wrapfill before \section

You could put it into the \section command.


Donald Arseneau as...@triumf.ca

Jason Lewis

unread,
Jan 15, 2004, 11:22:10 PM1/15/04
to
Hi Donald,

I worked out how to use it, and it kind of solves the problem but leaves a
large blank strip under the section. Try it with the code I posted before and
you'll see what I mean.

Thanks,

Jason

Jason Lewis

unread,
Jan 15, 2004, 11:28:53 PM1/15/04
to
Just to clarify, I should put wrapfill before the NEXT \section? to force the
end of that wrapfigure?

Jason

Donald Arseneau

unread,
Jan 16, 2004, 12:12:01 AM1/16/04
to
You want wrapping to stop before the next section

\begin{wrapfigure}
...
\end{wrapfigure}
text

\wrapfill
\section{}

Donald Arseneau as...@triumf.ca

Jason Lewis

unread,
Jan 16, 2004, 2:16:00 AM1/16/04
to
Donnald,

I have experimented a bit with your macro, and it does work very nicely with
large paragraphs of text. but it falls down as soon as there is a 1 line
paragraph followed by a longtable. It sticks too much vertical space at the
end if the wrapfill command or something. I can send you an example to
illustrate if you like.

Any ideas how I could minimize that?

BTW, I didn't realise you wrote wrapfigure. Its great. Thanks.

Jason

Jason Lewis

unread,
Jan 16, 2004, 10:13:20 PM1/16/04
to
Just for completness sake,

Donnald recommended I use this macro to solve my problem:

\makeatletter
\def\wrapfill{\par
\ifx\parshape\WF@fudgeparshape
\nobreak
\ifnum\c@WF@wrappedlines>\@ne
\advance\c@WF@wrappedlines\m@ne
\vskip\c@WF@wrappedlines\baselineskip
\global\c@WF@wrappedlines\z@
\fi
\allowbreak
\WF@finale
\fi
}
\makeatother

Which works pretty well but I found would leave large gaps after the
\wrapfill command when wrapping happened around a longtable.

Mitchell from #latex on irc.freenode.net suggested removing the \vskip
from the macro. That pretty much has solved the problem except for
images close together now run into each other a little.

Jason

Donald Arseneau

unread,
Jan 16, 2004, 11:17:04 PM1/16/04
to
Jason Lewis <ja...@NOdicksonSPAM.st> writes:

> I have experimented a bit with your macro, and it does work very nicely with
> large paragraphs of text. but it falls down as soon as there is a 1 line
> paragraph followed by a longtable. It sticks too much vertical space at the
> end if the wrapfill command or something.

The \wrapfill works fine. It is the calculation of the "number of
wrapped lines" that is wrong: A tabular environment counts as one
line even when it occupies 10 lines of space. The wrapfigure
documentation explains this, and suggests what to do. Try it with
more text after the table instead of \wrapfill -- you will see the
same excess space.

I don't really expect longtable to act sanely in wrapping text!


Donald Arseneau as...@triumf.ca

Donald Arseneau

unread,
Jan 16, 2004, 11:29:41 PM1/16/04
to
Jason Lewis <ja...@NOdicksonSPAM.com> writes:

> \vskip\c@WF@wrappedlines\baselineskip

> Mitchell suggested removing the \vskip from
> the macro. That pretty much has solved the problem except ...

That's nonsense. The \vskip is the entire point of the macro!

You'r generating the document from a database, right? Is there
ever any text below the table, and do you ever want it to take
up the full line width? If not, then don't use wrapfigure! Use
a tabular environment, or even a \leftline, containing a
tabular env in one column, and the figure in another column.

If you really do want wrapping text (rather than side-by-side
columns) then have whatever program generates the document
insert a correction for the number of lines in the table.
Something like
...
\end{lontable}
% That table had 10 lines, so correction is 9
\addtocounter{WF@wrappedlines}{-9}

Donald Arseneau as...@triumf.ca

Jason Lewis

unread,
Jan 17, 2004, 12:18:21 AM1/17/04
to
Donald,


Donald Arseneau wrote:

> You'r generating the document from a database, right? Is there
> ever any text below the table, and do you ever want it to take
> up the full line width? If not, then don't use wrapfigure! Use
> a tabular environment, or even a \leftline, containing a
> tabular env in one column, and the figure in another column.

Yes, I am generating from a database. There is never text below the
table. it would be nice if the text above the table could take up the
whole line when the image is small. but, if thats too hard, I'm happy
for the lines not to ever fill up a whole line.

I have been trying various combinations of tabular, and long table. I
have not tried sticking the whole lot in a tabular yet. I will try that
now. I never thought of that before.


> If you really do want wrapping text (rather than side-by-side
> columns) then have whatever program generates the document
> insert a correction for the number of lines in the table.
> Something like
> ...
> \end{lontable}
> % That table had 10 lines, so correction is 9
> \addtocounter{WF@wrappedlines}{-9}
>
> Donald Arseneau as...@triumf.ca

I'll try that too. I think though that your correct, and wrapfigure is
not what I'm after.

Thanks,

Jason

0 new messages