9

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}
Werner
  • 603,163
user37752
  • 163
  • 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 04 '13 at 21:07

2 Answers2

10

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
Werner
  • 603,163
5

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

Pierre
  • 883
  • I noticed this only moves the header. Is it possible to fix the header and move the paragraph up towards it? – user37752 Oct 04 '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 04 '13 at 23:10
  • Thanks a heap! By the way, why did you add in \clearpage? – user37752 Oct 05 '13 at 13:06
  • Force of habit. I could have used \newpage. A good answer about the difference between the two is found at http://tex.stackexchange.com/questions/45609/is-it-wrong-to-use-clearpage-instead-of-newpage – Pierre Oct 06 '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? – pretzlstyle Mar 06 '18 at 22:01
  • Hello! I know this is an old post. When \headsep is decremented, it moves up the body and foot of the page. I want to fix both header and footer when either footskip or headsep is modified. – mariovilar Nov 06 '22 at 18:44