2

Is it possible to set same header margins on pages with different margins?

One guideline of my university is a margin for corrections, but only on pages which contain my solution. I think it would look nicer, if the header margins wouldn't change if I change the page margins.

MWE:

\documentclass[a4paper]{scrartcl}

%\usepackage{fontspec}
\usepackage[ngerman]{babel}
\usepackage[headtopline,headsepline]{scrpage2}
\usepackage{lipsum}
\usepackage{geometry}

\geometry{
  left=25mm,
  right=25mm,
  top=20mm,
  bottom=30mm,
  bindingoffset=5mm
}

\ihead{Hausarbeit\\Dunkle Magie}
\ohead{John Doe\\Mat-Nr. 1234567}

\setkomafont{pageheadfoot}{\small}

\setheadtopline{0pt}
\setheadsepline{0.5pt}
\pagestyle{scrheadings}

\begin{document}

    \author{John Doe}
    \title{Lorem ipsum}
    \maketitle
    \newpage

    \section*{Aufgabe}
    \lipsum[1-3]

    \clearpage
    \newgeometry{
        left=65mm,
        right=25mm,
        top=20mm,
        bottom=30mm,
        bindingoffset=5mm
    }

    \section*{Lösung}
    \lipsum[1-3]
\end{document}

Many thanks!

Edit:

To clarify my question: [I already use \newgeometry, but] I wonder about how can I set a 6.5cm left hand margin just for the content / body and on the same page a left hand header margin of 2.5cm.

  • 1
    You can with \newgeometry. This weill make you start a new page. – Bernard Apr 5 '17 at 23:08
  • Yes, I already use \newgeometry, but I wonder about how can I set a 6.5cm left hand margin just for the content / body and on the same page a left hand header margin of 2.5cm. – ggn Apr 5 '17 at 23:53
2

With a KOMA-Script class like scrartcl you can use the addmargin environment to change the left or right margin for the content.

Package scrpage2 is depreciated. So I would use its successor scrlayer-scrpage.

\documentclass[%a4paper,% default
  headheight=24pt
]{scrartcl}
\usepackage{fontspec}
\usepackage[ngerman]{babel}
\usepackage{lipsum}

\usepackage[
  manualmark,
  headsepline=.5pt
]{scrlayer-scrpage}% sets pagestyle scrheadings automatically

\usepackage{geometry}
\geometry{
  left=25mm,
  right=25mm,
  top=20mm,
  bottom=30mm,
  bindingoffset=5mm
}

\ihead{Hausarbeit\\Dunkle Magie}
\ohead{John Doe\\Mat-Nr. 1234567}
\setkomafont{pageheadfoot}{\small}

\begin{document}
\author{John Doe}
\title{Lorem ipsum}
\maketitle
\newpage
\addsec*{Aufgabe}
\lipsum[1-3]
\clearpage
\begin{addmargin}[4cm]{0cm}
  \addsec*{Lösung}
  \lipsum[1-3]
\end{addmargin}
\end{document}

enter image description here

There is also a possibility if you want to use \newgeometry:

\documentclass[%a4paper,% default
  headheight=24pt
]{scrartcl}
\usepackage{fontspec}
\usepackage[ngerman]{babel}
\usepackage{lipsum}

\usepackage[
  manualmark,
  headsepline=.5pt
]{scrlayer-scrpage}% sets pagestyle scrheadings automatically

\usepackage{geometry}
\geometry{
  left=25mm,
  right=25mm,
  top=20mm,
  bottom=30mm,
  bindingoffset=5mm
}

\ihead{Hausarbeit\\Dunkle Magie}
\ohead{John Doe\\Mat-Nr. 1234567}
\setkomafont{pageheadfoot}{\small}

\begin{document}
\author{John Doe}
\title{Lorem ipsum}
\maketitle
\newpage
\addsec*{Aufgabe}
\lipsum[1-3]
\newgeometry{
  left=65mm,
  right=25mm,
  top=20mm,
  bottom=30mm,
  bindingoffset=5mm
}
\addsec*{Lösung}
\KOMAoptions{headwidth=\textwidth+4cm:-4cm}
\lipsum[1-3]
\restoregeometry
\KOMAoptions{headwidth=text}
\lipsum
\end{document}

enter image description here


If you really want to use the depreciated package scrpage2:

\documentclass[%a4paper,% default
  headheight=24pt
]{scrartcl}
\usepackage{fontspec}
\usepackage[ngerman]{babel}
\usepackage[
  headsepline
]{scrpage2}
\usepackage{lipsum}

\usepackage{geometry}
\geometry{
  left=25mm,
  right=25mm,
  top=20mm,
  bottom=30mm,
  bindingoffset=5mm
}

\ihead{Hausarbeit\\Dunkle Magie}
\ohead{John Doe\\Mat-Nr. 1234567}
\setkomafont{pageheadfoot}{\small}

\setheadsepline{0.5pt}
\pagestyle{scrheadings}

\begin{document}
\author{John Doe}
\title{Lorem ipsum}
\maketitle
\newpage
\addsec*{Aufgabe}
\lipsum[1-3]
\clearpage
\begin{addmargin}[4cm]{0cm}
  \addsec*{Lösung}
  \lipsum[1-3]
\end{addmargin}
\end{document}

or

\documentclass[%a4paper,% default
  headheight=24pt
]{scrartcl}
\usepackage{fontspec}
\usepackage[ngerman]{babel}
\usepackage[
  headsepline
]{scrpage2}
\usepackage{lipsum}

\usepackage{geometry}
\geometry{
  left=25mm,
  right=25mm,
  top=20mm,
  bottom=30mm,
  bindingoffset=5mm
}

\ihead{Hausarbeit\\Dunkle Magie}
\ohead{John Doe\\Mat-Nr. 1234567}
\setkomafont{pageheadfoot}{\small}

\setheadsepline{0.5pt}
\pagestyle{scrheadings}

\begin{document}
\author{John Doe}
\title{Lorem ipsum}
\maketitle
\newpage
\addsec*{Aufgabe}
\lipsum[1-3]
\newgeometry{
  left=65mm,
  right=25mm,
  top=20mm,
  bottom=30mm,
  bindingoffset=5mm
}
\setheadwidth[-4cm]{\dimexpr\textwidth+4cm\relax}
\addsec*{Lösung}% \section* replaced by \addsec*
\lipsum[1-3]
\restoregeometry
\setheadwidth{text}
\lipsum
\end{document}
  • Many thanks! I'm now using your scrlayer-scrpage solution. – ggn Apr 7 '17 at 8:17
0

You have the adjustwidth environment from changepage. It takes two arguments: the values of the width modifications for left and right margins. For two-sided documents, ig the changes are asymmetric, the \checkoddpage command will let you change the inner and outer margins rather than the left and right margins.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.