使用浮动框减少图形和标题之间的水平间隙

使用浮动框减少图形和标题之间的水平间隙

我习惯floatbox将标题放在图形的右侧,但如图所示,图形和标题开头之间有大约 1/8 行宽的间隙。我可以减少这个间隙并将标题移到图形旁边吗?因为它看起来很奇怪!

用于生成下图的代码:

\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}

它在我的文档中看起来如下:

在此处输入图片描述

答案1

您可以\thisfloatsetup使用capbesidesep键修改此水平间距。正如 中floatrow所述文档,可以为此键分配值

  • columnsep,增加了\columnsep水平跳跃,
  • quad,它添加了一个水平跳过1em(命令的长度\quad),
  • qquad,它添加了一个水平跳过2em(命令的长度\qquad),
  • hfil,其行为类似于\hfil
  • hfill,其行为类似于\hfill
  • none,它不添加任何水平跳过。

因此,您可以在这些键之间进行选择,以正确放置您的人物,或者您可以使用 定义另一个键\DeclareFloatSeparators。例如,

\DeclareFloatSeparators{mysep}{\hskip3em}

定义一个mysep添加水平跳跃的键3em。使用此命令,您甚至可以添加水平跳跃的负值。

下面是三个具有不同水平跳过的图形的示例,其中一个图形被定义为\DeclareFloatSeparators插入负跳过。

\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}

相关内容