2

I'm using scrreprt, and I want chapter headings to be formatted like in this question: Chapter number in left right margin ...with one small change. How can I get the number to be aligned with the bottom line of the multi-line chapter title rather than the first line?

It seems like this should be a simple change, but I don't understand the answer given there well enough to know what to change.

Thanks!

2 Answers 2

3

Since KOMA-Script version 3.19 you can redefine \chapterlinesformat to use a bottom aligned parbox:

\documentclass[
  fontsize=12pt,
  twoside,
  ngerman,
  parskip=half,
  headings=big,
  open=right
]
{scrreprt}[2015/10/03]

\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}

\usepackage{blindtext}% dummy text

\DeclareMathAlphabet\EuRoman{U}{eur}{m}{n}
\SetMathAlphabet\EuRoman{bold}{U}{eur}{b}{n}
\newcommand{\eurom}{\EuRoman}

\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
  \sbox\feline@chapter{%
    \resizebox{!}{#1}{\setlength{\fboxsep}{0pt}%
        \colorbox{white}{\color{black}$\eurom\thechapter$}}}%
  \raisebox{\depth}{\usebox{\feline@chapter}}%
}
\renewcommand*{\chapterformat}{\feline@chapter@marker[1.61cm]}

\renewcommand\chapterlinesformat[3]{%
  \ifstr{#1}{chapter}
  {%
    \makebox[\textwidth][l]{%
      \parbox[b]{\textwidth}{\raggedchapter #3}%
      \hspace*{\marginparsep}#2%
    }\\*[-.5\baselineskip]
    \rule{\textwidth}{.4pt}%
    \par%
  }
  {\@hangfrom{#2}{#3}}%
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Lorem ipsum dolor sit amet, consectetuer adipiscing elit}
\blindtext[2]
\end{document}

enter image description here

0
1

Maybe it is a simple change if one knows the internals of this particular class. I don't, but I can offer a less elegant solution until some more knowledgable person comes around.

Take the code from the answer that you mentioned, and add the following definition before \begin{document}.

\newcommand\mychapter[2][\mychapterheading]%
  {\def\mychapterheading{#2}%
   \chapter[#1]{\parbox[b]{\linewidth}{#2}}%
  }

As an example consider the following document.

... Code from the other posting up to \begin{document} ...
... Definition of \mychapter above
\begin{document}
\tableofcontents
\chapter{Lorem ipsum dolor sit amet, consectetuer adipiscing elit}
\mychapter{Lorem ipsum dolor sit amet, consectetuer adipiscing elit}
\mychapter{Lorem ipsum dolor sit amet,\\consectetuer adipiscing elit}
\mychapter[Lorem ipsum dolor sit amet, consectetuer adipiscing elit]%
          {Lorem ipsum dolor sit amet,\\consectetuer adipiscing elit}
\end{document}

This leads to the following table of contents and chapter headings:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

The heading of the first chapter is formatted according to the original chapter definition. The second one uses the new definition, but leaves line breaking to LaTeX. The third one contains a manual break, that is also used for the table of contents. Finally, the fourth example also contains a manual break, but the optional argument of the new command contains the chapter heading without line break, which is what goes into the table of contents.

You must log in to answer this question.

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