3

I would like to move the chapter number in the right margin (a bit like in the classicthesistheme) but all I tried just results in errors, it would be nice if some could have a look. My MWE is using scrreprt and I can't move to the memoir class.

MWE

classic thesis

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

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

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

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

\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
    \sbox\feline@chapter{%
        \resizebox{!}{#1}{\fboxsep=-0pt%\eurom{A}
            \colorbox{white}{\color{black}$\eurom{\thechapter}$}}}%
%       \rotatebox{90}{%
%           \resizebox{%
%               \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
%           {!}{\scshape\so\@chapapp}}\hspace{.4mm}%Abstand zum Wort Kapitel
        \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
    }


            \newcommand\feline@chm[1][4cm]{%
                \sbox\feline@chapter{\feline@chapter@marker[#1]}%
                \makebox[0pt][l]{% aka \rlap
                    \makebox[1cm][r]{\usebox\feline@chapter}%
                }
            }      

        \renewcommand*{\chapterformat}{%
            \hspace{\leftmargin} \feline@chm[1.61cm] % Height of the colored box
            \hspace{0.3cm}%Abstand zur Colorbox
        }

\patchcmd{\@@makechapterhead}
{\usekomafont{chapter}{#1}}
{\parbox[b]{\dimexpr\textwidth-4cm\relax}{\raggedright\usekomafont{chapter}{#1}}}
{\typeout{great}}
{\typeout{too bad}}
\makeatother
%------------------------------------------


\begin{document}

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

\end{document}
5

Here is a another suggestion

\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}

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

\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}{%
  \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}%
  {\noindent\setlength\parfillskip{0pt plus 1fil}\rule{\textwidth}{.4pt}\par}%
}

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

Note that I would use open=right if the chapter number should be in the right margin.

Result:

enter image description here


Update as answer of a comment below:

If you want to use \MakeUppercase for the chapter titles you can redefine \chapterlinesformat. Note that the following example needs at least KOMA-Script version 3.19:

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

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

\usepackage{blindtext}

\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}{%
  \sbox\feline@chapter{\feline@chapter@marker[1.61cm]}%
  \makebox[0pt][l]{%
    \makebox[\dimexpr\textwidth+\marginparsep+\wd\feline@chapter\relax][r]{%
      \usebox\feline@chapter}}%
}
\renewcommand\chapterlinesformat[3]{%
  \ifstr{#1}{chapter}
  {\@hangfrom{#2}{\MakeUppercase{#3}}}
  {\@hangfrom{#2}{#3}}%
}
\makeatother

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

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

enter image description here

  • Trying, to change the chapter headline with \addtokomafont{chapter}{\normalsize\MakeUppercase} (\MakeUppercase is from \usepackage{textcase}) leads to the error message ! Missing number, treated as zero., ! Color stack action is missing. ` ` and ! Missing number, treated as zero. Do you have any clue how to prevent this from happening? – jlk Sep 9 '15 at 14:23
  • I am still trying to understand the commands, so I have no idea on how to obtain the effect I need: to have the chapter number at the right, but two lines above the chapter name. Can you help here? – lfd Feb 26 '17 at 2:22
  • 1
    @lfd You could use \raisbox to shift the chapter number: \renewcommand\chapterlinesformat[3]{ \ifstr{#1}{chapter} {\@hangfrom{\raisebox{3\baselineskip}{#2}}{\MakeUppercase{#3}}}{\@hangfrom{#2}{#3}}} – esdd Feb 27 '17 at 23:29
2

think I found a good solution in this thread

enter image description here

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

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

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

% Define own Chapter style
% Pretty chapter pages
%------------------------------------------
\definecolor{nicered}{rgb}{.647,.129,.149}
\definecolor{gray}{gray}{0.55} 
\usepackage{soul}
\usepackage{pdfpages}
\usepackage{varwidth}
\usepackage[calcwidth,explicit]{titlesec}

%\makeatletter
%\newsavebox{\feline@chapter}
%\newcommand\feline@chapter@marker[1][4cm]{%
%   \sbox\feline@chapter{%
%       \resizebox{!}{#1}{\fboxsep=-0pt%\eurom{A}
%           \colorbox{white}{\color{black}$\eurom{\thechapter}$}}}%
%%      \rotatebox{90}{%
%%          \resizebox{%
%%              \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
%%          {!}{\scshape\so\@chapapp}}\hspace{.4mm}%Abstand zum Wort Kapitel
%       \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
%   }
%
%       
%           \newcommand\feline@chm[1][4cm]{%
%               \sbox\feline@chapter{\feline@chapter@marker[#1]}%
%               \makebox[0pt][l]{% aka \rlap
%                   \makebox[1cm][r]{\usebox\feline@chapter}%
%               }
%           }      
%       
%       \renewcommand*{\chapterformat}{%
%           \hspace{\leftmargin} \feline@chm[1.61cm] % Height of the colored box
%           \hspace{0.3cm}%Abstand zur Colorbox
%       }
%       
%\patchcmd{\@@makechapterhead}
%{\usekomafont{chapter}{#1}}
%{\parbox[b]{\dimexpr\textwidth-4cm\relax}{\raggedright\usekomafont{chapter}{#1}}}
%{\typeout{great}}
%{\typeout{too bad}}
%\makeatother
%%------------------------------------------

\newsavebox\mybox

\newlength\mylen
\newlength\titlewd
\newlength\ftitlewd
\newlength\titleboxwd
\setlength\mylen{3pc}
\setlength\titleboxwd{\dimexpr\textwidth-\mylen\relax}
\setlength\ftitlewd{\titleboxwd}

\newcommand\chapfont{\LARGE\bfseries\raggedleft}

\titleformat{\chapter}[hang]
{\chapfont\filleft}
{}{0pc}
{%
    \begin{lrbox}{\mybox}%
        \begin{varwidth}[t]{\titleboxwd}%
            \chapfont#1%
        \end{varwidth}%
    \end{lrbox}%
    \settowidth\titlewd{\usebox\mybox}%
    \ifdim\titlewd<\titleboxwd%
    \global\setlength\ftitlewd{\titlewd}%
    \fi%
    \parbox[t]{\ftitlewd}{\usebox\mybox}%
    \makebox[0pt][l]{\parbox[b]{4pc}{\hfill\scalebox{3}{\textcolor{gray}{$\eurom{\thechapter}$}}}}%
}%\color{black}$\eurom{\thechapter}$
[\vskip-1.4ex{\makebox[0pt][l]{%
        \hspace*{-\ftitlewd}\rule{\dimexpr\ftitlewd+4pc\relax}{1.5pt}}}%
]
\titleformat{name=\chapter,numberless}[hang]
{\chapfont\filleft}
{}{0pc}
{%
    \begin{lrbox}{\mybox}%
        \begin{varwidth}[t]{\titleboxwd}%
            \chapfont#1%
        \end{varwidth}%
    \end{lrbox}%
    \settowidth\titlewd{\usebox\mybox}%
    \ifdim\titlewd<\titleboxwd%
    \global\setlength\ftitlewd{\titlewd}%
    \fi%
    \parbox[t]{\ftitlewd}{\usebox\mybox}%
}
[\vskip-1.4ex{\makebox[0pt][l]{%
        \hspace*{-\ftitlewd}\rule{\dimexpr\ftitlewd+4pc\relax}{1.5pt}}}%
]
\titlespacing*{\chapter}
{1\mylen}{50pt}{40pt}

\begin{document}

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

\end{document}
  • Fine, but it is not recommended to use titlesec if you use the koma-script classes. – Bernard Sep 1 '15 at 14:48
  • I'm still open for other solutions – jlk Sep 1 '15 at 14:54

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.