4

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} 
  • 2
    You will be better off with geometry package for changing margins. However, adding \addtolength{\headwidth}{-1.5in} may be useful for you. Adjust the dimension as you wish. – user11232 Dec 18 '13 at 14:37
  • Please make your example a Minimal one. You cannot possibly need all of those packages to reproduce the issue, for example! – cfr Apr 17 '14 at 23:39
  • 1
    Note that it would be better to use the facilities offered by typearea if possible rather than geometry (but geometry is better than specifying the dimensions manually as you do here) and the facilities of the class you are using where possible e.g. rather than fancyhdr. You are probably getting American English but it would be better to specify american directly. You don't need to select a language when you are only loading one or until you wish to switch to a secondary language if you load more than one. – cfr Apr 17 '14 at 23:54
1

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

2

You school does strange stuff there. KOMA provides option titlepage=firstiscover that uses different margins for the first typeset titlepage. You can change the margins by redefining them.

It should be noted, that KOMA provides its own package for setting the header, fancyhdr should not be used.

Uncomment package showframe to better spot the differences.

\documentclass[twoside,headings=small,openright]{scrreprt}

\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage[utf8]{inputenc}

%\usepackage{geometry}
%\geometry{top=2cm,outer=4cm,inner=2cm,bottom=4cm}

%\usepackage{showframe}
\usepackage[automark]{scrlayer-scrpage}
\ohead{\rightmark}
\ihead{\leftmark}

\KOMAoption{titlepage}{firstiscover}
\renewcommand{\coverpageleftmargin}{%
\dimexpr \evensidemargin+2cm\relax}




\author{Johannes\_B}
\title{How to change the margins of the titlepage}
\subtitle{Foont}

\begin{document}
\pagestyle{empty} 
\maketitle

\tableofcontents

\cleardoublepage
\pagestyle{scrheadings}
\KOMAoption{headsepline}{true}

\blinddocument

\end{document} 

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.