# help with my kludges — manipulating whitespace in minipages

I'm using captionof to kludge some sidecap-like figures. sidecap wouldn't let me use my other kludge to get the horizontal rules. I like the first example figure but I don't like how the whitespace surrounds the caption in the second figure. There are lots of locations in the minipage environment to manipulate the vspace. Any tips where would be a consistent (ideally global) way to get the captions positioned correctly?

\documentclass[11pt]{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{sidecap}
\usepackage{wrapfig}
\usepackage{capt-of}
\usepackage{geometry}

\begin{document}
\lipsum[1]
\begin{figure}[htb]
\begin{minipage}{\textwidth}
\noindent\rule{\textwidth}{0.5pt}
\begin{minipage}{.45\linewidth}
\includegraphics[width=\linewidth]{test.pdf}
\end{minipage}\hfill
\begin{minipage}{.5\linewidth}
\captionof{figure}{ test }
\label{fig:test}
\end{minipage}\hfill
\noindent\rule{\textwidth}{0.5pt}
\end{minipage}
\hfill
\end{figure}

\lipsum[1]
\begin{figure}[htb]
\begin{minipage}{\textwidth}
\noindent\rule{\textwidth}{0.5pt}
\begin{minipage}{.45\linewidth}
\includegraphics[width=\linewidth]{test.pdf}
\end{minipage}\hfill
\begin{minipage}{.5\linewidth}
\captionof{figure}{ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pel- lentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum. }
\label{fig:test}
\end{minipage}\hfill
\noindent\rule{\textwidth}{0.5pt}
\end{minipage}
\hfill
\end{figure}

\end{document}

-
I'm really unclear about what you want. Do you want the text in the second example to wrap around the graphic? You mention excessive white space; it seems that it's the first figure that has a lot of white space. Maybe if you could explain why you're putting so much text into a caption, it might make it a bit more clear what sort of effect you're looking for. – A.Ellett Dec 6 '12 at 1:37
Sorry; I know this was a little unclear. No I don't want the text to wrap around, I want the rules to be evenly spaced around caption when it's larger than the figure. As for why I'm putting so much text into a caption, I guess that's another suboptimal thing i'm doing, but that's the constraint I'm interested in working around. – Ryan Dec 6 '12 at 1:54

I think I now see your issue. I've had this spacing problem with minipages and the following line being too close. I usual get around this by adding a spurious paragraph at the end of the minipage

See:

\documentclass[11pt]{article}

\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{sidecap}
\usepackage{capt-of}
\usepackage{geometry}

\begin{document}

\lipsum[1]

\begin{figure}[htb]
\begin{minipage}{\textwidth}
\noindent\rule{\textwidth}{0.5pt}
\begin{minipage}{.45\linewidth}
\includegraphics[width=\linewidth]{test.pdf}
\end{minipage}\hfill
\begin{minipage}{.5\linewidth}
\captionof{figure}{ test }  \label{fig:test:01}
\end{minipage}\hfill
\noindent\rule{\textwidth}{0.5pt}
\end{minipage}
\hfill
\end{figure}

\lipsum[1]

\begin{figure}[htb]
\begin{minipage}{\textwidth}
\noindent\rule{\textwidth}{0.5pt}
\begin{minipage}{.45\linewidth}
\includegraphics[width=\linewidth]{test.pdf}
\end{minipage}\hfill
\begin{minipage}{.5\linewidth}
\captionof{figure}{\protect\lipsum[1]}
\par~
\label{fig:test:02}
\end{minipage}\hfill
\noindent\rule{\textwidth}{0.5pt}
\end{minipage}
\hfill
\end{figure}
\end{document}


Alternatively, instead of adding \par~ within the minipage, you could add \\[\baselineskip] after the \hfill following the ending of this minipage.

-
Yeah you got it. Thanks for also showing me how to use \protect in the caption to make \lipsum work. – Ryan Dec 6 '12 at 2:19