2

I'm using the scrbook class from the KOMA-Script bundle, and I've run into a problem when using longtable.

When I use a normal tabular environment that spans multiple pages, everything works fine — the running head (e.g., chapter title in the page header) is displayed correctly.

However, when I use the longtable environment for tables that span multiple pages, the running head on the second and following pages displays the chapter title from the previous chapter, not the current one. It seems like longtable is interfering with how KOMA-Script determines the running head content.

Here is a minimal working example (MWE)

\documentclass[english,twoside,headsepline]{scrbook} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{longtable} \begin{document} \frontmatter \addchap{Addchap 1} \begin{tabular}{|c|c|} \hline Simple Table Entry & \\ \hline & \\ % ... repeated rows ... \hline \end{tabular} \mainmatter \addchap{Addchap 2} \begin{longtable}{|c|c|} \hline Long Table Entry & \\ \hline & \\ % ... enough rows to span multiple pages ... \hline \end{longtable} \end{document} 
  1. Using \markboth{Addchap 2}{Addchap 2} before the longtable, didn't fix it.
  2. Loading scrlayer-scrpage with \ihead{\leftmark}, the problem persists.
  3. Changing to \mainmatter before the second chapter, no effect

What I’m asking

  • Is this a known incompatibility between KOMA-Script and longtable?
  • Is there a workaround or recommended way to ensure the running head reflects the correct chapter when longtable spans multiple pages?
1
  • 1
    I don't quite see the issue in your MWE. Commented Aug 22 at 12:22

1 Answer 1

2

As explained in David's answer to a similar question this is a bug in longtable and unrelated to using scrbook. However, his workaround also helps, when using longtable with scrbook, because scrbook does not change anything in the mark mechanism of LaTeX:

\documentclass[ %english,% option commented, because neither the class nor any package in the example uses it %twoside,% option commented, because it is the scrbook default headsepline,% Note: option irrelevant for the problem. ]{scrbook} \usepackage[T1]{fontenc}% Note: Don't use this with LuaLaTeX or XeLaTeX. \usepackage[utf8]{inputenc}% Note: should not be needed anymore. \usepackage{longtable} % Workaround for longtable bug → https://tex.stackexchange.com/a/747157/277964 \makeatletter \providecommand\@expl@@@mark@update@singlecol@structures@@{}% for old latex \def\LT@output{% \ifnum\outputpenalty <-\@Mi \ifnum\outputpenalty > -\LT@end@pen \LT@err{floats and marginpars not allowed in a longtable}\@ehc \else \setbox\z@\vbox{\unvbox\@cclv}% \ifdim \ht\LT@lastfoot>\ht\LT@foot \dimen@\pagegoal \advance\dimen@\ht\LT@foot \advance\dimen@-\ht\LT@lastfoot \ifdim\dimen@<\ht\z@ \setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}% \@makecol \@expl@@@mark@update@singlecol@structures@@ \@outputpage \global\vsize\@colroom \setbox\z@\vbox{\box\LT@head}% \fi \fi \unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi \UseTaggingSocket{tbl/longtable/foot}% \fi \else \setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}% \UseTaggingSocket{tbl/longtable/foot}% \@makecol \@expl@@@mark@update@singlecol@structures@@ \@outputpage \global\vsize\@colroom \copy\LT@head\nobreak \fi} \makeatother \begin{document} \frontmatter \addchap{Addchap 1} \begin{tabular}{|c|c|} \hline Simple Table Entry & \\ \hline & \\ % ... repeated rows ... \hline \end{tabular} \mainmatter \addchap{Addchap 2} \begin{longtable}{|c|c|} \hline Long Table Entry & \\ \hline & \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \hline \end{longtable} \end{document} 

BTW: As my example proofs, it is not really complicated to add enough dummy rows to a MWE. So please next time try to show a ready-to-use minimal working example → I've just been asked to write a minimal working example (MWE), what is that?.

6
  • 61: Infinite glue shrinkage found in box being split. \end{longtable} : inputenc package ignored with utf8 based engines. : [english]. : No file texstudio_pRMAqX.aux. Commented Aug 22 at 12:36
  • @AymenLeslous With exactly my example? Here, with an today updated TeX Live 2025 I've no such error. Even not, when using LuaLaTeX. But when using LuaLaTeX or XeLaTeX you should remove inputenc and also fontenc. Moreover, \usepackage[utf8]{inputenc} should not be needed for more than a decade. Commented Aug 22 at 12:40
  • Thank you for your response. You're right — with LuaLaTeX or XeLaTeX, inputenc and fontenc aren't needed and are ignored. I had them out of habit, but they don't affect the output here. The actual issue is: "61: Infinite glue shrinkage found in box being split." This seems to be caused by the content inside the longtable, not by the encoding setup. I'm still checking if it’s due to excessive glue shrink/stretch. Appreciate the clarification! – Aymen Leslous Commented Aug 22 at 19:03
  • @AymenLeslous As told above: Using an up-to-date TeX Live 2025 there isn't any error with the example I've shown. So if you have an error, you should as a new question and show a MWE that can be used to reproduce the error. Commented Aug 22 at 19:25
  • In my case, the code compiles without any issues in TeXworks, but I get the following warning only when using TeXStudio (or a similar editor). ! Infinite glue shrinkage found in box being split. <argument> Infinite shrink error above ignored ! l.188 \end{longtable}. I'm using an up-to-date TeX Live 2025 distribution, and there are no actual errors when compiling via TeXworks. Commented Aug 22 at 20:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.