1

Dear LaTeX enthusiasts,

I have been trying to deal with a problem for days and I fear, it will still take me days if not months to find an answer myself -- if I ever find one at all. So I would very much appreciate your help.

My problem: I have adapted the definitions of headlines of chapter, section and so on to my needs -- and they now look just like I want them for the text, I am working at. One of my adaptions is, that I changed the color of the headlines.

But this change of color had an unwanted side effect: Now it can happen, that a lonely headline of section or subsection is seen at the very bottom of the page, the first line of text after that only appearing at the next page.

I have tried to write a minimum example:

\documentclass[12pt,fleqn,twoside]{report}%
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}%
\usepackage[ngerman,english]{babel}%
\usepackage{color}%
\usepackage[varumlaut]{yfonts}%  Oldstyle headlines
\usepackage{blindtext}%

%Adapted chapter headline
\makeatletter
\def\@makechapterhead#1{%
    \vspace*{-20\p@}%
    {\parindent \z@ \raggedright
        \large\textsc{\@chapapp\space \thechapter}
        \par\nobreak
        \interlinepenalty\@M
        \LARGE\color{blue} \textfrak{#1}\par\nobreak
%        \LARGE \textfrak{#1}\par\nobreak
        \vskip 20\p@
}}
\def\@makeschapterhead#1{%
    \vspace*{50\p@}%
    {\parindent \z@ \raggedright
        \interlinepenalty\@M
        \LARGE\color{blue} \textfrak{#1}\par\nobreak
%        \LARGE \textfrak{#1}\par\nobreak
        \vskip 40\p@
}}
\makeatother

%Adapted headlines of section and subsection
\makeatletter%
\renewcommand\section{%
    \@startsection {section}{1}{\z@}%
        {-3.5ex \@plus -1ex \@minus -.2ex}%
        {2.3ex \@plus.2ex}%
        {\color{blue}\large\frakfamily}}%
%        {\large\frakfamily}}%
%
\renewcommand\subsection{%
    \@startsection{subsection}{2}{\z@}%
        {-3.25ex\@plus -1ex \@minus -.2ex}%
        {1.5ex \@plus .2ex}%
        {\color{blue}\frakfamily}}%
%        {\frakfamily}}%
\makeatother%


\begin{document}
    \chapter{The chapter}
    \blindtext[2]\\%
    text\\
    text\\
    text\\
    text\\
    text\\
    text\\
    text\\
    text\\
    text\\
    text\\
    \section{The section}
    \subsection{The subsection}
    \blindtext
    
\end{document}    

It is not perfect though: I can't provoke it to only show a section headline directly followed by text to be interrupted by a pagebreak. But I managed to provoke a pagebreak between section headline and subsection headline.

Chapter headlines never are a problem up to now -- probably as their definition is quite different as well. For experimentation purposes I have given the lines without the color definition as well -- if you use them, the appearance of the text alters a bit and the problem can not be reproduced, even if you add some "text\\" lines.

My questions:

  1. Why is coloration of headlines altering the appearance of the text?
  2. What can I do for not having a pagebreak directly after a (section/subsection/subsubsection/paragraph) headline?

Can anybody help me?

1 Answer 1

1

Avoid adding color whatsit nodes in vmode

\renewcommand\subsection{%
    \@startsection{subsection}{2}{\z@}%
        {-3.25ex\@plus -1ex \@minus -.2ex}%
        {1.5ex \@plus .2ex}%
        {\everypar{\color{blue}\frakfamily}}%
6
  • Dear David, thank you very much: That solves most of my problems! The remaining ones are not covered by my minimum example. They occur, if directly after the headline my selfwritten macro \initiale is used. \initiale I defines as \newcommand\initiale[2][4.6]{ \ifx{#1}0\else\needspace{#1\baselineskip}\fi% \yinipar{\raisebox{0.6\baselineskip}{\hspace*{-4pt}\color{bildfarbe}#2\hspace*{4pt}}}}%
    – ThorstenL
    May 26 at 21:36
  • I first thought, the problem might be \needspace, so I gave it an optional argument, which, if 0, leaves out the \needspace (i.e. every initial directly after a headline is written \initiale[0]), but unfortunately that doesn't help ...
    – ThorstenL
    May 26 at 21:46
  • \ifx{#1 is testing if #1 starts with { you probably did not intend that. @ThorstenL May 26 at 22:55
  • No ... not really ... so how should I test, whether#1 is equal 0?
    – ThorstenL
    2 days ago
  • \ifnum#1=0 yes\else no\fi 2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .