4

I'd like to create a figure consisting of two subfigures without using the caption or subcaption package since these two packages seem to destroy my template. But all the solutions for subfigures I could find in the Internet use these two packages. What other possibilities do I have? I want the two figures in a 2-column layout to cover both columns and each figure should be 1 column width.

1
  • 2
    You could use the subfig package without caption package: \usepackage[caption=false]{subfig}. (Actually this still loads caption3.sty but this does not make any harm since this will not re-define anything but only provide a library for typesetting captions used by the subfig package internally.)
    – user2574
    Sep 12, 2013 at 7:26

1 Answer 1

6

Using minipages and a new counter you can produce your subfigures without any packages at all; you can also define a command to provide subcaptions:

\documentclass[twocolumn]{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{chngcntr}

\newcounter{mysfig}
\counterwithin{mysfig}{figure}

\renewcommand\themysfig{\thefigure(\alph{mysfig})}
\makeatletter
\newcommand\Scaption[1]{%
\refstepcounter{mysfig}%
\vskip.5\abovecaptionskip
  \sbox\@tempboxa{\small\themysfig~#1}%
  \ifdim \wd\@tempboxa >\hsize
    \small\themysfig~#1\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
\makeatother

\begin{document}
\lipsum[1-2]
\begin{figure*}
\stepcounter{figure}
\begin{minipage}[t]{\columnwidth}
\begin{minipage}[b]{\columnwidth}
\includegraphics[width=\linewidth]{example-image-a}\par
\end{minipage}
\Scaption{this is the caption for the left subfigure}
\label{sfig:testa}
\end{minipage}\hfill
\begin{minipage}[t]{\columnwidth}
\begin{minipage}[b]{\columnwidth}
\includegraphics[width=\linewidth]{example-image-b}
\end{minipage}
\Scaption{this is the caption for the right subfigure, spanning two lines}
\label{sfig:testb}
\end{minipage}%
\end{figure*}
\lipsum[1-5]
References to subfigures~\ref{sfig:testa} and~\ref{sfig:testb}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .