0

I want to:

  1. Have a float image at the bottom of a page that extends across the text and margin.
  2. Have text in the margin just above the float. This is just plain texxt, not a caption with a figure number.
  3. Have the main text come down the page to just above the float image.

In my MWE, the body text stops at the top of the text in the margin. I want it to stop just before the float image. To cover the blue arrow in the attached screenshot. A simple solution is better. This is my first post.

I also tried putting a marginnote in the float image. This worked. I could raise the bottom of the marginnote to be in the right place, but I had to do this by eye, so it is not a practical solution. I tried wrapfig but it didn't work.

\documentclass[oneside]{scrbook}    % using book here does not work
    \usepackage{graphicx}
    \usepackage{kantlipsum}
    \usepackage{marginnote}
        \usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry} 

    \renewcommand{\bottomfraction}{0.8}
    \renewcommand{\topfraction}{0.8}
    \renewcommand\bottomfraction{0.8}
    \renewcommand\topfraction{0.8}
    \renewcommand\textfraction{0.1}
    
    \setcounter{topnumber}{8}
    \setcounter{bottomnumber}{8}
    \setcounter{totalnumber}{8}


\begin{document}
    
\begin{figure}[b]
    \hspace{110mm}
    \begin{minipage}[t]{50mm}
      Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. If no language server is installed or the path provided in this extension’s Preferences tab is incorrect. 
    \end{minipage}
\end{figure}

\begin{figure}[b]
    \includegraphics[width=160mm]{example-image-a}
\end{figure}

\kant[1-2]

\end{document}

Screenshot of my MWE. I want the body text to come down to cover the blue arrow.

0

2 Answers 2

0

This computes the vertical adjustment needed for \marginnote.

First, it formats the caption in a savebox. And yes, you can use \caption and \label inside the savebox even if it gets moved to a new page. It uses \raisebox to move the baseline to the top of the figure, since the \marginnote is placed relative to the baseline.

The \makebox removes an overfull \hbox warning.

\documentclass[oneside]{scrbook}    % using book here does not work
    \usepackage{graphicx}
    \usepackage{kantlipsum}
    \usepackage{marginnote}
        \usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry} 

    \renewcommand{\bottomfraction}{0.8}
    \renewcommand{\topfraction}{0.8}
    \renewcommand\bottomfraction{0.8}
    \renewcommand\topfraction{0.8}
    \renewcommand\textfraction{0.1}
    
    \setcounter{topnumber}{8}
    \setcounter{bottomnumber}{8}
    \setcounter{totalnumber}{8}

    \usepackage{marginnote}

\begin{document}

\begin{figure}[b]
\sbox0{\begin{minipage}[b]{\marginparwidth}
    Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. If no language server is installed or the path provided in this extension’s Preferences tab is incorrect. 
\end{minipage}}% measure hgith of caption
    \edef\marginnotevadjust{-\the\ht0}%
    \marginnote{\usebox0}%
    \makebox[\textwidth][l]{\raisebox{-\height}{\includegraphics[width=160mm]{example-image-a}}}
\end{figure}

\kant[1-2]

\end{document}

This version uses \rlap and \raisebox to overlap the marginpar area above the float. No \marginnote or savebox needed.

\documentclass[oneside]{scrbook}    % using book here does not work
    \usepackage{graphicx}
    \usepackage{kantlipsum}
    \usepackage{marginnote}
        \usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry} 

    \renewcommand{\bottomfraction}{0.8}
    \renewcommand{\topfraction}{0.8}
    \renewcommand\bottomfraction{0.8}
    \renewcommand\topfraction{0.8}
    \renewcommand\textfraction{0.1}
    
    \setcounter{topnumber}{8}
    \setcounter{bottomnumber}{8}
    \setcounter{totalnumber}{8}

\begin{document}

\begin{figure}[b]
\leavevmode\rlap{\hskip\textwidth\hskip\marginparsep
    \raisebox{\depth}[0pt][0pt]{\begin{minipage}{\marginparwidth}
Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. If no language server is installed or the path provided in this extension’s Preferences tab is incorrect.\strut
\end{minipage}}}%
    \makebox[\textwidth][l]{\raisebox{-\height}{\includegraphics[width=160mm]{example-image-a}}}
\end{figure}

\kant[1-2]

\end{document}
4
  • That didn't work for me. You have used an image of width = /textwidth. I want a wider image. When I make the image wider it pushes the minipage text off to the right. When I use \raisebox to raise the minipage it has the same problems as the minibox in my MWE: The main body text doesn't extend below the top of the minipage, and I have to set \raisebox manually.
    – Stanley
    Commented Nov 28, 2022 at 4:06
  • Ah, I misunderstood what text you wanted next to the float. Commented Nov 29, 2022 at 14:50
  • That's all good now.
    – Stanley
    Commented Nov 30, 2022 at 1:59
  • It seems I don't have enough experience points to upvote your answer.
    – Stanley
    Commented Nov 30, 2022 at 3:45
0

This is a kludge but it works. I have 1 float at the bottom of the page, with an image and a marginnote. I have the top of the marginnote fairly high above the image, then fill it with a fairly tall minipage, who's bottom is just above the figure. I drop the marginnote text to the bottom of the minipage with it's [b] internal position option.

I'd like to see a better solution though.

\documentclass[oneside]{scrbook}    % using book here does not work
    \usepackage{graphicx}
    \usepackage{kantlipsum}
    \usepackage{marginnote}
        \usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry} 

    \renewcommand{\bottomfraction}{0.8}
    \renewcommand{\topfraction}{0.8}
    \renewcommand\bottomfraction{0.8}
    \renewcommand\topfraction{0.8}
    \renewcommand\textfraction{0.1}
    
    \setcounter{topnumber}{8}
    \setcounter{bottomnumber}{8}
    \setcounter{totalnumber}{8}

\begin{document}

\begin{figure}[b]
    \marginnote{
    \begin{minipage}[t][80mm][b]{\marginparwidth}%
      \raggedright Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal.    \end{minipage}
    }[-90mm]%
    \includegraphics[width=160mm]{example-image-a}
\end{figure}

\kant[1-2]

\end{document}

If the caption is supposed to go below the image, you don't need to adjust the baseline, just put the whole thing into one big minipage.

\documentclass[oneside]{scrbook}    % using book here does not work
    \usepackage{graphicx}
    \usepackage{kantlipsum}
    \usepackage{marginnote}
    
\usepackage[a4paper,left=20mm,top=25mm,headsep=2\baselineskip,textwidth=100mm,marginparsep=10mm,marginparwidth=50mm,textheight=49\baselineskip,headheight=\baselineskip,showframe]{geometry} 

    \renewcommand{\bottomfraction}{0.8}
    \renewcommand{\topfraction}{0.8}
    \renewcommand\bottomfraction{0.8}
    \renewcommand\topfraction{0.8}
    \renewcommand\textfraction{0.1}
    
    \setcounter{topnumber}{8}
    \setcounter{bottomnumber}{8}
    \setcounter{totalnumber}{8}

\begin{document}

\begin{figure}[b]
\makebox[\textwidth][l]{\begin{minipage}{\dimexpr \textwidth+\marginparsep+\marginparwidth}
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Smart code completion, contextual hover information, and issue reports require the TexLab Language Server. The easiest way to install TexLab is to first install Homebrew and then run brew install texlab in a terminal. If no language server is installed or the path provided in this extension’s Preferences tab is incorrect.}
\end{minipage}}
\end{figure}

\kant[1-2]

\end{document}
1
  • Yes, that works well. But the OP asked for the caption to be above the image and in the margin,
    – Stanley
    Commented Nov 28, 2022 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .