3

I'm trying to make the header "margin" bigger. It is to close to the edge. I've been trying to make \setlength{\headheight}{10pt} larger but then the page number moves to much down?

Any thoughts?

\documentclass[a4paper,12pt]{report}

\usepackage[margin=2cm]{geometry}
\usepackage{fancyhdr}
    \pagestyle{fancy}

\lhead{\nouppercase{\leftmark}}      % Set chapter in left header.
\rhead{\nouppercase{My University}}  % Set my university name in right header.
\setlength{\headheight}{10pt}        % ??????????????????

\begin{document}
    \chapter{First Chapter}                               %
    First chapter's content.
    \clearpage
    \section{Hello}
    The header is to close to the edge..
\end{document}
6
  • My suggestion would be to use the geometry option includeheadfoot which would include both the header/footer in your margin calculation. Then you can also specify headheight as part of \geometry{<options>}.
    – Werner
    Commented Nov 29, 2014 at 1:58
  • 1
    @bjartmar: Comment aside (I don't know how to send you this message in another way): you've deleted a question about formatting electronic citations with ieee bibliographic style. I had a solution to your problem. Are you still interested in having a solution, or is your question obsolete?
    – Bernard
    Commented Nov 29, 2014 at 10:47
  • @Bernard. I thought I deleted the question before somebody posted an answer. But I figured what my problem was and I fixed it. What I wanted to do was already built in the IEEE.bst/bibliography file... But my compiler was always looking for a "urldate" for the bibliography but "JabRef" made "timestamp". I just renamed every citation manually.
    – Bjartmar
    Commented Nov 30, 2014 at 2:41
  • @bjartmar: You can add new fields to JabRef.
    – Bernard
    Commented Nov 30, 2014 at 11:42
  • @Bernard: Yes, that's what I eventually did. I don't understand why I needed to do that. Some friends of mine didn't have to. Their bibliography used the "timestamp". Did not require "urldate".
    – Bjartmar
    Commented Nov 30, 2014 at 17:26

1 Answer 1

6

You get a warning;

Package Fancyhdr Warning: \headheight is too small (10.0pt): 
 Make it at least 14.49998pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.

fancyhdr tells you that header should be 14.4999pt high atleast. So make it 16pt to be safe. And do it with geometry package.

\usepackage[margin=2cm,top=2.5cm,headheight=16pt,headsep=0.1in,heightrounded]{geometry}

headsep=0.1in,heightrounded are other settings just for achieving perfection. In addition, you can increase the top margin as above.

\documentclass[a4paper,12pt]{report}

\usepackage[margin=2cm,top=2.5cm,headheight=16pt,headsep=0.1in,heightrounded]{geometry}
\usepackage{fancyhdr}
    \pagestyle{fancy}

\lhead{\nouppercase{\leftmark}}      % Set chapter in left header.
\rhead{\nouppercase{My University}}  % Set my university name in right header.
%\setlength{\headheight}{16pt}        %<---- Not this way

\begin{document}
    \chapter{First Chapter}                               %
    First chapter's content.
    \clearpage
    some text
    \section{Hello}
    The header is to close to the edge..
\end{document}

enter image description here

4
  • 1
    Nice! Thank you. I made the headsep a little larger. I don't like the text be to close to the header. :)
    – Bjartmar
    Commented Nov 29, 2014 at 2:13
  • One problem occurred. One of the electronic references in the bibliography splits between pages making the header with an hyperlink. Maybe not entirely cause of this... But that's another problem to solve.
    – Bjartmar
    Commented Nov 29, 2014 at 2:30
  • 1
    @bjartmar It is not due to geometry, I hope. Difficult to say without code.
    – user11232
    Commented Nov 29, 2014 at 2:32
  • It's true the margins doesn't cause this problem. Found the solution though. '\usepackage{etoolbox}' '\apptocmd{\thebibliography}{\interlinepenalty 10000\relax}{}{}'
    – Bjartmar
    Commented Nov 29, 2014 at 2:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .