0

I know there are a lot of questions like this everywhere, but i didn't find an answer to this: I have a figure with a lot of figures inside (a-e, build in MS powerpoint (not in latex)). Means my caption is quite long, so that it does not fit on one page and the caption goes through the page number etc. Is there an easy way to solve this?

example:

\documentclass[12pt,a4paper]{scrartcl}

\usepackage{graphicx}

\begin{document}
    text text text
    \begin{figure}
        \includegraphics[width=1\textwidth]{file.png}
        \caption[short]{damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption...}
        \label{fig:file}
    \end{figure}
\end{document}

thanks for any help

  • 1
    a figure has to fit on one page, so you could shrink the image, or use a smaller font for the text or (perhaps) sneak in a negative \vspace to steal some space from the page head or (perhaps?) change the wording of the caption... Only you can decide – David Carlisle Apr 26 '19 at 11:50
  • See also tex.stackexchange.com/questions/280998/… – John Kormylo Apr 26 '19 at 12:28
1

With \ContinuedFloat from the caption package one can manually split it in two. The risk is that one or both floats will change position, so I strongly suggest to fix their position with the [H] key from the float package

\documentclass[12pt,a4paper]{scrartcl}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{float}

\begin{document}
    text text text
    \begin{figure}[H]
        \includegraphics[width=1\textwidth]{example-image}
        \caption[short]{damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long  caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption...\\[0.2em]
        continues on next page
        }
        \label{fig:file}
    \end{figure}

    \begin{figure}[H]
        \ContinuedFloat
        \caption[]{
        continued from previous page\\[0.2em]
        ....caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption, damn long caption...}
    \end{figure}

\end{document}
  • don't do this. better is to consider @David comments below question. or move table explanation to the document text. – Zarko Apr 26 '19 at 12:07
  • @Zarko Why not? As long as one makes sure that the figures don't move away I don't see a problem. – user187610 Apr 26 '19 at 12:12
  • @Jonathan See tex.stackexchange.com/questions/469880 – Peter Wilson Apr 26 '19 at 17:27
  • @PeterWilson Yes, in general disabling floating is disadvantages, but for manually selecting the break point, it is essential. Every other behaviour would render the efforts useless. – user187610 Apr 26 '19 at 18:42
1

The caption itself cannot be split, but the text can be, at least when using hanging indentation.

This is a demonstration of concept. You would probably want to turn this into an macro or environment, depending on how you want to handle the image, caption and short caption.

Note that \vsplit likes to use \vbox while \caption prefers \vtop. Also, the height of \captionsave is 0pt, hence the \raisebox.

I should give credit to Jonathon for the \ContinuedFloat.

\documentclass[12pt,a4paper]{scrartcl}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{blindtext}% MWE only

\newsavebox{\captionsave}

\begin{document}
    \begin{figure}[p]
        \sbox0{\includegraphics[width=1\textwidth]{example-image}}% measure height
        \usebox0
        \sbox1{\csname fnum@figure\endcsname :~}% caption label
        \setlength{\dimen0}{\dimexpr \columnwidth-\wd1}% width of caption minus label
        \setbox1=\vbox{\hsize=\dimen0
          \blindtext[3]}% text part of caption
        \dimen1=\dimexpr \textheight-\ht0-\abovecaptionskip-\belowcaptionskip\relax
        \ifdim\dimen1<\ht1
          \setbox2=\vsplit1 to \dimen1
          \global\setbox\captionsave=\vtop{\unvbox1}%
          \setbox0=\vtop{\unvbox2}%
        \else
          \setbox0=\vtop{\unvbox1}%
          \global\setbox\captionsave=\box1 %empty
        \fi
        \caption[short caption]{\usebox0}
        \label{fig:file}
    \end{figure}
    \ifdim\dp\captionsave>0pt
      \begin{figure}[t]
        \ContinuedFloat
        \caption[]{\textbf{Continued...}\newline\raisebox{\ht\strutbox}{\usebox\captionsave}}
      \end{figure}
    \fi
\end{document}

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.