Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Welcome to TeX.sx! –  Kurt Nov 30 '12 at 20:49
add comment

1 Answer 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}
share|improve this answer
    
Thanks for helping me out but I get the same error on the line \begin{figure}[htp] –  sumrania 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? –  sumrania Nov 30 '12 at 20:47
    
@sumrania MacTeX is the distribution- is it up to date? see tex.stackexchange.com/questions/55437/… –  cmhughes Dec 1 '12 at 0:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.