我太迷茫了!不知道为什么我总是收到这个错误。我尝试了几乎所有的子图、浮动、居中组合,但总是收到“不在外部模式”错误
\begin{figure}[htp]
% \centering
\noindent\makebox[\textwidth]{
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{img/preproc_1.png}
\caption{Raw Image}
\label{fig:preproc_1}
\end{subfigure}%
~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
%(or a blank line to force the subfigure onto a new line)
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{img/preproc_2.png}
\caption{Gaussian Smoothing}
\label{fig:preproc_2}
\end{subfigure}
~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
%(or a blank line to force the subfigure onto a new line)
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{img/preproc_3.png}
\caption{Eigenvalues}
\label{fig:preproc_3}
\end{subfigure}
\caption{Visualization of the preprocessing procedure} \label{fig:preprocessing}
\end{figure}
答案1
您的代码几乎可以工作,但不需要以下行
% \noindent\makebox[\textwidth]{
我把它放在一起作为下面的完整 MWE -当您想要重新获取图像时删除该demo
选项。graphicx
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htp]
% \noindent\makebox[\textwidth]{
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{img/preproc_1.png}
\caption{Raw Image}
\label{fig:preproc_1}
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{img/preproc_2.png}
\caption{Gaussian Smoothing}
\label{fig:preproc_2}
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{img/preproc_3.png}
\caption{Eigenvalues}
\label{fig:preproc_3}
\end{subfigure}
\caption{Visualization of the preprocessing procedure} \label{fig:preprocessing}
\end{figure}
\end{document}