减少垂直空白子图

减少垂直空白子图

在此处输入图片描述

我在删除两行连续 4 幅图像之间的空白时遇到了问题。非常感谢您的帮助!请注意,水平空白是在“\end{subfigure}”后使用“%”删除的。

\documentclass[]{article}
\usepackage{mwe}
\usepackage[]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}

\begin{document}

\begin{figure}

\centering
% Waveform
\begin{subfigure}[b]{0.25\textwidth}
    \includegraphics[width =\textwidth]{example-image-a}
    \label{fig:ta}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
    \includegraphics[width =\textwidth]{example-image-b}
    \label{fig:tb}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
    \includegraphics[width =\textwidth]{example-image-c}
    \label{fig:tc}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0)
    {
        \includegraphics[width =\textwidth]{example-image-a}
    };
    \begin{scope}[ x={(image.south east)}, y={(image.north west)} ]
        \draw[red,ultra thick, dashed] (0.85,0.675) rectangle(0.95, 0.9);
%       \draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
%       \foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
%       \foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
    \end{scope} 
\end{tikzpicture}
\label{fig:td}
\end{subfigure}%

% Ray-based
\begin{subfigure}[b]{0.25\textwidth}
    \includegraphics[width =\textwidth]{example-image-a}
    \caption{}
    \label{fig:ba}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
    \includegraphics[width =\textwidth]{example-image-b}
    \caption{}
    \label{fig:bb}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
    \includegraphics[width =\textwidth]{example-image-c}
    \caption{}
    \label{fig:bc}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
    \includegraphics[width =\textwidth]{example-image-a}
    \caption{}
    \label{fig:bd}
\end{subfigure}%
\caption{I would for there to be no whitespace between the top row and bottom of images}\label{fig:invivo}
\end{figure}

\end{document}

答案1

这是一个可能的解决方案。将两幅图像(顶部和底部)放在一个subfigure环境中并用来vspace{-xx}缩小差距。

在此处输入图片描述

代码

\documentclass[]{article}
\usepackage{mwe}
\usepackage[]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}

\begin{document}
\begin{figure}

\centering
% Waveform
\begin{subfigure}[b]{0.25\textwidth}
\includegraphics[width =\textwidth]{example-image-a}\label{fig:ta}
\vspace{-1.07\baselineskip}
\includegraphics[width =\textwidth]{example-image-a}
\caption{}\label{fig:ba}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
\includegraphics[width =\textwidth]{example-image-b}\label{fig:tb}
\vspace{-1.07\baselineskip}
\includegraphics[width =\textwidth]{example-image-b}
\caption{} \label{fig:bb}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
\includegraphics[width =\textwidth]{example-image-c}
\label{fig:tc}\vspace{-1.07\baselineskip}
\includegraphics[width =\textwidth]{example-image-c}\caption{}\label{fig:bc}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
    {
        \includegraphics[width =\textwidth]{example-image-a}
    };
    \begin{scope}[ x={(image.south east)}, y={(image.north west)} ]
        \draw[red,ultra thick, dashed] (0.85,0.675) rectangle(0.95, 0.9);
%       \draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
%       \foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
%       \foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
    \end{scope} 
\end{tikzpicture}\label{fig:td}
\vspace{-1.07\baselineskip}
\includegraphics[width =\textwidth]{example-image-a}\caption{}\label{fig:bd}
\end{subfigure}%
\caption{I would for there to be no whitespace between the top row and bottom of images}\label{fig:invivo}
\end{figure}

\end{document}

相关内容