带有 subfloat 和 minipage 的调整框,用于“Overfull \hbox LaTeX”

带有 subfloat 和 minipage 的调整框,用于“Overfull \hbox LaTeX”

我试图将两个图形(分别存储在两个 .pdf 文件中)以单列样式垂直放置。\subfigure这是不允许的,下面是我的代码:

\documentclass{article}
\usepackage{subfig}
\usepackage{float}
\usepackage[export]{adjustbox}

\begin{document}

\begin{figure}[H]
    \centering
    \subfloat[1]{
        \begin{minipage}[t]{1\linewidth}
            \includegraphics[width = 1\linewidth]{1.pdf}
        \end{minipage}
        \label{1}
    }
    \\
    \subfloat[2]{
        \begin{minipage}[t]{1\linewidth}
            \includegraphics[width = 1\linewidth]{2.pdf}
        \end{minipage}
        \label{2}
    }
    \caption{0}
    \label{0}
\end{figure}

\end{document}

但是,我收到了 的警告Overfull \hbox (10.77068pt too wide)LaTeX。我搜索了一下,发现\adjustbox可以使用以下代码解决它:

\documentclass{article}
\usepackage{subfig}
\usepackage{float}
\usepackage[export]{adjustbox}

\begin{document}

\begin{figure}[H]
    \centering
    \begin{adjustbox}{width=\linewidth}
    \subfloat[1]{
        \begin{minipage}[t]{1\linewidth}        
            \includegraphics[width = 1\linewidth]{1.pdf}
        \end{minipage}
        \label{1}
    }
    \end{adjustbox}
    \\
    \begin{adjustbox}{width=\linewidth}
    \subfloat[2]{
        \begin{minipage}[t]{1\linewidth}
            \includegraphics[width = 1\linewidth]{2.pdf}
        \end{minipage}
        \label{2}
    }
    \end{adjustbox}
    \caption{0}
    \label{0}
\end{figure}

\end{document}

但我认为复制调整框有点复杂,并尝试了这种方式:

\documentclass{article}
\usepackage{subfig}
\usepackage{float}
\usepackage[export]{adjustbox}

\begin{document}

\begin{figure}[H]
    \centering
    \adjustbox{width=\linewidth}{
    \subfloat[1]{
        \begin{minipage}[t]{1\linewidth}        
            \includegraphics[width = 1\linewidth]{1.pdf}
        \end{minipage}
        \label{1}
    }
    \\
    \subfloat[2]{
        \begin{minipage}[t]{1\linewidth}
            \includegraphics[width = 1\linewidth]{2.pdf}
        \end{minipage}
        \label{2}
    }
    }
    \caption{0}
    \label{0}
\end{figure}

\end{document}

一次性设置整个图形,但Something's wrong--perhaps a missing \item.\\前面出现了错误\subfloat[2]{

在此处输入图片描述

那么有没有什么方法可以轻松解决这个问题呢?

答案1

%通过在之后插入和 来消除多余的空格\subfloat,从而消除 Overfull 。\label\end{minipage}

(在@David Carlisle 评论后更新)

\documentclass{article}
\usepackage{subfig}
\usepackage{float}
\usepackage[export]{adjustbox}

\usepackage{showframe} % ONLY to show the margins <<<<<<<<<<
\usepackage{graphicx} % to add example-image


\begin{document}

Some text.

\begin{figure}[H]       
    \centering
    \subfloat[1]{% <<<<<<<<<<<<
    \begin{minipage}[t]{1\linewidth}
        \includegraphics[width = 1\linewidth,height=150pt]{example-image}
          \end{minipage}%<<<<<<<<<<<<
        \label{1}% <<<<<<<<<<<<
    }
    \\
    \subfloat[2]{% <<<<<<<<<<<<
    \begin{minipage}[t]{1\linewidth}
        \includegraphics[width = 1\linewidth,height=150pt]{example-image}
          \end{minipage}%<<<<<<<<<<<<
        \label{2}% <<<<<<<<<<<<
    }
    \caption{0}
    \label{0}
\end{figure}
    
\end{document}

A

最简单的代码:

\begin{figure}[H]       
    \centering
    \subfloat[1\label{1}]{% label here 
        \includegraphics[width = 1\linewidth,height=150pt]{example-image}%      
     }
    \\
    \subfloat[2]{%
        \includegraphics[width = 1\linewidth,height=150pt]{example-image}%
        \label{2}%   or label here
    }
    \caption{0}
    \label{0}
\end{figure

相关内容