I'm a bit anal about caption positioning. In the following screenshots there are several issues:
Figure (0.1):
- ✅ the image is correctly positioned at the very right (it touches the magenta line)
- ✅ left margin with the text is enough
- ❌ caption is not aligned with the image
Figure (0.2):
- ❌ image is wrongly positioned (it doesn't touch the magenta line on the right)
- ❌ left margin is too small
- ✅ caption is perfectly aligned with the image
My goal is to score ✅✅✅, i.e. align the image to the far right, have a large enough left margin and a raggedright caption aligned with the image left.
In the following MWE you see that I'm using wrapfig
and adjustbox
that allows an extra parameter to includegraphics
(the position relative to the wrapfigure
). Both wrapfigure
s are aligned to the right, but...
In the Figure (0.1) I'm aligning the image to the right relative to the wrapfigure
(good), but the caption starts at the default margin on the left (wrong). By trial and error I could shorten the wrapfigure
itself, but I would end with a too short left margin (also wrong)
In the Figure (0.2) I'm aligning the image to the left (relative to the wrapfigure
), which helps in aligning it with the caption (good), but the image doesn't reach the far right (wrong) and the left margin is too short (also wrong). Using a wider image doesn't really help because even if the image would end up touching the right, the left margin keeps being too small.
Also, why is that the first image starts exactly at the top of the page, while the second is vertically off (~ one line) relative to where it should be?
If this is of any help, I'm using a document of class scrbook
.
MWE
\documentclass[11pt,oneside,captions=centeredbeside]{scrbook}
\usepackage{blindtext}
\usepackage[export]{adjustbox}
\usepackage{wrapfig}
\usepackage{xcolor}
\definecolor{caption-label-color}{HTML}{333333}
\definecolor{caption-text-color}{HTML}{777777}
\usepackage{caption}
\DeclareCaptionLabelSeparator{enskip}{\enskip}
\DeclareCaptionFont{blah}{\small\sffamily\selectfont}
\captionsetup[figure]{
position=bottom,
skip=3mm,
labelfont={bf,sf,color=caption-label-color},
textfont={blah,color=caption-text-color},
singlelinecheck=false,
justification=raggedright,
labelformat=parens,
labelsep=enskip
}
\setcapindent{0em}
\begin{document}
\begin{wrapfigure}{r}{0.50\textwidth}
\includegraphics[width=0.47\textwidth,right]{example-image-a}
\caption{A long caption that spans more than one row}
\end{wrapfigure}
\blindtext[1]
\begin{wrapfigure}{r}{0.50\textwidth}
\includegraphics[width=0.47\textwidth]{example-image-a}
\caption{A long caption that spans more than one row}
\end{wrapfigure}
\blindtext[1]
\end{document}
Thanks!
minipage
and flush it right? I have no computer now, but like (into the wrapfig)\hfill\begin{minipage}{0.95\linewdth}\includegraphic[width=\linewidth]{•••}\caption{•••}\end{minipage}
?