我正在尝试使用包将两个图形并排(大小相同)放置在文本的宽度内floatrow
。我使用showframe
选项和\fbox
mwe 中的以获得更好的可视化效果。如何完美适应文本宽度?
\documentclass[]{report}
\usepackage[a4paper,showframe]{geometry}
\usepackage{subcaption}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{floatrow}
\begin{document}
\lipsum[1]
\begin{figure}[htb!]
\ffigbox[\textwidth]
{\begin{subfloatrow}[2]\setlength\fboxsep{0pt}\setlength\fboxrule{0.75pt}\fbox{\ffigbox[0.49\textwidth]
{
\caption{sidewalk perforation}
\label{subfig:furadeira}
}
{ \setlength\fboxsep{0pt}
\setlength\fboxrule{0.75pt}
\fbox{\includegraphics[width=0.48\textwidth]{image1.jpg}}}
\setlength\fboxsep{0pt}
\setlength\fboxrule{0.75pt}}
\fbox{\ffigbox[0.49\textwidth]
{
\caption{volatile organic compounds measurement}
\label{subfig:medicaomalha}
}
{
\setlength\fboxsep{0pt}
\setlength\fboxrule{0.75pt}
\fbox{\includegraphics[width=0.48\textwidth]{image2.jpg}}
}}
\end{subfloatrow}
}
{
\caption{Hot spot investigation}
\label{fig:hotspot}
}
\end{figure}%
\lipsum[1]
\end{document}
答案1
您需要更改\columnsep
使用的默认 floatseparator ( )。考虑到图形的宽度,预定义的分隔符在这里都无用,但您可以使用以下方法轻松定义一个\DeclareFloatSeparators
:
\documentclass[]{report}
\usepackage[a4paper,showframe]{geometry}
\usepackage{subcaption}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{floatrow}
\DeclareFloatSeparators{myfill}{\hskip.013\textwidth plus1fill}
\begin{document}
\lipsum[1]
\floatsetup[subfloat]{floatrowsep=myfill}
\begin{figure}[htb!]
\setlength\fboxsep{0pt}\setlength\fboxrule{0.75pt}
\ffigbox[\textwidth]
{
\begin{subfloatrow}[2]
%\fbox{
\ffigbox[.49\textwidth]
{
\caption{sidewalk perforation}
\label{subfig:furadeira}
}
{
\includegraphics[width=\linewidth]{example-image-a}%
}
%}
%\fbox{
\ffigbox[.49\textwidth]
{
\caption{volatile organic compounds measurement}
\label{subfig:medicaomalha}
}
{
\includegraphics[width=\linewidth]{example-image-b}%
}
%}
\end{subfloatrow}%
}
{
\caption{Hot spot investigation}
\label{fig:hotspot}
}
\end{figure}%
\lipsum[1]
\end{document}
请注意,第一个子字的左边仍然有一些虚假的空白;我怀疑这是一个错误floatrow.sty
(很可能是缺少了%
消除多余空格的功能)。
为了使子图完美地与边缘对齐,我建议您使用 floatrow 而不是 subfloatrow 并使用 \captionof{subfigure}{text...} 来提供标题:
\documentclass[]{report}
\usepackage[a4paper,showframe]{geometry}
\usepackage{subcaption}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{floatrow}
\captionsetup[subfigure]{labelformat=parens,labelsep=space}
\begin{document}
\lipsum[1]
\begin{figure}[htb!]
\ffigbox[\textwidth]
{
\begin{floatrow}
\ffigbox[\linewidth]
{\captionof{subfigure}{sidewalk perforation}
\label{subfig:furadeira}}
{\includegraphics[width=\linewidth]{example-image-a}}
\ffigbox[\linewidth]
{\captionof{subfigure}{volatile organic compounds measurement}
\label{subfig:medicaomalha}}
{\includegraphics[width=\linewidth]{example-image-b}}
\end{floatrow}%
}
{\caption{Hot spot investigation}\label{fig:hotspot}}
\end{figure}
\lipsum[1]
\end{document}