
我正在嘗試使用包將兩個圖形並排(具有相同的大小)放入文字的寬度中floatrow
。我使用該showframe
選項和\fbox
in 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}