Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

subcaption instead of subfigure

564 views
Skip to first unread message

Ivan K

unread,
Dec 20, 2015, 11:34:25 PM12/20/15
to

So, according to:

https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions

the subfigure and subfig packages are deprecated and I should be using
the subcaption package instead although this post dated 2013:

http://tex.stackexchange.com/questions/144782/subfigure-and-subfig-packages-deprecated

claims that subfig is not deprecated.


In any case, I have an example appended with uses subfigure,
and I wonder if someone could explain to me the syntax that
I should use to switch this example to the subcaption
package.

Thank you for any pointers you may have.


\documentclass[letterpaper]{book}

\usepackage{graphicx}
\usepackage{subfigure}

\begin{document}
\begin{figure}

\begin{center}
\subfigure[.05 seconds of a Bassoon Tone at 130 hertz (C3)]{
\label{fig:bassoon_plot_01}
\includegraphics[width=3.25in,totalheight=2.00in]{bassoon_01.png}
}%
\subfigure[ .05 seconds of a Bassoon Tone at 440 hertz (A4)]{
\label{fig:bassoon_plot_02}
\includegraphics[width=3.25in,totalheight=2.00in]{bassoon_02.png}
}%

\end{center}
\caption{
Comparing plots of the sound wave of two bassoon
tones of .05 seconds each
}
\label{fig:twobassoontones}
\end{figure}


\end{document}

Markus Kohm

unread,
Dec 21, 2015, 3:18:38 AM12/21/15
to
Ivan K (Montag, 21. Dezember 2015 05:31):

> In any case, I have an example appended with uses subfigure,
> and I wonder if someone could explain to me the syntax that
> I should use to switch this example to the subcaption
> package.

Either:

\documentclass[letterpaper]{book}

\usepackage{graphicx}
\usepackage{subcaption}

\usepackage{mwe}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}{3.25in}
\includegraphics[width=\linewidth,totalheight=2.00in]{example-
image-a}
\caption{.05 seconds of a Bassoon Tone at 130 hertz (C3)}
\label{fig:bassoon_plot_01}%
\end{subfigure}%
\nobreak\enskip\nobreak% Only to have the same oversized result as
before
\begin{subfigure}{3.25in}
\includegraphics[width=\linewidth,totalheight=2.00in]{example-
image-b}%
\caption{.05 seconds of a Bassoon Tone at 440 hertz (A4)}
\label{fig:bassoon_plot_02}%
\end{subfigure}%
\caption{%
Comparing plots of the sound wave of two bassoon
tones of .05 seconds each%
}
\label{fig:twobassoontones}
\end{figure}

\end{document}

or

\documentclass[letterpaper]{book}

\usepackage{graphicx}
\usepackage{subcaption}

\usepackage{mwe}

\begin{document}
\begin{figure}
\centering
\subcaptionbox{.05 seconds of a Bassoon Tone at 130 hertz
(C3)\label{fig:bassoon_plot_01}}{%
\includegraphics[width=3.25in,totalheight=2.00in]{example-image-a}
}%
\subcaptionbox{.05 seconds of a Bassoon Tone at 440 hertz
(A4)\label{fig:bassoon_plot_02}}{%
\includegraphics[width=3.25in,totalheight=2.00in]{example-image-b}%
}
\caption{%
Comparing plots of the sound wave of two bassoon
tones of .05 seconds each%
}
\label{fig:twobassoontones}
\end{figure}

\end{document}

You should note that in your example 3.25in + 3.25in + several white spaces
is more than \textwidth. I have not changed this but tried to immitate the
result of your example.

Ivan K

unread,
Dec 21, 2015, 2:52:40 PM12/21/15
to

Thank you for this very helpful tutorial!

I do read the documentation, but sometimes, it is
still difficult for me to come up with a working example.

Thanks again.


Markus Kohm <komas...@gmx.info> wrote:
>
> Ivan K (Montag, 21. Dezember 2015 05:31):
>
>
> Either:
>
[...]
>
> or
>
[...]
0 new messages