0

I want the two pictures side by side.I want to post two figures side by side in latex but it results coming one after the another. How do I solve this? The code i used is:

    \begin{figure}[H]
    \includegraphics[scale=0.1]{img.jpg}
    \caption{Energy Vs Photon Count graph for day 44.6}

    \includegraphics[scale=0.45]{img2.jpg}
    \caption{Energy Vs Photon Count graph for day 45.9}
    \end{figure}
    \FloatBarrier
  • 2
    Welcome to TeX.SX. Please add a minimal working example (MWE) that illustrates your problem. – ebcontrol Jun 11 '19 at 11:16
  • 1
    you apparently told to TeX, that they must be one after the other (by empty lines between, by to wide image, etc). you should provide MWE (Minimal Working Example) which exhibit your problem. Than we be able to help you. – Zarko Jun 11 '19 at 11:27
  • First, a blank line will always start a new paragraph,. Second \caption starts and ends with a \par and takes up the whole width. Just put them into minipages, usually separated by \hfill. – John Kormylo Jun 11 '19 at 13:35

1 Answers1

2

There are many possibilities, see Two figures side by side or LaTeX figures side by side [duplicate]. For example with the floatrow (page 99) package:

    \documentclass{article}
    \usepackage{caption}
    \usepackage[style=plain]{floatrow}
    \usepackage{graphicx}
    \begin{document}
    \begin{figure}[H]
        \CommonHeightRow{%
            \begin{floatrow}[2]%
                \ffigbox[\FBwidth]
                {\includegraphics[height=\CommonHeight]{example-image-a}}
                {\caption{Energy Vs Photon Count graph for day 44.6}}
                \ffigbox[\FBwidth]
                {\includegraphics[height=\CommonHeight]{example-image-b}}
                {\caption{Energy Vs Photon Count graph for day 45.9}}
            \end{floatrow}}%
    \end{figure}
    \end{document}

Output:

enter image description here

If you want to delete the caption label, you can use the command \caption*{} or put \captionsetup{labelformat=empty} in your preamble:

    \documentclass{article}
    \usepackage{caption}
    \usepackage[style=plain]{floatrow}
    \usepackage{graphicx}
    %\captionsetup{labelformat=empty} 
    \begin{document}
    \begin{figure}[H]
        \CommonHeightRow{%
            \begin{floatrow}[2]%
                \ffigbox[\FBwidth]
                {\includegraphics[height=\CommonHeight]{example-image-a}}
                {\caption*{Energy Vs Photon Count graph for day 44.6}}
                \ffigbox[\FBwidth]
                {\includegraphics[height=\CommonHeight]{example-image-b}}
                {\caption*{Energy Vs Photon Count graph for day 45.9}}
            \end{floatrow}}%
    \end{figure}
    \end{document}

Output: enter image description here

Ñako
  • 3,626