Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm having troubles with increasing spacing between the header and section title. As suggested in titlesec package documentation, I added the following line to my preamble: \titlespacing{\section}{0pt}{4em}{3em}. If I understand correctly, it should provide 4em space before the section title and 3em space after it. However, it does not: that space before the title is clearly smaller, as you can see:

image1

I figured one ugly workaround: if I write \vspace*{0em} right before the \section{...}, the gap increases, however this time it's definitely bigger than 4em:

image2

The only way that could somehow solve my problem by far is to put there something like \vspace*{-40em}, but that's incredibly ugly and I would rather not do that by any means.

Google didn't help much. In fact, some results showed that people have issues with decreasing this size, but I didn't find much of a relevant info for my case.

The code I used for this example:

\documentclass[a4paper,14pt]{extarticle}
\usepackage[cm-default]{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{lipsum}
\usepackage[left=3cm,top=2.5cm,right=1cm,bottom=1.5cm]{geometry}

\usepackage{fancyhdr}
\fancyhead{}
\fancyhead[CH]{header}
\addtolength{\headheight}{\baselineskip}
\fancyfoot{}
\pagestyle{fancy}

\usepackage[compact]{titlesec}
\titleformat{\section}[block]{\filcenter\Large\bfseries}{\thesection}{1ex}{\uppercase}
\titlespacing{\section}{0pt}{4em}{3em}

\begin{document}
    %\vspace*{0pt}
    \section{Lorem ipsum}
    \lipsum[1-3]
\end{document}

I would really appreciate any suggestions!

share|improve this question
1  
Welcome to TeX.SX! The behavior is perfectly normal for a section title that starts a new page. The gap you see from the header rule and the title is the "headsep". So, if you add \vspace*{0pt} you get 4em plus the headsep. –  egreg Nov 29 '12 at 22:21
    
Are you sure you meant \vspace*{-40em}? -4 seems more reasonable. –  Ryan Nov 29 '12 at 22:25
    
@egreg Thanks for quick reply! Indeed, I forgot about the headsep when I was writing this example. So what would be the best way to work this around? I could write something like \vspace*{-\headsep} before every section, but it looks ugly to me—or is this perfectly fine? –  Kona-chan Nov 29 '12 at 22:26
    
@Ryan I actually meant -40pt, my mistake. Thanks for notice. –  Kona-chan Nov 29 '12 at 22:26
1  
@Kona-chan The problem is only in sections that start a new page. I really can't understand why you need them to stay so low. –  egreg Nov 29 '12 at 22:30

2 Answers 2

up vote 5 down vote accepted

A possible approximation to the specifications (as usual made by people that show little knowledge of typography, as testified by the 14pt size) is as follows:

\documentclass[a4paper,14pt]{extarticle}
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage[left=3cm,top=2.5cm,right=1cm,bottom=1.5cm,headsep=\baselineskip]{geometry}

\usepackage{fancyhdr}
\fancyhead{}
\fancyhead[C]{header}
\setlength{\headheight}{17pt}
\fancyfoot{}
\pagestyle{fancy}

\usepackage{etoolbox}
\newcommand{\sectionfix}{\newpage\vspace*{3\baselineskip}\nointerlineskip}

\usepackage[compact]{titlesec}
\titleformat{\section}[block]{\filcenter\Large\bfseries}{\thesection}{1ex}{\MakeUppercase}
\titlespacing{\section}{0pt}{0pt}{3em}

\preto{\section}{\sectionfix} % sections start a new page

\begin{document}
    \section{Lorem ipsum}
    \lipsum[1]
    \section{Lorem ipsum}
    \lipsum[1]
\end{document}

Notice that \MakeUppercase is better than \uppercase; the package xunicode is loaded automatically by fontspec, while xltxtra is not required nor recommended as it used to be (but you can load it if you want).

enter image description here

share|improve this answer
1  
Thank you! It was helpful, I managed to somehow modify your code so it would work with \doublespacing—my apologies for not making it clear I have to use double spacing to begin with. Looks like it will have to do with some precisious font manipulation. At least I no longer need to write \vspace*{0em} every time. –  Kona-chan Nov 29 '12 at 23:08
1  
@Kona-chan You mean that you're requested to have 14pt font size and double spacing? That's simply crazy. :( –  egreg Nov 29 '12 at 23:12
    
Yeah, our specs give me a headache. –  Kona-chan Nov 29 '12 at 23:22

Based on the discussion between @Kona-chan and @egreg, especially the rhetorical:

I could write something like \vspace*{-\headsep} before every section, but it looks ugly to me—or is this perfectly fine?

I think what you may want to do is something like \renewcommand{\headsep}{1pt} after \begin{document}. That will alter all the sections that start a new page.

I agree with @egreg that it seems unattractive. But specs are specs.

share|improve this answer
1  
But it would affect the pages that doesn't contain new section as well, effectively pushing all text up, wouldn't it? –  Kona-chan Nov 29 '12 at 22:52
    
Yeah...thought that was what you wanted...everything jutting up against the header. Guess not. @egreg's answer seems better. –  Ryan Nov 29 '12 at 23:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.