0

due to the help of Ulrike in my question How to get long captions across pages I can now finally use extra long captions for my theses. Thanks again :-) The following code block is used for this for each picture:

\begin{figure}[H]
\includegraphics{largeImage}
\end{figure}
\bigskip
\setbox0\vbox{\makeatletter
\let\caption@rule\relax
\captionof{figure}[short caption]{\kant[1-4]}
\global\skip1\lastskip\unskip
\global\setbox1\lastbox
}
\unvbox0
\setbox0\hbox{\unhbox1\unskip\unskip\unpenalty
\global\setbox1\lastbox}
\unvbox1
\vskip\skip1

I need to use colored table rows in my thesis. As soon as I include the colortbl package with \include{colortbl} which is kind of best practice for that demand, my long text captions are always moved to the next page and I do not know why. Even if I don't use a command shipped with colortbl, the caption is simply moved to the next page instead of continuing there, here is the comparison.

with \usepackage{colortbl}:

With using \usepackage{colortbl} the page layout looks like this. Unfortunately the caption is completely moved to the next page which causes loss of space

without \usepackage{colortbl}:

Without using \usepackage{colortbl} the page layout looks like this. Everything is nice, the long caption is completely moved to the next page which causes loss of space

So, something strange happens when loading the package colortbl...

-> Is there an alternative to colortbl in order to have some background colors behind rows? I just found the idea to put a colored image in the background but that only applies to single cells, not to multicolumn rows (Texture or image as background for a single table cell).

-> Maybe something the package code itself can be changes / overridden in order to get rid of that issue (I don't have any idea why colors can have an impact to the page layout....) Although I am a Latex Beginner, I could try to have a look to the source code of the package but I cannot find the relevant file containing the actual package code (https://ctan.org/pkg/colortbl?lang=de)

Does anyone have an idea how to get colored table rows in combination with the long-captions fix from How to get long captions across pages

As requested, here is the MWE. As soon as you uncomment the \usepackage{colortbl} package the caption gets moved to the next page as already mentioned in How to get figure caption to span multiple pages, without having to switch everything to capt-of? by Willy Adler:

\RequirePackage{fix-cm}
\documentclass[a4paper,twoside,openright,headsepline,parskip]{scrreprt}
\usepackage[scaled=0.92]{helvet}
\usepackage{setspace}
\onehalfspacing
\usepackage[a4paper]{geometry}
\geometry{width=16cm, left=3cm, top=2.5cm, bottom=2.5cm}
\usepackage[headsepline]{scrpage2}
\pagestyle{scrheadings}
\lehead{\fontfamily{cmr}\textsc{Results}}
\rohead{\fontfamily{cmr}\textsc{Results}}
\usepackage[english]{babel}
\usepackage[nooneline]{caption}
\usepackage{graphicx}  
\usepackage[format=plain, font={small, singlespacing}, labelfont=bf]{caption}
\usepackage{kantlipsum}
\usepackage{float}
%\usepackage{colortbl}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\kant[1]

\begin{figure}[H]%
\includegraphics[scale=1.1]{example-image-c}
\end{figure}
\bigskip
\setbox0\vbox{\makeatletter
\let\caption@rule\relax
\captionof{figure}[short caption]{\kant[1-4]}
\global\skip1\lastskip\unskip
\global\setbox1\lastbox
}
\unvbox0
\setbox0\hbox{\unhbox1\unskip\unskip\unpenalty
\global\setbox1\lastbox}
\unvbox1
\vskip\skip1

\kant[6-7]

\end{document} 

kind regards,

Stephan

David Carlisle
  • 757,742

1 Answers1

0

The issue is unrelated to colortbl it is the color package. You need to disable color for the same reason that the existing code disabled the caption rule: color whatsits, like rule nodes may not be removed once added. This just adds \let\normalcolor\relax

\RequirePackage{fix-cm}
\documentclass[a4paper,twoside,openright,headsepline,parskip]{scrreprt}
\usepackage[scaled=0.92]{helvet}
\usepackage{setspace}
\onehalfspacing
\usepackage[a4paper]{geometry}
\geometry{width=16cm, left=3cm, top=2.5cm, bottom=2.5cm}
\usepackage[headsepline]{scrpage2}
\pagestyle{scrheadings}
\lehead{\fontfamily{cmr}\textsc{Results}}
\rohead{\fontfamily{cmr}\textsc{Results}}
\usepackage[english]{babel}
\usepackage[nooneline]{caption}
\usepackage{graphicx}  
\usepackage[format=plain, font={small, singlespacing}, labelfont=bf]{caption}
\usepackage{kantlipsum}
\usepackage{float}
\usepackage{color}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\kant[1]

\begin{figure}[H]%
\includegraphics[scale=1.1]{example-image-c}
\end{figure}
\bigskip
\setbox0\vbox{\makeatletter
\let\caption@rule\relax
\let\normalcolor\relax
\captionof{figure}[short caption]{\kant[1-4]}%
\global\skip1\lastskip\unskip
\global\setbox1\lastbox
}
\unvbox0
\setbox0\hbox{\unhbox1\unskip\unskip\unpenalty
\global\setbox1\lastbox}
\unvbox1
\vskip\skip1

\kant[6-7]

\end{document} 
David Carlisle
  • 757,742