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}

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}

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}
\newgeometry
. This weill make you start a new page. – Bernard Apr 5 '17 at 23:08