[Tex/LaTex] Different margins in title and chapters

fancyhdrheader-footermargins

I am struggling here with adapting school template for my document. The problem is that I need different margins on the title and on the chapter pages. Here is the code. On the title page is all easy. But on the chapter pages changing \textwidth combined with use of the \fancyhead acts crazy. After all I can change the width of the header but not of the text. What is the way to fix it?

EDITED: I didn't state it clear, I want to extend the textwidth for chapters and not to shrink the header.

enter image description here

%===========================================
% Basic properties
%===========================================
\documentclass[11pt,a4paper,pdftex,twoside,headings=small,numbers=noenddot,abstracton,fleqn,titlepage,openright]{scrreprt}

%===========================================
% Language Settings
%===========================================
\usepackage [english]{babel}
\selectlanguage{english}
\usepackage{blindtext}

%===========================================
% Encoding Settings
%===========================================
\usepackage[utf8]{inputenc}
%\usepackage[latin1]{inputenc} % try this if you encounter problems with Umlauts etc.

%===========================================
% Packages
%===========================================
\usepackage{pifont,fancyhdr,gensymb,geometry,hyperref,graphicx,amsfonts,amssymb,amsmath,amsopn,amsthm,caption,footnote,colortbl,color,lscape,pdflscape,pdfpages,subcaption}
\usepackage{setspace} % fÃŒr Zeilenabstandeinstellungen

% allows rotation of any element
\usepackage{rotating}

% package for pseudocode / algorithms
\usepackage{algorithmic}

%===========================================
% Abbreviations and Nomenclature Setup
%===========================================
\usepackage[acronym,nonumberlist]{glossaries}
\input{misc/abbreviations}
\input{misc/nomenclature}
\makeglossaries

%===========================================
% Footnotes
%===========================================
\makesavenoteenv{tabular}
\makesavenoteenv{figure}
\makesavenoteenv{itemize}

%===========================================
% Margins
%===========================================
% remove huge, outdated printing margins
\setlength{\voffset}{-1in}
\setlength{\hoffset}{-1in}

% set vertical margins
\setlength{\topmargin}{2cm}
\setlength{\textheight}{23cm}
\setlength{\headheight}{0cm}
\setlength{\headsep}{1cm}

% set horizontal margins
\setlength{\evensidemargin}{5cm}
\setlength{\oddsidemargin}{4.5cm} % Just for title page, will be changed later!
\setlength{\textwidth}{12cm}

%===========================================
% Indentation
%===========================================
% Disable to enable indentation of paragraphs
\setlength{\parindent}{0pt}

%===========================================
% Typesetting
%===========================================
% penalties for typesetting
\clubpenalty = 100000       % Make sure that a paragraph does not start on the last line of a page
\widowpenalty = 100000      % Make sure that a paragraph does not end on the first line of a page

%===========================================
% Font settings
%===========================================
\newcommand{\captionmath}[1]{$\mathsf{#1}$}  %Serifenlose Schrift in Formeln
\renewcommand{\familydefault}{\sfdefault} %Seriefenlose Schrift im Textblock
%\newcommand{\mathsym}[1]{{}}
%\newcommand{\unicode}{{}}

%===========================================
% Line Spacing
%===========================================
\onehalfspacing % set line spacing to 1.5

%===========================================
% Itemize
%===========================================
% redefine first level itemization
\renewcommand{\labelitemi}{\raisebox{0.45ex}{\tiny{\textbullet}}}
% further levels: labelitemii, labelitemiii, labelitemiv

%===========================================
% Table of Contents and Headings
%===========================================
\setcounter{tocdepth}{2} % depth of table of contents
\setcounter{secnumdepth}{2} % depth of heading numbering

%===========================================
% Bibliography Settings
%===========================================
\bibliographystyle{plain}


%*************************************************************************************
%*************************************************************************************
% Beginning of Document
%*************************************************************************************
%*************************************************************************************
\begin{document}

%===========================================
% Titlepage
%===========================================
%\input{misc/titlepage} 
\blindtext
\thispagestyle{empty} 
\setlength{\evensidemargin}{2cm}
\setlength{\oddsidemargin}{3cm} % Just for title page, will be changed later!
\setlength{\textwidth}{16cm}

%===========================================
% Header and Footer
%===========================================
\pagestyle{fancy} 

\fancyhead{} %loescht alle Einstellungen
\fancyhead[RO,LE]{} 
\fancyhead[CO,CE]{}
\fancyhead[LO,RE]{}

\fancyfoot[RO,LE]{\thepage}
\fancyfoot[CO,CE]{}
\fancyfoot[LO,RE]{} 
\renewcommand{\headrulewidth}{0pt} 
\renewcommand{\footrulewidth}{0pt}
%\setlength{\headwidth}{170mm}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\renewcommand*{\chapterpagestyle}{fancy}


%===========================================
% Preamble
%===========================================
\pagenumbering{Roman} \setcounter{page}{1}

%===========================================
% Table of Contents
%===========================================
\tableofcontents
\thispagestyle{empty} 
\cleardoublepage

%===========================================
% Content
%===========================================
% change header
\renewcommand{\headrulewidth}{1pt}
\fancyhead[RO,LE]{\rightmark}
\fancyhead[LO,RE]{\leftmark}

% arabic numbering, reset page counter
\pagenumbering{arabic} \setcounter{chapter}{0} 

%\setlength{\evensidemargin}{5cm}
%\setlength{\oddsidemargin}{4.5cm} % Just for title page, will be changed later!
%\setlength{\textwidth}{12cm}

%===========================================
% Chapters
%===========================================
\Blinddocument

\end{document} 

Best Answer

Why do you need different margins for the title page and the chapter pages? Do you mean that you need 2 cm margins on the regular pages, but 3 cm margins on the title page and the chapter pages?

As Harish Kumar suggested, you should use the geometry package to change the margins. For example, consider the output of the following code:

\documentclass{scrreprt}

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

\pagestyle{fancy}
\fancyhead{}
\fancyhead[RO,LE]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
\fancyfoot[CO,CE]{}

\title{Different margins in title and chapters}
\author{Me}

\begin{document}

\maketitle

\chapter{First Chapter}

\section{First Section}

\lipsum[1-20]

\section{Second Section}

\lipsum[1-20]

\chapter{Second Chapter}

\lipsum[1-20]

\end{document}

enter image description here