Tell me more ×
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
show 1 more comment

2 Answers

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.
http://tex.stackexchange.com/questions/84879/cant-increase-spacing-before-section-title
tex.stackexchange.com
crawl=CC-MAIN-2013-20
53467
application/http; msgtype=response
sha1:5FD4F4VA5UYX24UBPKR673MZS5N23UK2
<urn:uuid:71ee0879-bce5-4c88-abe2-de15971762d6>
2013-05-22T10:59:46Z
198.252.206.16
sha1:A5BTPT35WV4K6ZQBKCE7WGNLOEYSNRBW
<urn:uuid:4fd00b6c-7f19-412d-8c1d-2edc8da8b15c>
http://tex.stackexchange.com/questions/84879/cant-increase-spacing-before-section-title
response
<urn:uuid:f6fd9cea-66ee-457a-8978-10bc51b178e0>
robots: classic
hostname: ip-10-60-113-184.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2013-20
operator: CommonCrawl Admin
description: Wide crawl of the web with URLs provided by Blekko for Spring 2013
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf