1

I'm making a document with document class scrreprt, and used this to get the page numbering on the top of the pages, and a line on the top of the page

\documentclass[11pt, twoside=semi, titlepage]{scrreprt}

\usepackage[top=2.5cm, bottom=2.5cm, left=6cm, right=2cm, heightrounded,
marginparwidth=3.5cm, marginparsep=0.5cm]{geometry}


%% To make the marginnotes appear on the left side on all the pages
\usepackage[strict]{changepage}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@addmarginpar}{\ifodd\c@page}{\ifodd\c@page\@tempcnta\m@ne}{}{}
\makeatother
\reversemarginpar


\usepackage[automark, headsepline]{scrlayer-scrpage}
\clearpairofpagestyles

\lehead[\pagemark]{\pagemark}
\rohead[\pagemark]{\pagemark}
\chead{\headmark}
\chead{\headmark}

\usepackage{blindtext}
\begin{document}
\blinddocument
\end{document}

Is it possible to make the line longer, so its over both the text and the margin notes?

landigio
  • 193

2 Answers2

1

Set the width of the header to include the marginpar as well.

\documentclass[11pt, twoside=semi, titlepage]{scrreprt}

\usepackage[automark, headsepline]{scrlayer-scrpage}
\clearpairofpagestyles

\setheadwidth{textwithmarginpar}
\ohead[\pagemark]{\pagemark}
\chead{\headmark}
\usepackage{blindtext}
\begin{document}
\blinddocument
\end{document}

Now, why doesn't it work loading geometry?

\usepackage[top=2.5cm, bottom=2.5cm, left=6cm, right=2cm, heightrounded,
marginparwidth=3.5cm, marginparsep=0.5cm]{geometry}

Adding the option showframe shows us one simple thing. Headers and footers are treated like left- and right-hand pages. But global option twoside=semi makes all pages in concern of margins odd (right-hand pages). Telling geometry to use a right margin of 2cm means, the text earea is two centi meter away from the page boundary, but you requested a marginpar width of 3.5 cm with an additional sep of half a centi meter. That means the width of the head is extenden about 2 cm outside of the physical paper (or pdf). You can easily test this:

\documentclass[11pt, twoside=semi, titlepage]{scrreprt}

\usepackage[top=2.5cm, bottom=2.5cm, left=6cm, right=2cm,heightrounded,
marginparwidth=3.5cm, marginparsep=0.5cm,showframe]{geometry}
\usepackage[automark, headsepline]{scrlayer-scrpage}
\clearpairofpagestyles

\setheadwidth{textwithmarginpar}
\ohead[\pagemark]{\pagemark}
\chead{\headmark}
\usepackage{blindtext}
\begin{document}
\marginpar{Where the duck is the rest of this text?}
\blindtext
\end{document}

enter image description here

You can get the marginpar smaller, of course, but i think you shouldn't use them anymore.

enter image description here

