1

I am soooo lost! have no idea why I keep getting this error. I have tried almost every combination of subfigure, float, centering but I keep getting "Not in outer par mode" error

\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}
snazziii
  • 141

1 Answers1

1

Your code nearly works, but there's no need for the following line

% \noindent\makebox[\textwidth]{

I've put it together as a complete MWE below- remove the demo option from graphicx when you want the images back in.

\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}
cmhughes
  • 100,947
  • Thanks for helping me out but I get the same error on the line \begin{figure}[htp] – snazziii Nov 30 '12 at 20:40
  • @sumrania did you copy my MWE? Is your distribution up to date? The MWE works fine for me... – cmhughes Nov 30 '12 at 20:41
  • yes i copied yours. i downloaded the latest MacTeX package. Is that what you mean by distribution? – snazziii Nov 30 '12 at 20:47
  • @sumrania MacTeX is the distribution- is it up to date? see http://tex.stackexchange.com/questions/55437/how-do-i-update-my-tex-distribution – cmhughes Dec 01 '12 at 00:55