1

I am using floatbox to place my caption on the right side of my figure but there is a gap of around 1/8th line width between the figure and the start of the caption as shown. Can I reduce this and move my caption right beside my figure as it looks weird!

Code used to generate the below image:

\begin{figure}[htp]
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,center},capbesidewidth=.35\linewidth}}]{figure}[\FBwidth]
{\caption{This is a caption describing this figure as needed. The caption can contain any text but needs to desribe the image with enough detail for a reader to completely understand the image.}
{\includegraphics[width=.5\textwidth]{image1}}
\end{figure}

This is how it looks in my document:

enter image description here

0

You can modify this horizontal spacing in \thisfloatsetup with the capbesidesep key. As said in floatrow's documentation, this key can be assigned the values

  • columnsep, which adds a \columnsep horizontal skip,
  • quad, which adds an horizontal skip of 1em (the length of a \quad command),
  • qquad, which adds an horizontal skip of 2em (the length of a \qquad command),
  • hfil, which behaves like \hfil,
  • hfill, which behaves like \hfill,
  • none, which doesn't add any horizontal skip.

So you can choose between those keys to place correctly your figure, or you could define another key using \DeclareFloatSeparators. For example,

\DeclareFloatSeparators{mysep}{\hskip3em}

defines a mysep key which adds an horizontal skip of 3em. Using this command, you could even add negative values of horizontal skips.

Here's an example of three figures with different horizontal skips, one of them being defined with \DeclareFloatSeparators to insert a negative skip.

\documentclass{article}
\usepackage{floatrow}
\usepackage{graphicx}
\DeclareFloatSeparators{mysep}{\hskip-1em}
\begin{document}
\begin{figure}[h!]
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,center},
                                     capbesidewidth=.42\linewidth,
                                     capbesidesep=quad}}]{figure}[\FBwidth]
{\caption{\texttt{capbesidesep=quad}. This is a caption describing this figure as needed. The caption can contain any text but needs to desribe the image with enough detail for a reader to completely understand the image.}}
{\includegraphics[width=.5\textwidth]{example-image}}
\end{figure}
\begin{figure}[h!]
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,center},
                                     capbesidewidth=.42\linewidth,
                                     capbesidesep=none}}]{figure}[\FBwidth]
{\caption{\texttt{capbesidesep=none}. This is a caption describing this figure as needed. The caption can contain any text but needs to desribe the image with enough detail for a reader to completely understand the image.}}
{\includegraphics[width=.5\textwidth]{example-image}}
\end{figure}
\begin{figure}[h!]
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,center},
                                     capbesidewidth=.42\linewidth,
                                     capbesidesep=mysep}}]{figure}[\FBwidth]
{\caption{\texttt{capbesidesep=mysep}. This is a caption describing this figure as needed. The caption can contain any text but needs to desribe the image with enough detail for a reader to completely understand the image.}}
{\includegraphics[width=.5\textwidth]{example-image}}
\end{figure}
\end{document}

1
  • Thanks so much I knew there would be a way to control it, I just couldn't find the right command. Works perfectly!
    – Charlie
    Apr 4 '20 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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