Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use beside captions placed in a large margin area. Sometimes, the caption text is taller than the figure and this causes too much vertical space around the figure.

I'd like the effective height of the figure to ignore the height of the caption text in the margin. Just some vertical space around the figure as if the caption was not present. Because the caption is over in the margin, it's fine if caption text vertically overlaps the body text.

How can this be done? I'd like a way to do this such a that I do not need to hand tune each instance.

[EDIT 1] Fixed example code that only worked under xetex.

[EDIT 2] Updated sample problem PDF and showed fixed version using TH's cool \smashcaption.

Many Thanks!

Here's a really extreme example of the problem:

\documentclass{book}
%%
% Set page layout geometry
% The asymmetric option keeps the margin notes always on the same side of the page which is the way Tufte does it.
\usepackage[
    letterpaper,
    asymmetric,
    includemp,
    headheight=0.5in, % needs to be big enough for the Intel logo graphic
    left=1.25in,
    width=6.75in,
    marginparsep=0.25in,
    marginparwidth=2in,
    bottom=1in,
    top=1in,
    nofoot,
    includehead]
    {geometry}

\usepackage{lipsum}
\usepackage{floatrow}

\floatsetup[figure]
    {
    floatwidth=\linewidth,
    capposition=beside,
    capbesideposition={right,center},
    capbesideframe=yes,
    capbesidewidth=\marginparwidth,
    capbesidesep=quad,
    floatrowsep=qquad
    }

\begin{document}
\lipsum[1]
\begin{figure}[ht]
  \centering
  \rule{8cm}{1cm}
  \caption{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. Pellentesque habitant morbi
tristique senectus et netus et malesuada fames ac turpis egestas. Mauris.}
\end{figure}
\lipsum[2]
\end{document}

Here's what it looks like:

          problem before

Now with TH's \smashcaption fix:

          Fixed version

share|improve this question
    
Your example doesn't compile for me. –  TH. Mar 25 '11 at 22:58
    
Without more info about your problem, this comment is not useful. –  srking Mar 25 '11 at 23:03
    
When I copy the code into a new document and try to compile it. I get the error ! Package floatrow Error: Undefined float separator 'marginparsep'. –  TH. Mar 25 '11 at 23:18
    
Yes, I see that too now. Works under xetex (my default), but nothing else. Will correct. –  srking Mar 25 '11 at 23:24
    
I removed the excessive whitespace from your images. –  Hendrik Vogt Mar 26 '11 at 22:27
add comment

1 Answer

up vote 5 down vote accepted

Commenting out the line that causes your example to not compile, here's a solution. Define a new macro \smashcaption as follows.

\makeatletter
\newcommand*\smashcaption{
        \def\FR@makecaption##1##2{%
                \vbox to\z@{%
                        \vss
                        \captionfont
                        {\captionlabelfont##1}\caption@lsep##2%
                        \par
                        \vss
                }%
        }%
        \caption
}
\makeatother

Now replace \caption in your code with \smashcaption and you get what I believe you want.

share|improve this answer
    
Works really well! Thanks TH! Your macro will give me something to study as well. –  srking Mar 25 '11 at 23:35
    
@srking: You can also just make that redefinition globally if you want. Then all \captions will have that effect. –  TH. Mar 26 '11 at 0:11
    
My example neglected to mention I was using the caption package. I am trying to recreate the formatting like so but it's still not formatted correctly: % {\captionlabelfont ##1}{\space\textendash\space}{\captiontextfont ##2}% –  srking Mar 26 '11 at 4:31
    
@srking: Does replacing my ##1: ##2 with that not work? I'd expect it to. –  TH. Mar 26 '11 at 8:08
    
@TH - It seems that the caption package doesn't provide a means to extract the effective caption formatting. For example, \captionlabelfont correctly made the font boldface, but not the correct size. I ended up just rebuilding my simple format from scratch. In my case: \small{\textbf{##1}{\space\textendash\space}##2}. It took me two hours to debug line spacing problems in the paragraph due to \small fontsize inadvertently not being in effect at the end of the statement. I think your smash option would be a nice addition to the caption package. Cheers. –  srking Mar 26 '11 at 15:39
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.