0

I am using the Cleanthesis LaTeX style, which is itself based in the Koma-Script 'report' class, and sometimes I see page breaks directly after a \section or \subsection. I have not been able to reproduce this without using Cleanthesis but it is fairly easy to reproduce it with Cleanthesis.

In order to reproduce it, create an example.tex file with the following contents:

\chapter{Chapter}

\section{Section}

\subsection{Subsection}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

\section{Section 2}

\subsection{Subsection 2}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Then edit the default my-thesis.tex to include only this file:

[...]
%\input{content/chapter-introduction}   % INCLUDE: introduction
%\input{content/chapter-related-work}   % INCLUDE: related work
%\input{content/chapter-system}         % INCLUDE: system
%\input{content/chapter-concepts}       % INCLUDE: concepts
%\input{content/chapter-conclusion}     % INCLUDE: conclusion
\input{example}
[....]

The result looks like this:

enter image description here

Any hints on why this may be happening or how to fix it ?

  • Sure but that's very fragile. I don't want to manually edit a 100+ page document and add \clearpage command which will be wrong as soon as the text changes. – Grodriguez Oct 18 '17 at 16:16
  • 1
    cleanthesis uses titlesec to format the section titles. So it disables most of the KOMA-Script features regarding the section titles. I am sure that you get warnings. – esdd Oct 18 '17 at 16:18
  • ah OK (I'll delete my comments then:-) – David Carlisle Oct 18 '17 at 16:40
  • Does the issue happen with the develop branch? – Johannes_B Oct 22 '17 at 7:03
  • Yes it did. It is now fixed (I submitted a patch which has been meged: github.com/derric/cleanthesis/pull/89) – Grodriguez Oct 23 '17 at 9:25
4

If you add the following code after loading cleanthesis, KOMA-Script will controll the section and subsection headings again.

\RedeclareSectionCommand[
  beforeskip=-.75em,
  afterskip=.2em%
]{section}
\addtokomafont{section}{\mdseries}
\renewcommand\sectionformat{\textcolor{ctcolorblack}{\thesection}\hspace*{10pt}}
\RedeclareSectionCommand[
  beforeskip=-.5em,
  afterskip=1sp%
]{subsection}
\addtokomafont{subsection}{\mdseries}
\renewcommand\subsectionformat{\textcolor{ctcolorblack}{\thesubsection}\hspace*{10pt}}

enter image description here

Code:

\documentclass[%
  paper=A4,                 % paper size --> A4 is default in Germany
  twoside=true,             % onesite or twoside printing
  openright,                    % doublepage cleaning ends up right side
  parskip=full,             % spacing value / method for paragraphs
  chapterprefix=true,           % prefix for chapter marks
  11pt,                     % font size
  headings=normal,          % size of headings
  bibliography=totoc,           % include bib in toc
  listof=totoc,             % include listof entries in toc
  titlepage=on,             % own page for each title page
  captions=tableabove,      % display table captions above the float env
  draft=false,              % value for draft version
]{scrreprt}%

\usepackage[utf8]{inputenc}     % defines file's character encoding
\usepackage[english]{babel} % babel system, adjust the language of the content
\usepackage[                    % clean thesis style
  figuresep=colon,%
  sansserif=false,%
  hangfigurecaption=false,%
  hangsection=true,%
  hangsubsection=true,%
  colorize=full,%
  colortheme=bluemagenta,%
  bibsys=bibtex,%
  bibfile=bib-refs,%
  bibstyle=alphabetic,%
]{cleanthesis}

\RedeclareSectionCommand[
  beforeskip=-.75em,
  afterskip=.2em%
]{section}
\addtokomafont{section}{\mdseries}
\renewcommand\sectionformat{\textcolor{ctcolorblack}{\thesection}\hspace*{10pt}}
\RedeclareSectionCommand[
  beforeskip=-.5em,
  afterskip=1sp%
]{subsection}
\addtokomafont{subsection}{\mdseries}
\renewcommand\subsectionformat{\textcolor{ctcolorblack}{\thesubsection}\hspace*{10pt}}

\begin{document}
\pagestyle{maincontentstyle}    % fancy header and footer
\chapter{Chapter}

\section{Section}

\subsection{Subsection}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

\section{Section 2}

\subsection{Subsection 2}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}
| improve this answer | |
  • I wonder why is all of this actually needed. The problem apparently does not come from the use of the titlesec package per se, but from the use of \color with \setkomafont in cleanthesis. And it can be easily fixed by switching from \color to \textcolor, or by just adding \nobreak, without having to completely redefine the sectioning commands. BTW if you wanted to redefine these commands it would not be just the section and subsection headings -- it would be all of them down to the paragraph level. – Grodriguez Oct 20 '17 at 10:03
1

OK looks like this is caused by the use of \color with \setkomafont in Cleanthesis. Similar problems are described here:

I have been able to fix this by adding \nobreak after \color in cleanthesis.sty. Here's a Github pull request including the fix:

https://github.com/derric/cleanthesis/pull/89

Update: The above pull request has now been merged into cleanthesis' Github repo.

| improve this answer | |

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.