[Tex/LaTex] Splitting figures’ caption apart

captionsfloats

I'm using stock figure environment and \caption{} command to typeset figures in my document. Is there any sane way I can get 'Figure N' part to be written right below the figure, and the actual caption's text above it?

The obvious hack with empty caption apparently works, but for my money it seems a bit awkward.

\begin{figure}
\center{Descriptive title string goes here}
\center\includegraphics[width=0.7\textwidth]{img/mw.png}
\label{monitor-main-window}
\caption{}
\end{figure}

I guess some environment or command needs to be (re)defined in order to change float layout, but I have vague idea where to start from.

Best Answer

Since the default behaviour is to typeset the caption text and numbering together, rather than break them apart, your hack works. It may just seem awkward since you're using \caption without actually giving a caption.

To that end, you could define "more convenient" commands that would do the same:

enter image description here

\documentclass{article}
\usepackage[demo]{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{caption}% http://ctan.org/pkg/caption
\captionsetup{labelsep=none,textfont=it}% Format caption settings
\newcommand{\floattitle}[1]{%
  \def\floattitletext{#1}% Store float title text
  \captiontextfont\strut #1\par\vskip\abovecaptionskip}
\newcommand{\floatnumber}{\caption[\floattitletext]{}}
\begin{document}
\begin{figure}
  \centering
  \floattitle{Descriptive title string goes here}
  \includegraphics[width=0.7\linewidth]{image}
  \floatnumber \label{monitor-main-window}
\end{figure}
\end{document}

The above example uses the caption package to format the float captions via key-value pairs. As such, you can use these key-values to format the separate components of the caption. I've defined \floattitle{<title>} which typesets the float title using \captiontextfont (it also stores <title> for later use). It also adds a gap at below the caption that is equivalent to the gap above the "actual caption" below the image. Also \floatnumber is a duplicate of \caption{}, which typesets nothing, but adds the correct reference test so you're able to use \listoffigures and/or \listoftables. Note that the command names are general, so you can use them in either a figure or a table environment.

Finally, for correct referencing, you need to place the \label after \floatnumber (or \caption in general). See Where to put the \label on a figure environment?

graphicx with the demo option was used to be able to typeset an image image without it actually being there - replacing it by a 150pt x 100pt rectangle. Don't use the demo option otherwise.