消除子图行之间的垂直间距

消除子图行之间的垂直间距

subfigure我正在尝试确定如何消除使用该包生成的行之间的垂直间距subcaption

目前我有

\documentclass[11pt]{article}

\usepackage[utf8x]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{overpic}
\usepackage{xcolor}

\DeclareCaptionLabelFormat{bold}{\textbf{(#2)}}
\captionsetup{subrefformat=bold}
\renewcommand{\thesubfigure}{\Alph{subfigure}}

\begin{document}

% Sub-Figure Example
\begin{figure}[h!]
  \captionsetup{width=.9\linewidth}
  \centering
  % Figure row 1
  \begin{subfigure}[b]{0.3\linewidth}
    \begin{overpic}[percent,width=\linewidth]{coffee.jpg}
      \put (5,40) {\color{white} A}
    \end{overpic}
    \phantomsubcaption\label{fig:a}
  \end{subfigure}%
  \begin{subfigure}[b]{0.3\linewidth}
    \begin{overpic}[percent,width=\linewidth]{coffee.jpg}
      \put (5,40) {\color{white} B}
    \end{overpic}
    \phantomsubcaption\label{fig:b}
  \end{subfigure}%
  \begin{subfigure}[b]{0.3\linewidth}
    \begin{overpic}[percent,width=\linewidth]{coffee.jpg}
      \put (5,40) {\color{white} C}
    \end{overpic}
    \phantomsubcaption\label{fig:c}
  \end{subfigure}
  % Figure row 2
  \begin{subfigure}[b]{0.9\linewidth}
    \begin{overpic}[percent,width=\linewidth]{coffee.jpg}
      \put (1.5,48) {\color{white} D}
    \end{overpic}
    \phantomsubcaption\label{fig:d}
  \end{subfigure}
  \caption{This is a figure. \subref{fig:a} This is a cup of coffee. \subref{fig:b} This is another cup of coffee. \subref{fig:c} This is more coffee.  \subref{fig:d} This is a big cup of coffee.}
  \label{fig:coffee3}
\end{figure}


\end{document}

A我正在尝试确定如何消除包含 的行和包含 的行B之间的空白CD

在此处输入图片描述

答案1

显然\phantomcaption跳过了一行。

\documentclass[11pt]{article}

\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{overpic}
\usepackage{xcolor}

\DeclareCaptionLabelFormat{bold}{\textbf{(#2)}}
\captionsetup{subrefformat=bold}
\renewcommand{\thesubfigure}{\Alph{subfigure}}

\begin{document}

% Sub-Figure Example
\begin{figure}[!htp]
\centering
\captionsetup{width=.9\textwidth}

% Figure row 1
\begin{subfigure}{0.3\textwidth}
  \centering
  \begin{overpic}[percent,width=\textwidth]{example-image}
    \put (5,40) {\color{white} A}
  \end{overpic}
  \phantomsubcaption\label{fig:a}
\end{subfigure}%
\begin{subfigure}{0.3\textwidth}
  \centering
  \begin{overpic}[percent,width=\textwidth]{example-image}
    \put (5,40) {\color{white} B}
  \end{overpic}
  \phantomsubcaption\label{fig:b}
\end{subfigure}%
\begin{subfigure}{0.3\textwidth}
  \centering
  \begin{overpic}[percent,width=\textwidth]{example-image}
    \put (5,40) {\color{white} C}
  \end{overpic}
  \phantomsubcaption\label{fig:c}
\end{subfigure}

\vspace{-\baselineskip}

\begin{subfigure}{0.9\textwidth}
  \centering
  \begin{overpic}[percent,width=\textwidth]{example-image}
    \put (1.5,48) {\color{white} D}
  \end{overpic}
  \phantomsubcaption\label{fig:d}
\end{subfigure}

\vspace{-\baselineskip}

\caption{This is a figure. \subref{fig:a} This is a cup of coffee. 
  \subref{fig:b} This is another cup of coffee. \subref{fig:c} This is more coffee.  
  \subref{fig:d} This is a big cup of coffee.}
\label{fig:coffee3}

\end{figure}


\end{document}

在此处输入图片描述

避免使用utf8x,它现在不受支持且没有必要。默认为utf8,因此您甚至不需要加载inputenc

也是[h!]自找麻烦。

相关内容