GeneralProblem with minipage + wrapfig

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
nanomir
Posts: 7
Joined: Fri Jan 09, 2009 6:39 pm

Problem with minipage + wrapfig

Post by nanomir »

Hi all,

I am trying to make a sort of a "template" for a captioned image on right, and a little bit of text on the left - I use minipage and wrapfig for this. In this case, the text is not much, however, Latex uses by default the text as reference for positioning - which overlaps images; here is the problem illustrated:

Image

And here is the code used:

Code: Select all

\documentclass[letterpaper]{article}

\usepackage{wrapfig} 
\usepackage{graphicx} 
\usepackage{color} 

\begin{document}

\section[Image 1]{Image 1}

\begin{minipage}{\textwidth}

\begin{wrapfigure}{r}{0.3\textwidth}
\vspace{-20pt}
\centering
\includegraphics[width=1.4189in,height=1.2709in]{picture.jpg}
\vspace{-20pt}
\caption{\textit{Picture one. }}
\label{fig:pic1}
\vspace{-10pt}
\end{wrapfigure}

\textsf{Some text:}  Some text.. (\textcolor{red}{some text})

\end{minipage} \newline
\vfill



\section[Image 2]{Image 2}

\begin{minipage}{\textwidth}

\begin{wrapfigure}{r}{0.3\textwidth}
\vspace{-20pt}
\centering
\includegraphics[width=1.4189in,height=1.2709in]{picture.jpg}
\vspace{-20pt}
\caption{\textit{Picture two. }}
\label{fig:pic1}
\vspace{-10pt}
\end{wrapfigure}

\textsf{Some text:}  Some text.. (\textcolor{red}{some text})

\end{minipage}
\vfill

\end{document}
When \vfill is before \end{minipage}, it's as if it has no effect, and thus I still get the situation on the figure left (overlap). If \vfill is sfter \end{minipage}, I get too much space - I want the section heading to be right below the image caption (or the text end, if it was larger - whichever comes first).

Any ideas how to solve this?

Thanks....
Attachments
minipagewrapfigproblem.jpg
minipagewrapfigproblem.jpg (16.34 KiB) Viewed 4821 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Re: Problem with minipage + wrapfig

Post by phi »

You could use a KOMA-Script class or the sidecap package, both have built-in facilities for sideways captions.
Post Reply