8

l

How can I decrease the white space marked with blue? I tried \vspace with negative marks but to no avail (it normally does the trick but not this time). I am using the 'fancyhdr'-package.

\documentclass[12pt, a4paper]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, amsmath, amssymb, fancyhdr, eulervm}

\setlength{\parindent}{0in}
\setlength{\headheight}{15pt}
\pagestyle{fancy}
\lhead{Left header, text}
\rhead{Right header, text}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\[
\int \!\! \int f(x,y) \, \text{d}x\text{d}y \quad \text{och} \quad \sum_{n=0}^{\infty}         \Big( n^2 + n + n! \Big)
\]
\end{document}
  • Welcome to TeX.SX! – barbara beeton Oct 4 '13 at 21:03
  • in the article class, the distance between the header and the baseline of the first line of text is a combination of \headsep (25pt) and \topsep (10pt). (i don't know whether this is changed by fancyhdr.) the one to decrease is \headsep; strange things can happen if you decrease \topsep and put a "tall" element in the first line. – barbara beeton Oct 4 '13 at 21:07
2

You can simply change the length of \headsep using the \setlength command, for example: \setlength{\headsep}{10pt}.

If I add at the end of your code:

\clearpage
\setlength{\headsep}{1pt}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I get the following result:

enter image description here

  • I noticed this only moves the header. Is it possible to fix the header and move the paragraph up towards it? – user37752 Oct 4 '13 at 21:40
  • @user37752 Please see my modified answer that shows that it is the paragraph that moves towards the header and not the other way round. – Pierre Oct 4 '13 at 23:10
  • Thanks a heap! By the way, why did you add in \clearpage? – user37752 Oct 5 '13 at 13:06
  • Force of habit. I could have used \newpage. A good answer about the difference between the two is found at tex.stackexchange.com/questions/45609/… – Pierre Oct 6 '13 at 22:21
  • And what if I only want this to affect more than one page, where I have more content after the page in question? I could of course just to \setlength{\headsep}{originalValue}, but I don't know how to obtain originalValue. Is there a way to restore it's default? – Anonymous Mar 6 '18 at 22:01
7

That distance is given by the headsep key when you use geometry. For example, adding headsep=1sp (just a very small amount) you'll see

enter image description here

\usepackage[...,headsep=1sp,...]{geometry}% http://ctan.org/pkg/geometry

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.