Discussion:
force a figure to be in a certain section when using wrapfigure
Jason Lewis
2004-01-14 06:33:46 UTC
Hi,

I am using Template Toolkit an LaTeX to write a product catalogue for my
business. The LaTeX for my document is all generated from a database using
Template Toolkit.

For an idea of how I want to lay out my catalogue, see the text at the end of
this message.

The problem I am having is getting all the text to line up exactly how I want
it. I have tried many different ways of laying out including minipages,
floatflt, wrapfigure and probably a few others. None of them was able to give
me perfect results but wrapfigure seems to come closest.

The problem i get is when I have a short section, wrapfigure puts my image
about 1-2 sections later, rather than in the short section, making the short
section longer. Thats probably what it was designed to do, but its not the
behaviour I am after.

Is there a way to force wrapfigure to put the image between 2 points of a
document? ie, "this image must be placed between point A and point B" or
something?

Or, is there a better way of flowing text around the image that I should be
aware of? I am willing to compromise and, say, assign a column on the left
hand side of my document that would only have floating images in it, and put
captions on them, but I couldnt work out how to do that either.

Here is a sample of my code currently:
\subsection{Norfolk Punch - Sauces and Relishes}
\begin{wrapfigure}{r}{0pt}
\end{wrapfigure}

Cu?ious Relish
Has a gentle heat and bite of mild chilli and the smoothness of liquorice
root. Add to rice, soups and stir frys.

St Georges Dragon's Breath Sauce

A warm and spicy sauce containing chilli, ginger, tomato, garlic, cloves, and
dragons blood (spice imported from China which gives the red tinge to this sauce)
\begin{longtable}[l]{p{7cm}|l|r|l|r@{.}l|l|l|l|l|l|l|l|l|l|l|l|l|l} \hline
St Geo Dragon Breath Sauce 150ml & & 24 & 9011302 & 3 & 60 & & & & & & &
& & & & & \\ \hline
Cur?ous Relish 250ml & & 24 & 9011303 & 3 & 50 & & & & & & &
& & & & & \\ \hline
\end{longtable}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this section includes images by the minipage method
% this one tries to put all of the section in the minipage
\subsection{Condiments}

.
.
.
etc....

And here is the layout I am trying to acheive.....

1.3.4 Product Listing
ducts and aThis is a list of oducts and a descrip -------------------------
a descriptilist of my product a description of th | |
ption of thmy products and a iption of them. This | |
m. This is and a description em. This is a lis to | |
s is a listdescription of theis is a list of my p | an included image |
of my produof them. This is a of my products and | |
ducts and aThis is a list of oducts and a descrip | |
a descriptilist of my product a description of th | |
on of them.products and a desion of them. This is ------------------------
his is a lia description of tThis is a list of my products and a description
of my produof them. This is a of my products and a description of them. This
and a descis a list of my prs and a description of them.

this is a longtable
Product1 3.50 | | | | | | | | | | | |
Product2 3.50 | | | | | | | | | | | |
Product3 3.50 | | | | | | | | | | | |
Product4 3.50 | | | | | | | | | | | |
Product5 3.50 | | | | | | | | | | | |
Product6 3.50 | | | | | | | | | | | |
Product7 3.50 | | | | | | | | | | | |
Product8 3.50 | | | | | | | | | | | |
Product9 3.50 | | | | | | | | | | | |

and when its a short bit of text.....

1.3.4 Product Listing
ducts and aThis is a list of mydts and a descrip -------------------------
a descriptilist of my products aescription of th | |
ption of thmy products and a depon of them. This | |
m. This is and a description ofmThis is a lis to | |
| an included image |
this is a longtable | |
Product1 3.50 | | | | | | | | | | | | | |
Product2 3.50 | | | | | | | | | | | | | |
Product3 3.50 | | | | | | | | | | | | ------------------------
Product4 3.50 | | | | | | | | | | | |
Product5 3.50 | | | | | | | | | | | |
Product6 3.50 | | | | | | | | | | | |
Product7 3.50 | | | | | | | | | | | |
Product8 3.50 | | | | | | | | | | | |
Product9 3.50 | | | | | | | | | | | |

