Graphics, Figures & Tablesside by side figures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
daviddoria
Posts: 60
Joined: Tue Sep 30, 2008 9:24 pm

side by side figures

Post by daviddoria »

I would like to have 3 images side by side. I tried to use this:

Code: Select all

\begin{figure}[t]
\begin{center}
\label{BadMatchFigure}
\begin{array}{ccc}
\includegraphics{images/ConcaveWorld} & \includegraphics{images/GoodOccludedModel} & \includegraphics{images/PerfectModel}
\end{array}
\end{center}
\end{figure}
But I get "missing $ inserted" errors. Is there a better way to do this?

Dave

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

side by side figures

Post by Stefan Kottwitz »

Hi Dave,

you could use the subfig package, have a look at its documentation.
Or just set minipages side-by-side.

The error you've mentioned occured because the array environment has to be used in math mode. In text mode you could use tabular, tabularx etc.

Btw. in figure environments I would use \centering instead of \begin{center} ... \end{center}, see center vs. \centering.

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 »

The current version of the caption package comes with the subcaption package, which provides the same but more reliable capabilities as the subfig package.


Best regards
Thorsten¹
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

side by side figures

Post by gmedina »

Hi,

another option would be to use the subcaption package (a tiny companion of the caption package):

Code: Select all

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}[!ht]
  \begin{subfigure}[b]{.3\linewidth}
    \centering
    \rule{2cm}{2cm}
    \caption{A subfigure.}
    \label{fig:subfiga}
  \end{subfigure}%
  \begin{subfigure}[b]{.3\linewidth}
    \centering
    \rule{2cm}{4cm}
    \caption{A subfigure.}
    \label{fig:subfigb}
  \end{subfigure}%
  \begin{subfigure}[b]{.3\linewidth}
    \centering
    \rule{2cm}{3cm}
    \caption{A subfigure.}
    \label{fig:subfigc}
  \end{subfigure}%
  \caption{A figure with three subfigures.}
  \label{fig:testfig}
\end{figure}

\end{document}
Please refer to the subcaption documentation for further information.

Edit: localghost has already suggested the subcaption package, so this post can be deleted.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
prince8889
Posts: 19
Joined: Mon Feb 27, 2012 11:01 pm

Re: side by side figures

Post by prince8889 »

hiii...

I just want to know where is the figure name mentioned in the above code or to make it is easy what is the figure name in the above code???
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

side by side figures

Post by localghost »

prince8889 wrote:hiii...

I just want to know where is the figure name mentioned in the above code or to make it is easy what is the figure name in the above code???
Ask targeted and clearly phrased questions with an adequate problem description in the topic you opened for this purpose [1]. This is certainly better than reactivating a thread that is more than three(!) years old.

[1] View topic: Place two independent Figures Side by Side
Post Reply