1

i am using the following code to put three figures in a row but it puts them in a column. how can i fix it?

 \documentclass[a4paper,12pt]{report}‎
 \usepackage{graphicx} 

 \usepackage{subcaption}

 \begin{figure}[h]   ‎  ‎
 \centering     ‎
 \begin{subfigure}[h]{0.3\textwidth}
 \includegraphics[width=\textwidth]{a}
         \end{subfigure}%

   \begin{subfigure}[h]{0.3\textwidth} ‎
   \includegraphics[width=\textwidth]{b} \end{subfigure}‎‎

   \begin{subfigure}[h]{0.35\textwidth}   ‎
   \includegraphics[width=\textwidth]{c} \end{subfigure}‎‎
   \end{figure}

\end{document}
user3482383
  • 1,629
  • Can you please add a full minimal working example so that people can see what packages etc you need to get your code to work (but don't add code that is not needed). This makes it much easier for people to help you. –  Sep 03 '14 at 07:41

1 Answers1

4

You have empty lines between your subfigures, causing every one of them to be in a new paragraph.

Getting rid of the empty lines, deleting the unnecessary placement specifiers on the subfigures, making all pictures the same size and allowing for some glue between them, gives the following:

\documentclass{book}

\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}[h]
    \centering     ‎
    \begin{subfigure}{0.3\textwidth}
        \includegraphics[width=\textwidth]{Example-Image}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.3\textwidth} ‎
        \includegraphics[width=\textwidth]{Example-Image}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.3\textwidth}   ‎
        \includegraphics[width=\textwidth]{Example-Image}
    \end{subfigure}‎‎
\end{figure}
\end{document}

result

If really no separate captions for the subfigures are required, the subfigures can also be omitted as @DavidCarlisle correctly noted:

\begin{figure}[h]
    \centering     ‎
    \includegraphics[width=0.3\textwidth]{Example-Image}
    \hfill
    \includegraphics[width=0.3\textwidth]{Example-Image}
    \hfill
    \includegraphics[width=0.3\textwidth]{Example-Image}
\end{figure}

will give the same output.

greyshade
  • 3,576
  • @DavidCarlisle that's right - edited. – greyshade Sep 03 '14 at 08:28
  • @greyshade thanks, there is one paragraph from the next topic which comes before my figure, how can i fix this? – user3482383 Sep 03 '14 at 10:01
  • @user3482383 the figure is a float environment - see here for a good reference on how to control floats. In short, you may use [H] as a placement specifier - or, if you don't need any captions at all, just use a minipage to include the pictures in. – greyshade Sep 03 '14 at 12:35