floats - Want figure height to ignore side caption height - TeX

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

1 Answer

  1. Lawrence- Reply

    2019-11-14

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>