3

In a two-column document, I have a figure that span almost the whole column, leaving not enough room for the caption in the remaining part of the column. Therefore, I want the caption to continue in the next column. I've tried several approaches including \captionof and \contcaption (package ccaption) and haven't been able to achieve the desired result. I've been able to move the whole caption to the next column, but the editorial staff of the journal I'm submitting to (The Cryosphere) have rejected that solution. I've edited a capture of my document in photoshop to illustrate the desired result: enter image description here

I would like to provide a generic minimal working example, but I'm tied to the journal-provided document class. The files associated to the document class together with the MWE can be downloaded here. The content of the MWE is the following:

\documentclass[journal abbreviation]{copernicus}

%% \usepackage commands included in the copernicus.cls:
%\usepackage[german, english]{babel}
%\usepackage{tabularx}
%\usepackage{cancel}
%\usepackage{multirow}
%\usepackage{supertabular}
%\usepackage{algorithmic}
%\usepackage{algorithm}
%\usepackage{amsthm}
%\usepackage{float}
%\usepackage{subfig}
%\usepackage{rotating} 

\usepackage{blindtext}%Only used in this minimal example

\begin{document}

\begin{figure}[t]
\includegraphics[width=\columnwidth, height=0.9\textheight]{example-image}
\caption{\blindtext[2]}
\end{figure}

\blindtext[5]

\end{document}

if the image were smaller (for example 0.6\textheight) it looks like this: enter image description here

However for a long image (0.9\textheight) it looks like this enter image description here

And I need the figure to stay in the left column and the caption to continue in the right column as shown in the first image.

Any clues on how to achieve that?

  • Welcome to TeX.SX! – Bobyandbob May 22 '18 at 7:27
  • Have you seen How to put a figure in one column and its caption in another column in a two column article latex? Does it help? Otherwise it is always a good idea to add a minimal working example (MWE) to the question, that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier with compilable code. – Bobyandbob May 22 '18 at 8:25
  • One can use \vsplit to separate a caption into two parts, provided you know how much space is left in the first column. You will have to insert the \vsplit inside \@makecaption (which is package dependent) and save the second half globally. – John Kormylo May 22 '18 at 12:53
  • @Bobyandbob Thanks for the comment. I tried that, but the editorial staff of the journal rejected that option. They want the legend starting at the bottom of the figure. I've added a MWE and some screenshots of the outputs. I hope that helps. Thanks! – Camilo Rada May 22 '18 at 20:27
  • @JohnKormylo I'm afraid I will need a more detailed explanation than that, sorry. I don't know how to add something inside \@makecaption. I've tried adding \vsplit inside \caption and I get errors. I've added a MWE and some screenshots, I hope that helps. Thanks! – Camilo Rada May 22 '18 at 20:29
1

Note that copernicus.cls defines its own \@makecaption.

This solution adds two commands: \splitcaption and \mergecaption. \splitcaotion adds an argument for the available space remaining (which you must compute), \mergecaption creates a new figure to handle the remainder of the caption (if any). It should be used immediately after the original figure environment (NOT inside).

One can use \afterpage to force the figure into the left column. Note: \afterpage does not work with \blindtext, probably as it forms one huge paragraph.

\documentclass[journal abbreviation]{copernicus}

%% \usepackage commands included in the copernicus.cls:
%\usepackage[german, english]{babel}
%\usepackage{tabularx}
%\usepackage{cancel}
%\usepackage{multirow}
%\usepackage{supertabular}
%\usepackage{algorithmic}
%\usepackage{algorithm}
%\usepackage{amsthm}
%\usepackage{float}
%\usepackage{subfig}
%\usepackage{rotating} 

\usepackage{blindtext}%Only used in this minimal example
\usepackage{lipsum}%forms paragraphs
\usepackage{afterpage}

\newsavebox{\splitcaptionbox}
\newlength{\splitcaptionheight}
\makeatletter
\long\def\@makesplitcaption#1#2{% see \@makecaption from copernicux.cls (figure only)
  \if@stage@final
    \vskip0.7\abovecaptionskip
    \addtolength{\splitcaptionheight}{-0.7\abovecaptionskip}%
  \else
    \vskip\abovecaptionskip\goodbreak
    \addtolength{\splitcaptionheight}{-\abovecaptionskip}%
  \fi
  \setbox\splitcaptionbox=\vbox{\interlinepenalty 0
    \reset@font\small{\bfseries#1.} #2\par}%
  \vsplit\splitcaptionbox to \splitcaptionheight
  \global\setbox\splitcaptionbox=\box\splitcaptionbox
  \if@cop@home\ifonline\ifnum\csname c@\@captype\endcsname=1 % for 1st fig or tab only
    \immediate\write\@auxout{\string\gdef\string\@num\@captype{}}%
    \hypertarget{\@captype}{}%
  \fi\fi\fi}

\newcommand{\splitcaption}[3][\empty]% #1=short caption (optional), #2=caption, #3=remaining height
 {\setlength{\splitcaptionheight}{#3}%
  \let\cop@makecaption=\@makecaption
  \let\@makecaption=\@makesplitcaption
  \ifx\empty#1\relax
    \caption{#2}%
  \else
    \caption[#1]{#2}%
  \fi
  \let\@makecaption=\cop@makecaption}
\makeatother

\newcommand{\mergecaption}{\ifdim\ht\splitcaptionbox>0pt
  \begin{figure}[tp]
  \box\splitcaptionbox
  \end{figure}
\fi}

\begin{document}

\afterpage{\begin{figure}[p]
\includegraphics[width=\columnwidth, height=0.9\textheight]{example-image}
\splitcaption{\blindtext}{0.1\textheight}
\end{figure}%
\mergecaption}

\lipsum[1-12]

\end{document}

full page

  • Great answer! Thanks a lot, I really appreciate the time you took to answer. I would just add that the \label tag must go inside \splitcaption, otherwise it is not properly recognized. It took me a while to figure that out. Thanks again! – Camilo Rada May 23 '18 at 18:49
  • 1
    That's due to the \bgroup ... \egroup. I might be able to fix that. – John Kormylo May 23 '18 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.