Graphics, Figures & TablesSide by Side Figures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
masarvghadi
Posts: 1
Joined: Mon Mar 05, 2012 11:17 am

Side by Side Figures

Post by masarvghadi »

Hi friends,

I am new to LaTeX and I am using two figure side by side. But the problem is that I cannot see the first figure's caption also the second figure's caption is placed under the first figure. Can anyone help me to fix this problem? My code is shown below.

Code: Select all

\begin{figure}[ht]
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[scale=0.75]{singleclustertopologyeps}
\caption{Single Cluster Topology}
\label{fig3.1}
\end{minipage}
\hspace{0.1cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[scale=0.75]{chaintopologywithtwohopseps}
\caption{Chain Topology with Two Hops}
\label{fig3.2}
\end{minipage}
\end{figure}
thank you in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

NoIdeaNickanme
Posts: 13
Joined: Wed Nov 09, 2011 5:41 pm

Side by Side Figures

Post by NoIdeaNickanme »

Try using the subfig package
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Side by Side Figures

Post by Stefan Kottwitz »

Another way would be using the subcaption package, which belongs to the caption package.
NoIdeaNickanme wrote:Try using the subfig package
Btw. I see you link to the package folder. We've got some new features, and one small of them is a CTAN button and bbcode syntax, for easy package linking. For any CTAN package, you could write like

Code: Select all

[CTAN]subfig[/CTAN]
or mark the package name and click the CTAN button. This produces the link subfig.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Side by Side Figures

Post by localghost »

masarvghadi wrote:[…] But the problem is that I cannot see the first figure's caption also the second figure's caption is placed under the first figure. […]
Your code can't work as expected since you try to put more content inside a line than it can take. The calculation is very easy. You have two figures of half the line width and you add 0.1cm of additional horizontal space. Hence this is more than the line width and the second figure goes into the next line. If you reduce the width of both figures to e. g. 0.49\linewidth and replace \hspace{0.1cm} by \hfill, it should work as desired.

Another point is that you use a fixed scaling factor for the included graphics files. This might not match the given widths of the minipage environments, thus also can cause the trouble.

Due to missing information and a missing minimal example advanced help is not possible at the moment.


Best regards and welcome to the board
Thorsten
Post Reply