But sometimes, i only have 1 or 2 lines in my longtable, so i would like the
following behaviour in that situation

1.3.4 Product Listing
ducts and aThis is a list of my cts and a descrip -------------------------
a descriptilist of my products adescription of th | |
ption of thmy products and a desion of them. This | |
m. This is and a description of This is a lis to | |
| an included image |
this is a longtable | |
Product1 3.50 | | | | | | | | | | | | | |
| |
| |
| |
| |
| |
------------------------

1.3.5 Next Section starts below Image
This is the next section. This is the next section.
This is the next section. This is the next section.
This is the next section. This is the next section.
This is the next section.

Any suggestions would be greatly appreciated.

Thanks,

Jason

PS. I am looking for a workable solution - I'm happy to do things differently
if it will make it easier. Im just really stuck on this.

Jason
Ulrike Fischer
2004-01-14 09:10:16 UTC
Post by Jason Lewis
Hi,
I am using Template Toolkit an LaTeX to write a product catalogue for
my business. The LaTeX for my document is all generated from a
database using Template Toolkit.
For an idea of how I want to lay out my catalogue, see the text at the
end of this message.
The problem I am having is getting all the text to line up exactly how
I want it. I have tried many different ways of laying out including
minipages, floatflt, wrapfigure and probably a few others. None of
them was able to give me perfect results but wrapfigure seems to come
closest.
The problem i get is when I have a short section, wrapfigure puts my
image about 1-2 sections later, rather than in the short section,
making the short section longer. Thats probably what it was designed
to do, but its not the behaviour I am after.
Is there a way to force wrapfigure to put the image between 2 points
of a document? ie, "this image must be placed between point A and
point B" or something?
Or, is there a better way of flowing text around the image that I
should be aware of? I am willing to compromise and, say, assign a
column on the left hand side of my document that would only have
floating images in it, and put captions on them, but I couldnt work
out how to do that either.
You could perhaps make a large margin and use \marginpar.
You shouldn't sent snippets of code. Make a complete (but minimal)
document. Replace graphics by e.g. \rule{3cm}{3cm}. So that everybody
can test your code and see the problem.
Post by Jason Lewis
\subsection{Norfolk Punch - Sauces and Relishes}
\begin{wrapfigure}{r}{0pt}
\includegraphics[width=3cm,height=3cm,keepaspectratio=true]{/tmp/LaTeXC
d_Sauces_20030514_no_background.jpg}
\end{wrapfigure}
Cu?ious Relish
Has a gentle heat and bite of mild chilli and the smoothness of
liquorice root. Add to rice, soups and stir frys.
Do you agree, that this is not easy to read? Why didn't you at least
replace the path with a shorter one?

If I remember it right, wrapfigure place the figure in the current
paragraph. So don't put a blank line between the figure and the text
following.

