Skip to content

Commit

Permalink
Fancy: Removed fancyhdr dependency.
Browse files Browse the repository at this point in the history
CleanThesis now uses KOMA script's scrlayer-scrpage package.
  • Loading branch information
derric committed Jun 26, 2016
1 parent c301b7e commit 2c5331e
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 68 deletions.
151 changes: 84 additions & 67 deletions cleanthesis.sty
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@
\RequirePackage{setspace} % for line spacing, e.g. \onehalfspacing
\RequirePackage[]{graphicx} % graphics import features
\RequirePackage{tabularx} % table features
\RequirePackage{fancyhdr} % for header and footer modifications
%\RequirePackage{fancyhdr} % for header and footer modifications
\RequirePackage{enumitem} % for simple list modifications
\RequirePackage{blindtext} % package for blind text
\RequirePackage{textcomp} % different symbols
\RequirePackage{hyperref} % interactive link inside the document
\RequirePackage[automark]{scrlayer-scrpage}

%
\RequirePackage[ % modify figure and table captions
Expand Down Expand Up @@ -360,79 +361,95 @@
% **************************************************
% Header and Footer
% **************************************************
\pagestyle{fancy}

\automark[section]{chapter} % automatically marks sections as rightmark
% and chapters as leftmark

\setlength{\footheight}{120pt} % avoids scrlayer-scrpage warning:
% footheight to low warning

\setlength{\footskip}{185pt} % BAD HACK that moves the foot downwards

\KOMAoption{footwidth}{foot:53pt} % BAD HACK that moves the foot towards
% the outer border

\pagestyle{scrheadings}

%% Redefinition of the chaptermark (used for footer mark on even (left) pages)
\renewcommand{\chaptermark}[1]{%
\markboth{%
\footnotesize%
% use \@chapapp instead of \chaptername to avoid 'Chapter A Appendix ...', thanks to @farbverlust (issue #47)
{\color{ctcolorfootermark}\textbf{\@chapapp\ \thechapter}}%
\quad%
\ifct@cthesis@wrapfooter%
{\color{ctcolorfootertitle}\protect\parbox[t]{.7\textwidth}{#1}}%
\else%
{\color{ctcolorfootertitle}#1}%
\fi%
}{}%
\markboth{%
\ctfontfootertext
% use \@chapapp instead of \chaptername to avoid
% 'Chapter A Appendix ...', thanks to @farbverlust (issue #47)
{\color{ctcolorfootermark}\textbf{\@chapapp\ \thechapter}}%
\quad%
\protect\begin{minipage}[t]{.65\textwidth}%
#1%
\protect\end{minipage}%
}{}%
}

%% Redefinition of the sectionmark (used for footer mark on odd (right) pages)
\newlength{\lensectionnumber}
\renewcommand{\sectionmark}[1]{%
\markright{%
\footnotesize%
{\color{ctcolorfootermark}\textbf{\thesection}}%
\quad%
\ifct@cthesis@wrapfooter%
{\color{ctcolorfootertitle}\protect\parbox[t]{.7\textwidth}{#1}}%
\else%
{\color{ctcolorfootertitle}#1}%
\fi%
}%
\markright{%
\ctfontfootertext
\setlength{\lensectionnumber}{0em}
\settowidth{\lensectionnumber}{\textbf{\thesection}\quad}
\protect\begin{minipage}[t]{.72\textwidth}%
{\ }% bad hack to prevent a wrong baseline for the minipage
\protect\raggedleft%
\hangindent=\lensectionnumber%
{\color{ctcolorfootermark}\textbf{\thesection}}%
\quad%
#1%
\protect\end{minipage}%
}%
}
%
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfootoffset[OR]{1.85cm}
\fancyfoot[OR]{%
{\ }\tgherosfont%
{\color{ctcolorfooterline}\rule[-90pt]{1.25pt}{100pt}}%
\hspace*{10pt}\begin{minipage}[b]{1.5cm}%
\color{ctcolorfooterpage}\normalsize\textbf{\thepage}%
\end{minipage}%
}
\fancyfootoffset[EL]{1.85cm}
\fancyfoot[EL]{%
\tgherosfont%
\begin{minipage}[b]{1.5cm}%
\raggedleft\color{ctcolorfooterpage}\normalsize\textbf{\thepage}%
\end{minipage}%
\hspace*{10pt}{\color{ctcolorfooterline}\rule[-90pt]{1.25pt}{100pt}}%
}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

%% Page number for odd (right) pages
\newcommand{\ctfooterrightpagenumber}{%
{\color{ctcolorfooterline}\rule[-90pt]{1.25pt}{100pt}}%
\hspace*{10pt}%
\begin{minipage}[b]{1.5cm}%
\ctfontpagenumber%
\thepage\ %
\end{minipage}%
}
%
\fancypagestyle{maincontentstyle}{%
\pagestyle{plain}
\fancyhf{}
\fancyfootoffset[OR]{1.85cm}
\fancyfoot[OR]{%
{\ }\tgherosfont\footnotesize%
\rightmark%
\hspace*{0.75cm}{\color{ctcolorfooterline}\rule[-90pt]{1.25pt}{100pt}}%
\hspace*{10pt}\begin{minipage}[b]{1.5cm}%
\color{ctcolorfooterpage}\normalsize\textbf{\thepage}%
\end{minipage}%
}
\fancyfootoffset[EL]{1.85cm}
\fancyfoot[EL]{%
\tgherosfont\footnotesize%
\begin{minipage}[b]{1.5cm}%
\raggedleft\color{ctcolorfooterpage}\normalsize\textbf{\thepage}%
\end{minipage}%
\footnotesize%
\hspace*{10pt}{\color{ctcolorfooterline}\rule[-90pt]{1.25pt}{100pt}}%
\hspace*{0.75cm}\leftmark%
}

%% Page number for even (left) pages
\newcommand{\ctfooterleftpagenumber}{%
\begin{minipage}[b]{1.5cm}%
\ctfontpagenumber%
\raggedleft\thepage%
\end{minipage}%
\hspace*{10pt}%
{\color{ctcolorfooterline}\rule[-90pt]{1.25pt}{100pt}}%
}

%% Defines the content for header and footer
\lehead{}
\cehead{}
\rehead{}
\lohead{}
\cohead{}
\rohead{}
\lefoot[\ctfooterleftpagenumber]{%
\ctfooterleftpagenumber%
\hspace*{0.75cm}%
\headmark%
}
\cefoot{}
\refoot{}
\lofoot{}
\cofoot{}
\rofoot[\ctfooterrightpagenumber]{%
\headmark%
\hspace*{0.75cm}%
\ctfooterrightpagenumber%
}


% **************************************************
% New Commands
% **************************************************
Expand Down
2 changes: 1 addition & 1 deletion my-thesis.tex
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
% --------------------------
\pagenumbering{arabic} % arabic page numbering
\setcounter{page}{1} % set page counter
\pagestyle{maincontentstyle} % fancy header and footer
\pagestyle{scrheadings} % header and footer style

%% Uncomment the following lines using the \part command
%% to add part sections
Expand Down

0 comments on commit 2c5331e

Please sign in to comment.