Graphics, Figures & Tablessubfig | Multiple Sub-figures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
minidiable
Posts: 30
Joined: Tue Nov 13, 2012 4:18 pm

subfig | Multiple Sub-figures

Post by minidiable »

Hi to all.

I'm using TeXmaker 3.5.2 and I'm trying to write my Master Thesis with it. I have my first need of help.

I would like to display two different figures on the same line and I did it with these command:

Code: Select all

\begin{figure}[h]
\begin{center}$
\begin{array}{cc}
\includegraphics[width=50mm]{pics/figure1.jpg}&
\includegraphics[width=50mm]{pics/figure2.jpg}
\end{array}$
\end{center}
\caption{Figure caption}
\label{pics:blablabla}
\end{figure}
Now I would like to itemize them. That is, I would like to display for example Figure 3.1(a) and Figure 3.2(b) ... I searched on the web and I found the solution, but I have to download and install the package subfig.

Is there another solution? Or how can I download and install that package?


Thanks,
Fabrizio

Recommended reading 2024:

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

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

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

subfig | Multiple Sub-figures

Post by Stefan Kottwitz »

Hi Fabrizio,

welcome to the board!

You could alternatively use the subcaption package, which is part of the caption package, if you would have that one already installed.

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

subfig | Multiple Sub-figures

Post by localghost »

minidiable wrote:[…] Or how can I download and install that package? […]
Download and installation of a package is usually done by the package manager of your TeX distribution (which you didn't tell us).

As Stefan I also favour the more sophisticated subcaption package from the caption bundle. If you really want to do it with subfig, the below code might serve as some inspiration.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mwe}    % loads »blindtext« and »graphicx«
\usepackage{subfig}

\begin{document}
  \begin{figure}[!ht]
    \subfloat[First sub-figure\label{subfig-1:dummy}]{%
      \includegraphics[width=0.45\textwidth]{example-image-a}
    }
    \hfill
    \subfloat[First sub-figure\label{subfig-2:dummy}]{%
      \includegraphics[width=0.45\textwidth]{example-image-b}
    }
    \caption{Dummy figure}
    \label{fig:dummy}
  \end{figure}
\end{document}
The mwe package (when installed) makes the sample images available on your system and loads blindtext and graphicx.


Best regards and welcome to the board
Thorsten
Attachments
subfig-example.png
subfig-example.png (14.29 KiB) Viewed 184437 times
minidiable
Posts: 30
Joined: Tue Nov 13, 2012 4:18 pm

subfig | Multiple Sub-figures

Post by minidiable »

Hi,
Thanks for the quick reply. and thank you for the welcome.

I don't want to use a specific package.

So I tried to write

Code: Select all

\usepackage{caption}
But:

Code: Select all

! LaTeX Error: File `subcaption.sty' not found.
How can I do? I'm using TexMaker but I don't know what do you mean for Package manager of my Tex Distribution. Maybe you are talking about another software that I have that is MikTex 2.9 , because if I understood right Texmaker it's only an editor. Right?


Thanks,
Fabrizio
User avatar
Stefan Kottwitz
Site Admin
Posts: 10347
Joined: Mon Mar 10, 2008 9:44 pm

subfig | Multiple Sub-figures

Post by Stefan Kottwitz »

Hi Fabrizio,
minidiable wrote:I don't want to use a specific package.
That's the way LaTeX works: besides the kernel, it's split into hundreds (basic) and thousands (add-on) packages, so you choose the functions you use instead of having a large software which does all.
minidiable wrote:that is MikTex 2.9
So it should be easy, MiKTeX has a package manager, you can find it in the start menu.

Stefan
LaTeX.org admin
minidiable
Posts: 30
Joined: Tue Nov 13, 2012 4:18 pm

Re: subfig | Multiple Sub-figures

Post by minidiable »

Thank you. If someone else need it:

Under Windows:
StartMenu->All programs->MikTex2.9->Maintenance->Package Manager...
Then search your package (i.e. "caption") right click and then INSTALL

Thanks.
fabrizio.
Lehmer
Posts: 1
Joined: Wed Aug 20, 2014 4:48 pm

subfig | Multiple Sub-figures

Post by Lehmer »

localghost wrote:

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mwe}    % loads »blindtext« and »graphicx«
\usepackage{subfig}

\begin{document}
  \begin{figure}[!ht]
    \subfloat[First sub-figure\label{subfig-1:dummy}]{%
      \includegraphics[width=0.45\textwidth]{example-image-a}
    }
    \hfill
    \subfloat[First sub-figure\label{subfig-2:dummy}]{%
      \includegraphics[width=0.45\textwidth]{example-image-b}
    }
    \caption{Dummy figure}
    \label{fig:dummy}
  \end{figure}
\end{document}
Thanks a lot!! I was looking for an answer about this during hours. You save me! Thanks again!!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10347
Joined: Mon Mar 10, 2008 9:44 pm

Re: subfig | Multiple Sub-figures

Post by Stefan Kottwitz »

Hi Lehmer,

welcome to the forum!

Thanks for telling that. Nice to see that Thorsten's solution helped you too. Feel free to post any other question you might have. In that case, just open a new topic.

Best regards,

Stefan
LaTeX.org admin
Post Reply