Page LayoutCustom Header fails

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
statistician
Posts: 2
Joined: Tue Mar 05, 2013 9:44 am

Custom Header fails

Post by statistician »

Hi,

I want to write my master thesis with the following setting:

Code: Select all

\documentclass[
  a4paper,
  12pt,
  bibliography=totoc,
  index=totoc,
  abstracton,
  headsepline,
%  footnosepline,
]{scrartcl}

\usepackage{latexsym}
\usepackage[latin1]{inputenc}
\usepackage[ngerman,english]{babel}
\usepackage{subfig}
\usepackage{float}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{mathrsfs}
\usepackage{eurosym,bm,amsmath,amssymb,verbatim}
\usepackage{listings}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage[round,authoryear]{natbib} 

\usepackage{amsmath}

\usepackage{graphicx,eso-pic,lipsum}
\usepackage[automark]{scrpage2}
\usepackage{url}

\usepackage{tocstyle} 
\usetocstyle{noonewithdot}
\usepackage[bookmarksopen,hyperfootnotes=false,pdftitle=test, pdfauthor=test,pdfsubject=Project]{hyperref}
\usepackage{listings} 
\lstset{ 
  language=R,            
  basicstyle=\scriptsize,
  showstringspaces=false,
  showspaces=false,
  keywordstyle=\color{blue},         
  commentstyle=\color{green},       
  stringstyle=\color{black}
}
%------------------------------------------------------------------------

\parindent0em           
\topmargin-20.4mm   
\textheight245mm

\textwidth157mm \oddsidemargin11mm \evensidemargin11mm

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{scrheadings}

\ifoot[]{My Name}

\AddToShipoutPicture{%
\hspace{16cm}
% {\includegraphics[scale=1]{Logowatermark.jpg}}}


\begin{document}    
\begin{titlepage}

%\hspace{2cm}\scalebox{1}{\includegraphics{Logo.jpg}}

\vspace*{1cm}
\large\textbf{Title}\\[0.5cm]

\normalsize description\\

subtext\\

Degree Course: enter here\\

\textbf{School of  \mbox{test}}\\[0.8cm]

Name of Chair \\[1.5cm]
%
%
\noindent\begin{tabular}[h]{@{}ll}
%\begin{tabular}{l l}
Chairholder:  \\
\\
Supervisors:             \\
\\
Author:   &My Name              \\
\\
%Address:         &               \\[0.2cm]
%                 &1                   \\
\\
Matriculation Number.:    &            \\
\\
Email:           &      \\
\\
\end{tabular}

\vfill
Place, Date

\end{titlepage}


\newpage
\pagenumbering{Roman}


\clearpage
\pagenumbering{arabic}
\onehalfspacing                 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tableofcontents

\newpage
\listoffigures
\newpage
\listoftables
\newpage
\setcounter{page}{1}

 % \input{Chapter1}  
%\newpage
%\input{Chapter2}
\newpage
\part{Description}
\section{Description}
test test test test test test
%\input{Chapter3}
\newpage
%\input{Appendix}
\newpage
\end{document}                                         
Now I want to have a different header:
  1. I want to have a vertical line at the left and at the right side
  2. I want to have a description in the header of the chapter and the section also on pages where part starts. At the moment, you can see, that there is no description on the first page (roman number 1).
I wanted to include the following header with the fancyhdr package (headercolor is a specified color).

Code: Select all

\fancyhead[L]{\hspace{2mm}\textcolor{headercolor}{\leftmark}\text{ }\textcolor{headercolor}{\rightmark}\hfill\textcolor{headercolor}{\thepage}\hspace{4mm}}
\renewcommand{\headrule}{\vspace{-\headheight}\textcolor{headercolor}{\vrule height \headheight width 2pt\relax\rule{\textwidth-8pt}{2pt}\vrule height \headheight width 2pt\relax}}
But if I try to use the package, I get the error message:

Code: Select all

LaTeX Error: Command \chead already defined. Or name \end... illegal,
             see p.192 of the manual.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Custom Header fails

Post by localghost »

Please reduce the problem to a proper minimal example (emphasize on minimal). The vast majority of loaded packages and definitions is for sure not necessary to describe the problem.

You are using already a class from the KOMA-Script bundle and you are loading already »scrpage2«. It conflicts with fancyhdr. Why don't you use this package?


Best regards and welcome to the board
Thorsten
Post Reply