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'm using Want figure height to ignore side caption height to place a caption into the outer margin. Unfortunately, i can get it only to work with left pages. On right pages i can't muster bringing the float into the outer margin.

Working with left pages (caption in outer margin): Margincaption at the outer margin

Not working with right pages (caption in binding margin): Margincaption in binding margin

PS: Is it possible to get a proper top, bottom alignment with this \smashcaption hack? It is always a bit off.

CODE:

\documentclass[twoside]{book}
\usepackage[
    letterpaper,
    includemp,
    headheight=0.5in, 
    left=1.25in,
    width=6.75in,
    marginparsep=0.25in,
    marginparwidth=2in,
    bottom=1in,
    top=1in]
    {geometry}

\usepackage{lipsum}
\usepackage{blindtext}
\usepackage{floatrow}

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


%\floatsetup[table]{}

\begin{document}

\blindtext

\thisfloatsetup{%
floatwidth=\linewidth,
capposition=beside,
capbesideposition={bottom,outside},
capbesideframe=yes,
capbesidewidth=\marginparwidth,
capbesidesep=quad,
floatrowsep=qquad}
\begin{figure}[h]
\makebox[\textwidth][l]{
\rule{4.5in}{0.5in}
}
\smashcaption{Nulla malesuada porttitor diam. Donec felis erat, congue non, volut- pat at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit. Proin fer- mentum massa ac quam. Sed diam turpis, molestie vitae, placerat a, mo- lestie nec, leo.}
\label{fig}
\end{figure}

\blindtext[4]

\thisfloatsetup{%
floatwidth=\linewidth,
capposition=beside,
capbesideposition={bottom,outside},
facing=no,
capbesideframe=yes,
capbesidewidth=\marginparwidth,
capbesidesep=quad,
floatrowsep=qquad}
\begin{figure}[h]
\makebox[\textwidth][r]{
\rule{4.5in}{0.5in}
}
\smashcaption{Nulla malesuada porttitor diam. Donec felis erat, congue non, volut- pat at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit. Proin fer- mentum massa ac quam. Sed diam turpis, molestie vitae, placerat a, mo- lestie nec, leo.}
\label{fig}
\end{figure}

\blindtext[2]
\end{document}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Here is an example of this working in a two sided layout:

Sample output

\documentclass[twoside]{book}
\usepackage[
    letterpaper,
    includemp,
    headheight=0.5in, 
    left=1.25in,
    width=6.75in,
    marginparsep=0.25in,
    marginparwidth=2in,
    bottom=1in,
    top=1in]
    {geometry}

\usepackage{lipsum}
\usepackage{blindtext}
\usepackage{floatrow}

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

\floatsetup[figure]{%
heightadjust=nocaption,
margins=hangoutside,
floatwidth=\linewidth,
capposition=beside,
capbesideposition={bottom,outside},
capbesideframe=yes,
facing=yes,
capbesidewidth=\marginparwidth,
capbesidesep=quad,
floatrowsep=qquad}

\begin{document}

\blindtext

\begin{figure}[h]
\makebox[\textwidth][l]{
\rule{4.5in}{0.5in}
}
\smashcaption{Nulla malesuada porttitor diam. Donec felis erat, congue non,
volutpat at, tincidunt tristique, libero. Vivamus viverra fermentum
felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper
elit. Proin fermentum massa ac quam. Sed diam turpis, molestie
vitae, placerat a, molestie nec, leo.}
\label{fig}
\end{figure}

\blindtext[4]

\begin{figure}[h]
\makebox[\textwidth][l]{
\rule{4.5in}{0.5in}
}
\smashcaption{Nulla malesuada porttitor diam. Donec felis erat, congue
non, volutpat at, tincidunt tristique, libero. Vivamus viverra
fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing
semper elit. Proin fermentum massa ac quam. Sed diam turpis,
molestie vitae, placerat a, molestie nec, leo.} 
\label{fig}
\end{figure}

\blindtext[2]
\end{document}

The changes I have made are as follows:

  • In \smashcaption: added an extra comment character on the first line, that was causing spurious vertical spacing; removed the final \vss, so the caption is bottom aligned, not centered.

  • Moved all the float set-up into one command, for uniformity.

  • Added a margins=hangoutside option, to get captions in to the outer margins, when combined with facing=yes [facing was not consistent between your examples].

I have also tidied the text in your captions.

One warning with the above code: a figure close to the top of the page may have its caption run out over the top - the height of the caption has been completely hidden to page making routine. [This was also the case in your original code.]

share|improve this answer
add comment

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.