I don't delete the rest of your post so that you can see that is really
not possible to see what you want.
Post by Jason Lewis
St Georges Dragon's Breath Sauce
A warm and spicy sauce containing chilli, ginger, tomato, garlic,
cloves, and dragons blood (spice imported from China which gives the
red tinge to this sauce)
\hline St Geo Dragon Breath Sauce 150ml & & 24 & 9011302 & 3 & 60
& & & & & & & & & & & & \\ \hline
Cur?ous Relish 250ml & & 24 & 9011303 & 3 & 50 & & &
& & & & & & & & & \\ \hline
\end{longtable}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this section includes images by the minipage method
% this one tries to put all of the section in the minipage
\subsection{Condiments}
.
.
.
etc....
And here is the layout I am trying to acheive.....
1.3.4 Product Listing
ducts and aThis is a list of oducts and a descrip
------------------------- a descriptilist of my product a description
of th | | ption of thmy products and a iption of
them. This | | m. This is and a description em.
This is a lis to | | s is a listdescription of
theis is a list of my p | an included image | of my produof them.
This is a of my products and | | ducts and
aThis is a list of oducts and a descrip | | a
descriptilist of my product a description of th |
| on of them.products and a desion of them. This is
------------------------ his is a lia description of tThis is a list
of my products and a description of my produof them. This is a of my
products and a description of them. This
and a descis a list of my prs and a description of them.
this is a longtable
Product1 3.50 | | | | | | | | | | | |
Product2 3.50 | | | | | | | | | | | |
Product3 3.50 | | | | | | | | | | | |
Product4 3.50 | | | | | | | | | | | |
Product5 3.50 | | | | | | | | | | | |
Product6 3.50 | | | | | | | | | | | |
Product7 3.50 | | | | | | | | | | | |
Product8 3.50 | | | | | | | | | | | |
Product9 3.50 | | | | | | | | | | | |
and when its a short bit of text.....
1.3.4 Product Listing
ducts and aThis is a list of mydts and a descrip
------------------------- a descriptilist of my products aescription
of th | | ption of thmy products and a depon of
them. This | | m. This is and a description
ofmThis is a lis to | |
| an included
image |
this is a longtable |
| Product1 3.50 | | | | | | | | | | | | |
| Product2 3.50 | | | | | | | | | | | | |
| Product3 3.50 | | | | | | | | | | | |
------------------------ Product4 3.50 | | | | | | | | | | | |
Product5 3.50 | | | | | | | | | | | |
Product6 3.50 | | | | | | | | | | | |
Product7 3.50 | | | | | | | | | | | |
Product8 3.50 | | | | | | | | | | | |
Product9 3.50 | | | | | | | | | | | |
But sometimes, i only have 1 or 2 lines in my longtable, so i would
like the following behaviour in that situation
1.3.4 Product Listing
ducts and aThis is a list of my cts and a descrip
------------------------- a descriptilist of my products adescription
of th | | ption of thmy products and a desion of
them. This | | m. This is and a description of
This is a lis to | |
| an included
image |
this is a longtable |
| Product1 3.50 | | | | | | | | | | | | |
|
|
| |
|
|
| |
|
|
|
------------------------
1.3.5 Next Section starts below Image
This is the next section. This is the next section.
This is the next section. This is the next section.
This is the next section. This is the next section.
This is the next section.
--
Ulrike Fischer
e-mail: zusätzlich meinen Vornamen vor dem @ einfügen.
e-mail: add my first name between the news and the @.
Jason Lewis
2004-01-14 11:41:24 UTC
Ulrike,

You are correct, it is unreadable. I'll try and come up with a way of
making it more readable and repost.

Jason
Post by Ulrike Fischer
Post by Jason Lewis
Hi,
I am using Template Toolkit an LaTeX to write a product catalogue for
my business. The LaTeX for my document is all generated from a
database using Template Toolkit.
For an idea of how I want to lay out my catalogue, see the text at the
end of this message.
The problem I am having is getting all the text to line up exactly how
I want it. I have tried many different ways of laying out including
minipages, floatflt, wrapfigure and probably a few others. None of
them was able to give me perfect results but wrapfigure seems to come
closest.
The problem i get is when I have a short section, wrapfigure puts my
image about 1-2 sections later, rather than in the short section,
making the short section longer. Thats probably what it was designed
to do, but its not the behaviour I am after.
Is there a way to force wrapfigure to put the image between 2 points
of a document? ie, "this image must be placed between point A and
point B" or something?
Or, is there a better way of flowing text around the image that I
should be aware of? I am willing to compromise and, say, assign a
column on the left hand side of my document that would only have
floating images in it, and put captions on them, but I couldnt work
out how to do that either.
You could perhaps make a large margin and use \marginpar.
You shouldn't sent snippets of code. Make a complete (but minimal)
document. Replace graphics by e.g. \rule{3cm}{3cm}. So that everybody
can test your code and see the problem.
Post by Jason Lewis
\subsection{Norfolk Punch - Sauces and Relishes}
\begin{wrapfigure}{r}{0pt}
\includegraphics[width=3cm,height=3cm,keepaspectratio=true]{/tmp/LaTeXC
d_Sauces_20030514_no_background.jpg}
\end{wrapfigure}
Cu?ious Relish
Has a gentle heat and bite of mild chilli and the smoothness of
liquorice root. Add to rice, soups and stir frys.
Do you agree, that this is not easy to read? Why didn't you at least
replace the path with a shorter one?
If I remember it right, wrapfigure place the figure in the current
paragraph. So don't put a blank line between the figure and the text
following.
I don't delete the rest of your post so that you can see that is really
not possible to see what you want.
Post by Jason Lewis
St Georges Dragon's Breath Sauce
A warm and spicy sauce containing chilli, ginger, tomato, garlic,
cloves, and dragons blood (spice imported from China which gives the
red tinge to this sauce)
\hline St Geo Dragon Breath Sauce 150ml & & 24 & 9011302 & 3 & 60
& & & & & & & & & & & & \\ \hline
Cur?ous Relish 250ml & & 24 & 9011303 & 3 & 50 & & &
& & & & & & & & & \\ \hline
\end{longtable}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this section includes images by the minipage method
% this one tries to put all of the section in the minipage
\subsection{Condiments}
.
.
.
etc....
And here is the layout I am trying to acheive.....
1.3.4 Product Listing
ducts and aThis is a list of oducts and a descrip
------------------------- a descriptilist of my product a description
of th | | ption of thmy products and a iption of
them. This | | m. This is and a description em.
This is a lis to | | s is a listdescription of
theis is a list of my p | an included image | of my produof them.
This is a of my products and | | ducts and
aThis is a list of oducts and a descrip | | a
descriptilist of my product a description of th |
| on of them.products and a desion of them. This is
------------------------ his is a lia description of tThis is a list
of my products and a description of my produof them. This is a of my
products and a description of them. This
and a descis a list of my prs and a description of them.
this is a longtable
Product1 3.50 | | | | | | | | | | | |
Product2 3.50 | | | | | | | | | | | |
Product3 3.50 | | | | | | | | | | | |
Product4 3.50 | | | | | | | | | | | |
Product5 3.50 | | | | | | | | | | | |
Product6 3.50 | | | | | | | | | | | |
Product7 3.50 | | | | | | | | | | | |
Product8 3.50 | | | | | | | | | | | |
Product9 3.50 | | | | | | | | | | | |
and when its a short bit of text.....
1.3.4 Product Listing
ducts and aThis is a list of mydts and a descrip
------------------------- a descriptilist of my products aescription
of th | | ption of thmy products and a depon of
them. This | | m. This is and a description
ofmThis is a lis to | |
| an included
image |
this is a longtable |
| Product1 3.50 | | | | | | | | | | | | |
| Product2 3.50 | | | | | | | | | | | | |
| Product3 3.50 | | | | | | | | | | | |
------------------------ Product4 3.50 | | | | | | | | | | | |
Product5 3.50 | | | | | | | | | | | |
Product6 3.50 | | | | | | | | | | | |
Product7 3.50 | | | | | | | | | | | |
Product8 3.50 | | | | | | | | | | | |
Product9 3.50 | | | | | | | | | | | |
But sometimes, i only have 1 or 2 lines in my longtable, so i would
like the following behaviour in that situation
1.3.4 Product Listing
ducts and aThis is a list of my cts and a descrip
------------------------- a descriptilist of my products adescription
of th | | ption of thmy products and a desion of
them. This | | m. This is and a description of
This is a lis to | |
| an included
image |
this is a longtable |
| Product1 3.50 | | | | | | | | | | | | |
|
|
| |
|
|
| |
|
|
|
------------------------
1.3.5 Next Section starts below Image
This is the next section. This is the next section.
This is the next section. This is the next section.
This is the next section. This is the next section.
This is the next section.
Donald Arseneau
2004-01-14 11:18:28 UTC
Post by Jason Lewis
The problem i get is when I have a short section, wrapfigure puts my image
about 1-2 sections later, rather than in the short section,
Utterly misleading description. Wrapfigure puts the figure where you
told it to.
Post by Jason Lewis
1.3.5 Next Section starts below Image
So you want to skip down to below the figure and terminate wrapping
text. I have a macro for that,

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

