1

I am writing a report with the KOMA-Script class scrreprt. Below each chapter title, I am creating a rule which goes all the way to the end of the paper:

Example image

This actually works fine, but creates an overfull hbox warning at every chapter title:

Overfull \hbox (89.62619pt too wide) in paragraph

I am not very surprised by this warning, as I am creating a too wide box. The 89.62619pt is exactly the length between the right end of the paragraph and the end of the paper.

Is there a way to create such rules without creating overfull boxes? Or otherwise, is there a way to suppress this warning (but only for this rule in the chapter heading)?

Here is a MWE containing my redefinition of the chapter heading and a test case:

\documentclass{scrreprt}
\usepackage{calc}

\makeatletter
\renewcommand{\@makechapterhead}[1]{
    \hfill
    \begin{minipage}[b]{9cm}
        \raggedleft
        \sffamily\huge\textbf{#1}
    \end{minipage}
    \quad
    \sffamily\huge\textbf{\thechapter}
    \vskip 5\p@
    \noindent
    \rule{\paperwidth-\oddsidemargin-\hoffset-1in}{0.7pt}
    \vskip 20\p@
    \normalfont\normalsize
}
\makeatother

\begin{document}
    \chapter{A test chapter}
    Some example text.

    \chapter{Another very long chapter title which will break}
    Even more text.

\end{document}

Small comment: I am creating the minipage so chapter titles which are longer than one line also work correctly. If there is a better way of doing this, I am happy about suggestions.

1
  • you can just out \hspace{-\paperwidth} after the rule (or any length really:-) Also you are missing % from the ends of most lines in your definition. Sep 30, 2015 at 6:50

2 Answers 2

3

Here is only an additional suggestion how the chapter title could be formatted: With the new KOMA-Script Version 3.19 you can redefine \chapterlinesformat to change the layout of the chapter heading. This works also for unnumbered chapters like the table of contents.

\documentclass{scrreprt}[2015/09/29]

\RedeclareSectionCommand[
  beforeskip=0pt,
  afterskip=20pt,
  font=\huge
]{chapter}

\renewcommand\raggedchapter{\raggedleft}
\renewcommand\chapterformat{\thechapter}

\renewcommand\chapterlinesformat[3]{%
  \parbox[b]{\textwidth}{%
    \raggedchapter%
    \begin{minipage}[b]{9cm}
        \raggedchapter #3
    \end{minipage}%
    \ifstr{#2}{}{}{\quad#2}\\*
    \makebox[\textwidth][l]{\rule{\paperwidth}{.7pt}}%
  }%
}

\begin{document}
    \tableofcontents
    \chapter{A test chapter}
    Some example text.
    \chapter{Another very long chapter title which will break}
    Even more text.
\end{document}

Note that version 3.19 is already on CTAN and will be soon in TeXLive and MiKTeX. But you can also install the current version from the repository on the KOMA-Script Website.

enter image description here

enter image description here

1
  • Thanks a lot for this suggestion. I will think about switching to \chapterlinesformat once KOMA-Script 3.19 comes with standard installations.
    – hbaderts
    Sep 30, 2015 at 14:18
4

Your rule is extending in to the right margin and it is natural that it produces bad boxes. Put the rule inside a box of, say \textwidth to get rid of the bad box.

\documentclass{scrreprt}
\usepackage{calc}

\makeatletter
\renewcommand{\@makechapterhead}[1]{%
    \hfill
    \begin{minipage}[b]{9cm}
        \raggedleft
        \sffamily\huge\textbf{#1}
    \end{minipage}
    \quad
    \sffamily\huge\textbf{\thechapter}
    \vskip 5\p@
    \noindent
    \makebox[\textwidth][l]{\rule{\paperwidth-\oddsidemargin-\hoffset-1in}{0.7pt}}
    \vskip 20\p@
    \normalfont\normalsize
}
\makeatother

\begin{document}
    \chapter{A test chapter}
    Some example text.

    \chapter{Another very long chapter title which will break}
    Even more text.

\end{document}

enter image description here

1
  • Nice, I didn't know one can just specify a smaller box. Thank you very much.
    – hbaderts
    Sep 30, 2015 at 7:14

You must log in to answer this question.

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