I've searched hundereds forums of the same question, but without any working solution.
I'd like to insert images to my document to the right side of the page and my text shall wrap them from the left.
After many hours I've built below piece of code, but it still doesn't work properly although most issues are solved now:
\begin{wrapfigure}{r}{.3/textwidth}
\centering
\vspace{-11pt} % Kill unwanted space above
\includegraphics[height=4cm]{name.jpg}
\caption{Some description}
\end{wrapfigure}
\paragraph{}\vspace*{-\parskip}
Some text which should wrap the image.
Unwanted behaviour
width of the image area is based on page width, but it's unacceptable
- I need to set image area width based on image width, not page width
- Reason: images are imported to .tex file using external script and image width is variable - I don't know what is their width. I need only to specify their height and width must be calculated. It works for image itself, but not for the wrapfigure area.
wrapfigure doesn't work at all if an image (or its caption) overflows the page break
- if I use {r} settings for wrapfigure, image is displayed under the text out of page and dummy space is generated at the top of next page
- if I use {R} settings which is recommended in lots of forums, output after first overflow is absolutely nonsense - although there
is no overflow below text area as described for {r}, starting from
the first occurence of intersection image and page break all further images are displayed at nonsense positions at below pages - not only vertically, but also horizontally - in some cases the image is
centered, in other cases it's aligned to left side - required behaviour is page break before both image and begin of wrapping text, I don't want to split image and above mentioned "Some
text which should wrap the image." in any way (for example starting
text on previous page and then display image on next page is
unwanted. Text and image must start at the same line, of course empty space of approximately height of image at previous page is expected).
First essential questions:
- is wrapfigure the correct method how to display images wrapped by text?
- if any of above requirements can't be fulfilled (I need essentially both - width detection and proper page breaks), what should I use instead of wrapfigure?
If wrapfigure can fulfill all above requrements, how to solve wrapfigure width detection based on included image width and non-working page breaks?