I'm having problems with conflicting width requirements for subcaptions on subfloats that are horizontal versus vertical. I've spent considerable time searching here and more broadly, poring over the subfig
package documentation, etc, and I figured out that the problem is with the widths.
For the subfloats that are arranged horizontally, the subcaptions need to be 3 inches wide; for the subfloats that are arranged vertically, the subcaptions need to be 5 inches wide. If I specify a 3in subcaption width, the subcaptions for the 5in images look awful. If I specify anything over a 3in subcaption width, the subcaptions for the 3in images are offset to the right and run off the page. When I was not specifying caption widths at all, the subfloat subcaptions became very narrow and weird.
I'm not sure how to resolve this; both subfloat arrangements need to be included in the same document. I realize that a custom environment might be in order, but don't have the first idea of how to construct something for this purpose.
Here is the example MWE (to the best of my ability, it's a first try…)
\documentclass[11pt]{article}
\usepackage{tabulary}
\usepackage{ctable}
\usepackage{epsfig}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{subfig}
\captionsetup[subfloat]{
nearskip=20pt,
width=3in
}
\captionsetup{
format=hang,
width=5.5in,
}
\begin{document}
\title{Title}
\author{Me}
\date{\today}
\maketitle
Vertically arranged images:
\begin{figure}[htbp]
\begin{center}
\subfloat[Calibration image on the front of the view guide.]{\label{fig:vizcardfront}}\includegraphics[width=5in]{figures/viewcardfront.jpg}
\subfloat[Data submission form on the back of the view guide.]{\label{fig:vizcardback}}\includegraphics[width=5in]{figures/viewcardback.jpg}
\caption{The visibility monitoring view guide.}
\label{fig:viewcard}
\end{center}
\end{figure}
Horizontally arranged images:
\begin{figure}[htpb]
\begin{center}
\subfloat[A plantcam at a monitoring plot.]{\label{fig:plantcam}}{\includegraphics[width=3in]{figures/plantcam.jpg}}
\hfill
\subfloat[A HOBO$\textsuperscript{\textregistered}$ data logger for air and soil data.]{\label{fig:logger}}{\includegraphics[width=3in]{figures/logger.jpg}}
\caption{Automatic data collection instruments.}
\label{fig:autodata}
\end{center}
\end{figure}
\end{document}
Any assistance will be very much appreciated!
Best Answer
Here are some suggestions to fix your current situation:
Note the
subfloat
notation:Since your
<body>
consisted only of a\label
command, the<subcaption>
(actually, the<LoF>
entry) had to wrap around something that is "very thin", causing it to not typeset properly. See page 4 of thesubfig
documentation for an explanation of this.Also, the
\label
should be included in the<body>
.If you put the entire
\subfloat
within a fixed-width environment, the caption will wrap according to that width. This can be achieved via aminipage
environment, for example. In the following minimal example, I've defined two new commands:that you can use to replace the traditional
\subfloat
.\vertfig
typesets its contents in a5in
-widthminipage
, while\horizfig
does so in a3in
-widthminipage
. Both dropped the second optional argument of\subfloat[..][..]{...}
, since it didn't seem to matter to you.As you can see, no fixed-width
\captionsetup
is required, since the captions wrap to the box they're contained in.geometry
was merely used to set the paper size toa3paper
.