Everyone: Please tell me if the fill function should be added to \WFclear,
or if a new command (\wrapfill) should be added.

Donald Arseneau ***@triumf.ca
2004-01-18 11:46:43 UTC
Post by Donald Arseneau
Post by Jason Lewis
1.3.5 Next Section starts below Image
So you want to skip down to below the figure and terminate wrapping
text. I have a macro for that,
\makeatletter
\def\wrapfill{
[snip]
Post by Donald Arseneau
}
\makeatother
Everyone: Please tell me if the fill function should be added to \WFclear,
or if a new command (\wrapfill) should be added.
Thanks Donald for the macro. It is exaclty what I was looking for! In my

Best regards

Kristof
Donald Arseneau
2004-01-21 02:52:48 UTC
Post by Donald Arseneau
Everyone: Please tell me if the fill function should be added to \WFclear,
or if a new command (\wrapfill) should be added.
Thanks Donald for the macro. It is exaclty what I was looking for! In my
Something else I was thinking about would be an incompatible change:
The wraping could synchronize the line-count between paragraphs
(and only between paragraphs) by looking at the \pagetotal parameter.
Then, a big tabular could be counted as 10 lines for the wrapping.
I could even make it so it only synchronizes if there was no
explicit line-count parameter.

Donald Arseneau ***@triumf.ca
i***@gmail.com
2018-07-19 18:06:07 UTC
Post by Donald Arseneau
Post by Jason Lewis
The problem i get is when I have a short section, wrapfigure puts my image
about 1-2 sections later, rather than in the short section,
Utterly misleading description. Wrapfigure puts the figure where you
told it to.
Post by Jason Lewis
1.3.5 Next Section starts below Image
So you want to skip down to below the figure and terminate wrapping
text. I have a macro for that,
\makeatletter
\def\wrapfill{\par
\nobreak
\fi
\allowbreak
\fi
}
\makeatother
Everyone: Please tell me if the fill function should be added to \WFclear,
or if a new command (\wrapfill) should be added.
Everyone: Please tell me if the fill function should be added to \WFclear,
or if a new command (\wrapfill) should be added.
Donald Arseneau
IMHO, both of them deserve being added and documented :) . Without them, user should place wrapfigures with a great care, as demonstrated here: https://tex.stackexchange.com/a/442369/143086 .
Paul Thompson
2004-01-14 15:23:47 UTC
Have you looked into building minipages with the figure and text? That
way, you bind them together.
Post by Jason Lewis
Hi,
I am using Template Toolkit an LaTeX to write a product catalogue for my
business. The LaTeX for my document is all generated from a database
using Template Toolkit.
For an idea of how I want to lay out my catalogue, see the text at the
end of this message.
The problem I am having is getting all the text to line up exactly how I
want it. I have tried many different ways of laying out including
minipages, floatflt, wrapfigure and probably a few others. None of them
was able to give me perfect results but wrapfigure seems to come closest.
The problem i get is when I have a short section, wrapfigure puts my
image about 1-2 sections later, rather than in the short section, making
the short section longer. Thats probably what it was designed to do, but
its not the behaviour I am after.
Is there a way to force wrapfigure to put the image between 2 points of
a document? ie, "this image must be placed between point A and point B"
or something?
Or, is there a better way of flowing text around the image that I should
be aware of? I am willing to compromise and, say, assign a column on the
left hand side of my document that would only have floating images in
it, and put captions on them, but I couldnt work out how to do that either.
\subsection{Norfolk Punch - Sauces and Relishes}
\begin{wrapfigure}{r}{0pt}
\end{wrapfigure}
Cu?ious Relish
Has a gentle heat and bite of mild chilli and the smoothness of
liquorice root. Add to rice, soups and stir frys.
St Georges Dragon's Breath Sauce
A warm and spicy sauce containing chilli, ginger, tomato, garlic,
cloves, and dragons blood (spice imported from China which gives the red
tinge to this sauce)
St Geo Dragon Breath Sauce 150ml & & 24 & 9011302 & 3 & 60 & & & &
& & & & & & & & \\ \hline
Cur?ous Relish 250ml & & 24 & 9011303 & 3 & 50 & & & &
& & & & & & & & \\ \hline
\end{longtable}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this section includes images by the minipage method
% this one tries to put all of the section in the minipage
\subsection{Condiments}
.
.
.
etc....
And here is the layout I am trying to acheive.....
1.3.4 Product Listing
ducts and aThis is a list of oducts and a descrip -------------------------
a descriptilist of my product a description of th | |
ption of thmy products and a iption of them. This | |
m. This is and a description em. This is a lis to | |
s is a listdescription of theis is a list of my p | an included image |
of my produof them. This is a of my products and | |
ducts and aThis is a list of oducts and a descrip | |
a descriptilist of my product a description of th | |
on of them.products and a desion of them. This is ------------------------
his is a lia description of tThis is a list of my products and a description
of my produof them. This is a of my products and a description of them. This
and a descis a list of my prs and a description of them.
this is a longtable
Product1 3.50 | | | | | | | | | | | |
Product2 3.50 | | | | | | | | | | | |
Product3 3.50 | | | | | | | | | | | |
Product4 3.50 | | | | | | | | | | | |
Product5 3.50 | | | | | | | | | | | |
Product6 3.50 | | | | | | | | | | | |
Product7 3.50 | | | | | | | | | | | |
Product8 3.50 | | | | | | | | | | | |
Product9 3.50 | | | | | | | | | | | |
and when its a short bit of text.....
1.3.4 Product Listing
ducts and aThis is a list of mydts and a descrip -------------------------
a descriptilist of my products aescription of th | |
ption of thmy products and a depon of them. This | |
m. This is and a description ofmThis is a lis to | |
| an included image |
this is a longtable | |
Product1 3.50 | | | | | | | | | | | | | |
Product2 3.50 | | | | | | | | | | | | | |
Product3 3.50 | | | | | | | | | | | | ------------------------
Product4 3.50 | | | | | | | | | | | |
Product5 3.50 | | | | | | | | | | | |
Product6 3.50 | | | | | | | | | | | |
Product7 3.50 | | | | | | | | | | | |
Product8 3.50 | | | | | | | | | | | |
Product9 3.50 | | | | | | | | | | | |
But sometimes, i only have 1 or 2 lines in my longtable, so i would like the
following behaviour in that situation
1.3.4 Product Listing
ducts and aThis is a list of my cts and a descrip -------------------------
a descriptilist of my products adescription of th | |
ption of thmy products and a desion of them. This | |
m. This is and a description of This is a lis to | |
| an included image |
this is a longtable | |
Product1 3.50 | | | | | | | | | | | | | |
| |
| |
| |
| |
| |
------------------------
1.3.5 Next Section starts below Image
This is the next section. This is the next section.
This is the next section. This is the next section.
This is the next section. This is the next section.
This is the next section.
Any suggestions would be greatly appreciated.
Thanks,
Jason
PS. I am looking for a workable solution - I'm happy to do things
differently if it will make it easier. Im just really stuck on this.
Jason