Johannes_B
  • 24,235
  • 10
  • 93
  • 248
  • yes this works! but only on the even numbered pages.. :/ thank you very much for fast answer! – landigio Oct 27 '14 at 19:44
  • Works perfectly for me. Do you have a recent KOMA-script? http://www.komascript.de/current Might have been a bug in an older version. – Johannes_B Oct 27 '14 at 20:43
  • Think i found the problem. I think it is my options on the geometry pack that messes things up. i added my geometry package settings on my origninal question on the top (sorry for not adding it from the start). – landigio Oct 27 '14 at 21:13
  • do you know how to solve the problem? – landigio Oct 27 '14 at 22:20
  • @landigio I don't know if you get pinged when edits happen, so ^^^^ – Johannes_B Oct 29 '14 at 18:14
  • im sorry, i have understood that i may have done things a bit difficult for my self making my document. The reason i have the margins that way is because i want all the marginnotes to appear on the right side, and i have actually figured out how to make the margins appear on the right side (they dont disappear outside the document, i can add my code for this over), so thats not a problem. i just don't know how to make the header line don't end up outside the document (on odd numbered pages). Thank you so much for your help anyway! – landigio Oct 30 '14 at 15:21
  • @landigio You could define a clone layer for every page (odd, even) and define the sepline for any possible case. But i sense using option twoside=semi and \reversemarginpar has it's reason. Can you explain your goal? We might find a better solution. Doing it for a one sided document is easy, for a twosided as well. But not for semi. – Johannes_B Oct 31 '14 at 14:10
  • my goal is to make the document so the marginnotes appears on the left side on all the pages (i want the thick margin on the left side). but i want the pagenumbers to appear on the top of the page, on the left side on even numbered pages, and on the right side on odd numbered pages. I also want the head line to reach over the margin. – landigio Oct 31 '14 at 17:03
  • @landigio You are aware that this layout is quite unusual? – Johannes_B Oct 31 '14 at 17:06
  • yeah i didn't know when i started, but i have realised that now. i hoped it would be possible anyway though. – landigio Oct 31 '14 at 17:41
  • And you really want to have the document twosideed? Meaning text on both sides of the pages? – Johannes_B Oct 31 '14 at 17:45
  • the option twoside=semi was something i used to get the pagenumering on the left side on even numbered pages, and on the right on odd numbered pages. i really don't know much about latex yet, and thought i had to use it to get the page numbering the way i wanted. i guess it doesn't matter if i use the twoside option if i still get the pagenumbering the way i want. – landigio Oct 31 '14 at 17:54
  • So, you basically want the pagenumber on the outside? – Johannes_B Oct 31 '14 at 17:57
  • hmm here is another question i asked, on the picture you can see what i have in mind. [http://tex.stackexchange.com/questions/209365/how-do-i-add-a-blue-box-around-the-section-number] – landigio Oct 31 '14 at 20:01
1

Set the headwidth to textwithmarginpar and then use different offsets for the header on even and odd pages (possible with KOMA-Script version 3.14 or newer).

headwidth=textwithmarginpar:-\the\marginparwidth-\the\marginparsep:marginpar

enter image description here

Code:

\documentclass[twoside=semi, titlepage]{scrreprt}

\usepackage[
  vmargin=2.5cm, heightrounded,
  left=6cm, right=2cm,
  marginparwidth=3.5cm, marginparsep=0.5cm
]{geometry}

\reversemarginpar

\usepackage[
    automark,
    headsepline,
    headwidth=textwithmarginpar:-\the\marginparwidth-\the\marginparsep:marginpar
  ]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead*{\pagemark}
\chead{\headmark}

\usepackage{blindtext}
\begin{document}
\chapter{Chapter}
\section{Section}
\Blindtext\marginpar{Margin text}
\Blindtext\marginpar{Margin text}
\Blindtext[1]
\blinddocument
\end{document}
esdd
  • 85,675
  • I know this answer is five months old. But. The picture is exactly what i want! :D But when i add the code you wrote (and only your code in a new document) i don't get the same document as you have one the picture. The head line on the even numbered pages is starting right over the text and disappears outside the page on the right. How do i ajust so the line works on even numbered pages too? – landigio May 16 '15 at 10:13
  • Using KOMA-Script Version 3.16 (current in MiKTeX and in TL2014) or 3.17a (current in TL2015 and on CTAN) I get still the same document as in my picture. So, which KOMA-Script version do you use? And note that you need version 3.14 or newer and that twoside=semi is used in the example. – esdd May 16 '15 at 20:07
  • But how do i update? i cant figure out how. I use windows and miktex. I opended package manager (miktex) and searched for koma-srcipt. i thought i could a it, and then install it, but that option isn't available :S If you could help me with describing how to fix this i would be so grateful! – landigio May 18 '15 at 17:18
  • @landigio Use the MiKTeX update manager: see the MiKTeX Manual. If you have a muliuser Installation you should do it both in admin and user mode. And see also How should one maintain and update a MiKTeX installation? – esdd May 19 '15 at 07:57
  • Thank you very much! This was really helpful, I finally got it to work! :) – landigio May 22 '15 at 19:37