Re: Error "Undefined control sequence. \chapter"
Verfasst: Mo 29. Aug 2022, 09:14
Oh, für die tatsächliche Lösung muss es natürlich:
heißen. Man beachte die Änderung bei \IfArgIsEmpty. Das betrifft auch das erste Beispiel. Ich wollte das aber nicht noch einmal posten.
\documentclass[chapterprefix]{scrreprt} % Changes the chapter mark in the header to "Chapter #:" instead % of "Chapter #": \renewcommand*{\chaptermarkformat}{\chapapp\nobreakspace\thechapter:\enskip} % Create Chapter Headings separated by a line and with upper case prefix line. \iffalse % change to \iftue to see the issue instead of a possible solution % OLD: Code with \MakeUppercase issue \usepackage{ifthen}% The old code uses package ifthen, which is not really % needed, because KOMA-Script provides \IfArgIsEmpty % and alternatively \Ifstr. However, we use the % original code and therefore have to load the package. \renewcommand{\chapterlineswithprefixformat}[3]{% % if the chapter is unnumbered (prefix is empty) \ifthenelse{\equal{#2}{}}% % then only show the title text {#3}% % else if chapter is numbered {% % set numeration in uppercase letters right-aligned {\raggedleft \MakeUppercase{#2}}\nobreak % create a line spanning the whole page \rule[.5\baselineskip]{\textwidth}{0.4pt}\\* % insert the title text #3 }% } \else % NEW: Code without \MakeUppercase issue and several improvements. \renewcommand*{\chapterformat}{\MakeUppercase{\chapapp~\thechapter\autodot}}% Uppercase prefix and number \renewcommand{\chapterlineswithprefixformat}[3]{% % if the chapter is unnumbered (prefix is empty) \IfArgIsEmpty{#2}% Das zweite Argument ist ggf. die Nummer oder leer! {#3}% then only show the title text {% else if chapter is numbered % set numeration right-aligned {\raggedleft #2\par}\nobreak % create a line spanning the whole page \raggedchapter\noindent% \noindent only needed, if \raggedchapter is empty \rule[.5\baselineskip]{\textwidth}{0.4pt}\par\nobreak #3% last but not least the title text (with optionally additional formatting }% } \fi \usepackage{blindtext}% Useful for small demonstration documents. \begin{document} \tableofcontents \blinddocument \end{document}