1

I'm trying to get my document to be free of warnings. One of them is

Usage of package `titlesec' together(scrreprt) with a KOMA-Script class is not recommended.
Non standard sectioning command detected(titlesec) Using default spacing and no format.

I already changed the layout so I'm not using titleformat anymore. The code still does'nt work without \usepackage{titlesec} though.. What am I missing?

\documentclass[11pt, a4paper]{scrreprt}

\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{titlesec}
%\usepackage[headsepline, automark]{scrlayer-scrpage}

% \titleformat{\chapter}[display]     % {command}[shape]
%   {\usekomafont{chapter}\filcenter} % format
%   {                                 % label
%   {\fcolorbox{black}{shadecolor}{
%   {\huge\chaptertitlename\mbox{\hspace{1mm}}\thechapter}
%   }}}
%   {1pc}                             % sep (from chapternumber)
%   {\vspace{1pc}}                    % {before}[after] (before chaptertitle and after)

\KOMAoptions{chapterprefix}

\renewcommand{\chapterheadmidvskip}{%
    \vspace{12pt}
}
\setkomafont{chapter}{\Large\color{black}}
\renewcommand{\chapterlineswithprefixformat}[3]{%
    \parbox{\dimexpr\linewidth-2\fboxrule-2\fboxsep}{%
        #2 \vspace{.9pc}
        \hrule height 1pt \vspace{2pc}
        #3 \vspace{1.2pc}\hrule height 1pt%
    }
}
\renewcommand{\chapterheadmidvskip}{}
\renewcommand{\chapterformat}{%
    \mbox{\LARGE\MakeUppercase{Kapitel}\Huge~\thechapter\filright%
    }
}

\begin{document}
    \chapter{test}
    \blindtext
\end{document}
1
  • Did'nt think it would be this easy :D Thank You!
    – newToLaTeX
    Mar 5, 2018 at 14:17

1 Answer 1

2

As @campa mentioned in a comment \filright is defined by package titlesec.

Here are some additional suggestions: Do not redefine \chapterheadmidvskip (this is done twice in your MWE). Instead set innerskip using \RedeclareSectionCommand. Add \raggedchapter inside the \parbox in the redefinition of \chapterlineswithprefixformat.

\documentclass[ngerman]{scrreprt}% 11pt and paper=a4 are default

\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{babel}
\usepackage[headsepline, automark]{scrlayer-scrpage}

\KOMAoptions{chapterprefix}

\RedeclareSectionCommand[
  innerskip=0pt,
  font=\Large\color{black},
  prefixfont=\LARGE
]{chapter}

\renewcommand{\chapterlineswithprefixformat}[3]{%
  \ifstr{#1}{chapter}{% <- change the layout for chapters
    \parbox{\dimexpr\linewidth-2\fboxrule-2\fboxsep}{%
        \raggedchapter% <- added (default meaning is \raggedright)
        #2 \vspace{.9pc}
        \hrule height 1pt \vspace{2pc}
        #3 \vspace{1.2pc}\hrule height 1pt%
    }%
  }{%
    #2#3% original definition for other levels with style=chapter
  }
}

\renewcommand{\chapterformat}{%
    \MakeUppercase{\chaptername}\Huge~\thechapter
}

\begin{document}
\chapter{test}
\blindtext
\Blinddocument
\end{document}

enter image description here

2
  • I see this kind of 'screenshot' for pdfs fairly often of tex.se. How do you guys make them? I guess everybody makes them with the same routine, as the design is pretty consistent, but what is it?
    – thymaro
    Mar 5, 2018 at 21:24
  • @thymaro I use SnippingTool.exe (part of the Windows installation).
    – esdd
    Mar 6, 2018 at 11:37

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.