[Tex/LaTex] Cannot align to right or left

horizontal alignment

I have this LaTeX code which should place this two images on the left and the right of the page:

\begin{flushright} \begin{figure}[H]
\includegraphics[width=107px ,
height=134px]{t1.jpg} \end{figure}

\begin{flushleft} \begin{figure}[H]
\includegraphics[width=113px ,
height=190px]{t2.jpg} \end{figure}

but the two images are placed one at the top of the other, why??

Best Answer

There are a number of issues:

figure is a floating environment. It is not placed directly but stored and placed where LaTeX thinks it fits best. This can be influenced by the optional argument like [H] but surrounding alignment environment still don't have any influence on it.

flushleft and flushright produce paragraphs and therefore a line break. So both contents will always vertical stacked, never side by side.

Note that you don't need a figure environment to use \includegraphics, only if you want a caption. Also you can have multiple images and captions (!) in one figure. Try the following code to place the two images side-by-side and at the left and right corner (if this is what you want):