1

I am struggling to add a header with a colored headsepline to my header.

I have tried to add a command like this:

\setheadsepline{\color{1blue}}

But instead of the colored line I got the whole text blue. I know it's probably an easier fix, but I just can't find it. I want to have the same color on the header line, as I have on the Titlepage.

Sample:

\documentclass[a4paper,12pt,titlepage]{scrartcl}

\usepackage[left=2.5cm, right=2cm]{geometry}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fontenc}

\usepackage{microtype} %Spacing
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}

%\usepackage{hyperref}
\usepackage{url}
\urlstyle{same}

\usepackage{caption}

\usepackage{float}

\usepackage{setspace}

%Titlepage
\colorlet{1blue}{RoyalBlue!65}

%NewCommand HRule for Titlepage
\newcommand{\HRule}{\textcolor{1blue}{\rule{\textwidth}{0.5mm}}}

%Header
\usepackage[automark, headsepline]{scrpage2}
\pagestyle{scrheadings}
\setheadsepline{\color{1blue}}
\ihead{}
\chead{}
%\ohead{\includegraphics[width=2.5cm]{Bilder/krutec-logo-m.png}}
\ifoot{}
\cfoot{}
\ofoot{\pagemark}

\begin{document}

Minimal example

\end{document}
Schweinebacke
  • 26,336
Severus15
  • 207

2 Answers2

3

\setheadsepline does not expect a colour but a length as mandatory argument. So your example results in an error message:

./test.tex:32: Argument of \@scr@setline has an extra }.
<inserted text> 
                \par 
l.32 \setheadsepline{\color{1blue}}

However, scrpage2 is obsolete/deprecated. See the warning message produced by scrpage2:

Package scrpage2 Warning: usage of obsolete package!
(scrpage2)                Package `scrpage2' is obsolete.
(scrpage2)                You should not longer use package `scrpage2'.
(scrpage2)                You should replace usage of package `scrpage2'
(scrpage2)                by `scrlayer-scrpage' on input line 52.

or have a look into the scrpage2 manual, scrpage2.pdf, that is titled:

The Obsolete package scrpage2

and states in the preamble of the first chapter:

recommendation to use scrlayer-scrpage

Usage of scrlayer-scrpage as recommended by the information shown above, with the correct user interface for setting up the colour, which is explained in the KOMA-Script manuals, scrguien.pdf or scrguide.pdf:

\documentclass[12pt,titlepage]{scrartcl}% a4paper is default

% 1st: Load packages
\usepackage[left=2.5cm, right=2cm]{geometry}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fontenc}
\usepackage{microtype} %Spacing
\usepackage{graphicx} % not used by the example
\usepackage[dvipsnames]{xcolor}
\usepackage{caption} % not used by the exmaple
\usepackage{float} % not used by the example
\usepackage{setspace}

\usepackage[automark,headsepline]{scrlayer-scrpage}% scrpage2 is obsolete
\usepackage{url}
%\usepackage{hyperref}

% 2nd: Do configuration (using the packages)

\newcommand{\HRule}{\textcolor{1blue}{\rule{\textwidth}{0.5mm}}}% not used by the example
\colorlet{1blue}{RoyalBlue!65}
\urlstyle{same} % not used by the example

\pagestyle{scrheadings}
\addtokomafont{headsepline}{\color{1blue}}% setting up the colour of element headsepline
\clearpairofpagestyles
%\ohead{\includegraphics[width=2.5cm]{Bilder/krutec-logo-m.png}}
\ofoot*{\pagemark}% \pagemark also on plain pages

\begin{document}

Minimal example

\end{document}

results in:

left top edge of a page

Schweinebacke
  • 26,336
0

You misunderstood the syntax of \setheadsepline:

\documentclass[a4paper,12pt,titlepage]{scrartcl}

\usepackage[left=2.5cm, right=2cm]{geometry}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fontenc}

\usepackage{microtype} %Spacing
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}

%\usepackage{hyperref}
\usepackage{url}
\urlstyle{same}

\usepackage{caption}

\usepackage{float}

\usepackage{setspace}

%Titlepage
\colorlet{1blue}{RoyalBlue!65}

%NewCommand HRule for Titlepage
\newcommand{\HRule}{\textcolor{1blue}{\rule{\textwidth}{0.5mm}}}

%Header
\usepackage[automark, headsepline]{scrpage2}
\pagestyle{scrheadings}
\setheadsepline{0.5mm}[\color{1blue}]
\ihead{}
\chead{}
%\ohead{\includegraphics[width=2.5cm]{Bilder/krutec-logo-m.png}}
\ifoot{}
\cfoot{}
\ofoot{\pagemark}

\begin{document}

Minimal example

\end{document}

enter image description here

Bernard
  • 271,350
  • 1
    Please do not use scrpage2 any longer. It could be removed from KOMA-Script with any future release, because it warns that it is obsolete for almost two years and the official successor is already available for more than six years. – Schweinebacke Apr 04 '19 at 08:51
  • Thanks. That line works now.

    @Schweinebacke What should I use instead? I searched for hours for a way to get a header.

    – Severus15 Apr 04 '19 at 08:56
  • 1
    @Severus15 See my answer I gave 5 minutes before Bernard or the answer to the question Kurt has linked in his comment to your question. And have a look into the KOMA-Script manual. There is a chapter about it. – Schweinebacke Apr 04 '19 at 08:58