4

I'm designing an exercise sheet and need some help with the header. It looks as it should with my code, but is way too high on the page. Changing the headheight does not seem to have any effect, only that LaTeX complains if i choose it too low.

Is there a way to get it lower onto the page? Or do i have to do the two-line header in another way?

Additionally, i'd like to know if there's an easy possibility to only show the header on those pages where a new section begins, and not on the other pages (e.g. on the first two pages, but not the last one in the example).

\documentclass[paper=a4, twoside=true, fontsize=11pt, parskip=half, headheight=1cm, DIV=12]{scrartcl}

% Designing the head of the page
\usepackage[automark,headsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\ihead{{\normalfont\bfseries Exercise Sheet \thesection\  for some Lecture, Summer 2015}\\
    \normalfont Due date: Thursday, 01. January 2015, 10:00}
\ohead{{\normalfont\bfseries Prof. Dr. John Doe}\\
    \normalfont email@professor.com}
\chead{}

\usepackage{blindtext}

\begin{document}
\blinddocument
\end{document}
Timitry
  • 275
  • 3
  • 8

2 Answers2

5

Maybe you are looking for the headinclude=true option. You can set this option explicitly \documentclass[...,headinclude=true,...]{scrartcl}. Or you can set the headsepline option as an class option. Then headinclude=true will be set automatically.

If there should only be a header in case a section starts on the page use the plain pagestyle and switch to scrheadings using \thispagestyle{scrheadings} after the \section command

\documentclass[
  twoside=true,
  parskip=half,
  headlines=2,
  headsepline,% headinclude=true is also set
  DIV=12
  ]{scrartcl}
% Designing the head of the page
\usepackage[
    %automark,% why? \headmark etc. are not used in your code
    %headsepline
  ]{scrlayer-scrpage}
\ihead{\textbf{Exercise Sheet \thesection\  for some Lecture, Summer 2015}\\
    Due date: Thursday, 01. January 2015, 10:00}
\ohead{\textbf{Prof. Dr. John Doe}\\
    email@professor.com}
\chead{}

\setkomafont{pagehead}{\normalfont}

\pagestyle{plain}

\usepackage{blindtext}

\begin{document}
\section{First section}\thispagestyle{scrheadings}
\subsection{First subsection}
\Blindtext
\subsection{Second subsection}
\Blindtext
\section{Second section}\thispagestyle{scrheadings}
\subsection{First subsection}
\Blindtext
\subsection{Second subsection}
\Blindtext
\end{document}

enter image description here

Alternatively you can load etoolbox to patch the \section command

\documentclass[
  twoside=true,
  parskip=half,
  headlines=2,
  headsepline,% headinclude=true is also set
  DIV=12
  ]{scrartcl}
% Designing the head of the page
\usepackage[
    %automark,% why? you define the header manually in your code
    %headsepline
  ]{scrlayer-scrpage}
\ihead{\textbf{Exercise Sheet \thesection\  for some Lecture, Summer 2015}\\
    Due date: Thursday, 01. January 2015, 10:00}
\ohead{\textbf{Prof. Dr. John Doe}\\
    email@professor.com}
\chead{}

\setkomafont{pagehead}{\normalfont}

\pagestyle{plain}

\usepackage{etoolbox}
\pretocmd\section{\thispagestyle{scrheadings}}{}{}

\usepackage{blindtext}

\begin{document}
\section{First section}
\subsection{First subsection}
\Blindtext
\subsection{Second subsection}
\Blindtext
\section{Second section}
\subsection{First subsection}
\Blindtext
\subsection{Second subsection}
\Blindtext
\end{document}
esdd
  • 85,675
  • Yes, headinclude did the trick! Looking way better now. \pagestyle{plain} together with \thispagestyle{scrheadings} works too. Maybe i will just remove the whole header and put it as a kind of title at the beginning of each sheet, but i'm not sure about that yet. Thanks for your answer! – Timitry Sep 24 '14 at 12:13
1

Well, KOMA-Script has his own algorithm to build or better calculate the printing area.

For example you used DIV=12. In the manual of KOMA-Script you can read how this works. For here only that: With a greater number (for example 12) you will have smaller margins with KOMA-Script. If you want greater margins use a smaller number for DIV, for example DIV=9.

To visualise this I added package showframe to my MWE to mark the typing area for you. Try my MWE with several numbers for DIV. Then change the fontsize and try again with several DIVs. You will see a difference.

If you to use special margins consider to use package geometry instead.

MWE with a little bit pretty printing for testing:

\documentclass[%
  paper=a4
%,twoside=true      % why for an article??????????????
 ,fontsize=11pt     % relevant for typing area
 ,parskip=half
 ,headheight=28pt   % 28pt minimum; depends on fontsize
 ,DIV=9             % relevant for typing area: try 9, 10, 11, 12
]{scrartcl}

\usepackage{blindtext} % for dummy text
\usepackage{showframe} % shows typing area

% Designing the head of the page
\usepackage[%
  automark
 ,headsepline
]{scrlayer-scrpage}
\pagestyle{scrheadings}

\ihead{{\normalfont\bfseries Exercise Sheet \thesection\  for some Lecture, Summer 2015}\\
    \normalfont Due date: Thursday, 01. January 2015, 10:00}
\ohead{{\normalfont\bfseries Prof. Dr. John Doe}\\
    \normalfont email@professor.com}
\chead{}


\begin{document}
\blinddocument
\thispagestyle{empty}
\blindtext
\end{document}

If you want no header on a page you can use the command \thispagestyle{empty} as shown in the last two lines of the MWE.

Mensch
  • 65,388
  • I knew about the DIV-setting, and i chose it high to have more space on the page. The problem was more that the head was not included in the margin calculation, like esdd posted in his answer. Still, the showframe package is a nice tool which i did not know yet, thanks! And why should i not have a twoside layout for scrartcl? – Timitry Sep 24 '14 at 12:16