5

I'm using the \MakeUppercase command (from \textcase) (but also tried \MakeTextUppercase cos I thought the problem might be caused by the math-environment of the chapter number) and the \addtokomafont{chapter}{...} command to set up the Koma-script report class. My MWE is based on the following thread. Unfortunately, adding \MakeUppercase to \addtokomafont{chapter}{\normalsize\scshape} doesn't compile with the changed chapter format but it does without, does some one have an idea how to solve the problem?

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

\usepackage[english,german]{babel}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{blindtext}
%\usepackage{showframe}

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

\usepackage{textcase}

\setkomafont{sectioning}{\rmfamily} 
\setkomafont{caption}{\small}                                                   
\setkomafont{captionlabel}{\sffamily\bfseries\small}    
\setkomafont{chapterentry}{\small\bfseries}                     
\setkomafont{chapter}{\normalsize}      
\setkomafont{section}{\normalsize}                                      
\setkomafont{subsection}{\normalsize}                                   

\addtokomafont{chapter}{\normalsize\scshape}%%%%%%%%%     \MakeUppercase
\addtokomafont{section}{\normalsize\scshape\MakeTextLowercase}
\addtokomafont{subsection}{\normalsize\itshape}     


% Define own Chapter style
% Pretty chapter pages
%------------------------------------------
\definecolor{nicered}{rgb}{.647,.129,.149}
\usepackage{pdfpages}
\usepackage{etoolbox}
\usepackage{fancyhdr}

\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
  \sbox\feline@chapter{%
    \resizebox{!}{#1}{\setlength{\fboxsep}{0pt}%
        \colorbox{white}{\color{black}$\eurom\thechapter$}}}%!!!!!Error?
  \raisebox{\depth}{\usebox{\feline@chapter}}%
}
\renewcommand*{\chapterformat}{%
  \sbox\feline@chapter{\feline@chapter@marker[1.61cm]}%
  \makebox[0pt][l]{%
    \makebox[\dimexpr\textwidth+\marginparsep+\wd\feline@chapter\relax][r]{%
      \usebox\feline@chapter}}%
}
\makeatother

\preto\chapterheadendvskip{%
  \vspace*{-\parskip}%
  {\setlength\parfillskip{0pt plus 1fil}\rule{\textwidth}{.4pt}\par}%
}


\begin{document}
\tableofcontents
\chapter{Lorem ipsum dolor sit amet, consectetuer}
\blindtext[2]
\section{Lorem ipsum dolor sit amet, consectetuer}
\end{document} 
  • I am pretty pretty sure that i have read that very same question earlier today, it even had a helpful answer. I bet the person who wrote the answer is not very happy to see his effort wasted by deleting the whole thread. – Johannes_B Sep 9 '15 at 17:31
  • 1
    I wonder if there is a better way but one could patch \scr@makechapterhead and \scr@makeschapterhead – clemens Sep 9 '15 at 20:36
  • BTW: you're missing to load fontenc – is that on purpose? Also you load german instead of ngerman with babel which means you have old spelling instead of the new (no so new anymore) one. – clemens Sep 9 '15 at 20:41
  • Do you mind to explain to me what do you think is causing the error? It seems not to be the interaction of the chapter number (in math mode) and \MakeUppercase as I thought (cos even be editing this part I still get the same error message). – jlk Sep 9 '15 at 21:02
  • @harryhaller if you want to notify someone ping them with a @ followed by the user name. The problem is that after the chapter font is inserted what follows isn't the corresponding heading directly but a whole bunch of internal commands. So \MakeTextUppercase (or whatever) acts on a lot more than just the heading. – clemens Sep 10 '15 at 10:09
7

This is possible with KOMA-Script version 3.19 or newer. In version 3.19 the new commands \chapterlinesformat and \sectionlinesformat have been introduced. They are explained in the KOMA-Script documentation.

Here is a suggestion using these commands:

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

\usepackage[english,german]{babel}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{blindtext}
%\usepackage{showframe}

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

\usepackage{textcase}

\setkomafont{sectioning}{\rmfamily} 
\setkomafont{caption}{\small}                                                   
\setkomafont{captionlabel}{\sffamily\bfseries\small}    
\setkomafont{chapterentry}{\small\bfseries}                     
\setkomafont{chapter}{\normalsize}      
\setkomafont{section}{\normalsize}                                      
\setkomafont{subsection}{\normalsize}                                   

\addtokomafont{chapter}{\normalsize\scshape}
\addtokomafont{section}{\normalsize\scshape}
\addtokomafont{subsection}{\normalsize\itshape}     


% Define own Chapter style
% Pretty chapter pages
%------------------------------------------
\definecolor{nicered}{rgb}{.647,.129,.149}
\usepackage{pdfpages}
\usepackage{etoolbox}
\usepackage{fancyhdr}

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

\renewcommand\chapterlinesformat[3]{%
    \parbox[t]{\textwidth}{\raggedchapter\MakeUppercase{#3}}%
    #2%
    \\\rule{\textwidth}{.4pt}
}

\renewcommand*{\sectionlinesformat}[4]{%
  \@hangfrom{\hskip #2#3}{\ifstr{#1}{section}{\MakeTextLowercase{#4}}{#4}}%
}
\makeatother

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

Result

enter image description here

enter image description here

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.