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 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}
share|improve this question
    
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. –  Andrew Sep 3 at 7:41

1 Answer 1

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.

share|improve this answer
    
@DavidCarlisle that's right - edited. –  greyshade Sep 3 at 8:28
    
+1 thanks (I deleted the comment) –  David Carlisle Sep 3 at 8:32
    
@greyshade thanks, there is one paragraph from the next topic which comes before my figure, how can i fix this? –  user3482383 Sep 3 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 3 at 12:35

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.