1

I am trying to get my headings set up to meet my university's thesis formatting requirement. I'm using the titlesec package because it has the ability to suppress the spacing before the second heading when two headings appear in a row. That's a requisite given the school's guidelines. Things are mostly working out, but I'm running into two problems:

  1. The spacing before and after the first line of a display chapter heading is a bit larger than what I think I'm telling it to be.
  2. The spacing after the chapter heading is different for single and multiline chapter titles. (I don't need the text to start in the same place on every page, I just need the space between the bottom of the chapter title and the first line of text to be consistent.)

I've tried digging through the guts of titlesec.sty to try and figure out exactly what's going on, but that is a very steep uphill battle. It's quite the convoluted pile of code (with a lot of capability, of course).

So, I was wondering if anyone could lend some insight into what is triggering the extra space around the label and what is causing the inconsistent spacing following the title.

Recommendations on how to trace the processing and see exactly where the spaces are coming from would also be appreciated. I know that TeX has some debugging functions available, but I've never worked with them and the references I have describing them are a bit scary given my lack of TeXpertise. If there are some approachable tools I could be using, I'd love to be able to apply them in some other places, too. In particular, places where I have to switch back and forth between single and double spacing. That often results in me needing to insert some \vspace hacks to fix things up since I don't really know what's going on under the hood very well.

Here is a minimum working example that illustrates the problems I'm running into with the headings:

\documentclass[openany,oneside]{book}

\setlength{\headsep}{12pt}
\setlength{\headheight}{12pt}
\setlength{\topmargin}{-24pt}
\setlength{\textheight}{9in}
\setlength{\footskip}{24pt}

% Command to create a rule of the specified width and height, but pretending both are zero so it
% doesn't actually shift anything around. Optionally shift it vertically by a specified amount.
% \zeroSizeRule[verticalShift]{width}{height}
\newcommand{\zeroSizeRule}[3][0pt]%
{%
    \raisebox{#1}[0pt][0pt]{\makebox[0pt][l]{\rule{#2}{#3}}}%
}

\newcommand{\testFirstLineSpace}{\settoheight{\tempheight}{CHAPTER}\zeroSizeRule[\tempheight]{0.125in}{2in}\zeroSizeRule[-12pt]{0.25in}{12pt}}
\newcommand{\testHeadingToTextSpace}{\zeroSizeRule[-1in]{0.375in}{1in}}


\usepackage[explicit]{titlesec}

\newlength{\tempheight}
\titleformat{name=\chapter}%
    [display]% shape type
    {\normalfont\rmfamily\bfseries\LARGE\centering}% format for title text
    {\testFirstLineSpace CHAPTER \thechapter}% format for label 
    {12pt}% spacing between label and title text
    {\parbox[t]{4.5in}{#1}}% before code

\titlespacing{name=\chapter}%
    {0pt}% left margin increase - let the parbox take care of it
    {1in}% vertical space before title
    {1in}% vertical space after title

\newcommand{\filler}{\MakeUppercase{A quick brown dog with memory problems jumped over the lazy fox over and over and over and over and over and over again.}}

\begin{document}

\mainmatter

\chapter{TEST THAT IS LONG ENOUGH TO WRAP ONTO A SECOND LINE\testHeadingToTextSpace}
\filler

\chapter{SHORTER TEST\testHeadingToTextSpace}
\filler

\end{document}
6
  • Not that it directly answers your question, but I might recommend looking at memoir for your base class. I'm using it for my university thesis/dissertation style, and my current chapter formatting setup can be found here. There's a decent chance that by the time you've pieced together enough packages and other code to satisfy all your university's requirements, you'd have ended up with less code using memoir. Commented Jun 4, 2011 at 22:51
  • @Mike: Thanks for the tip on the memoir package. I wasn't familiar with it, but will keep it in mind for the future. At this point, I'm probably 80% of the way there using book as my base class, so the effort of finishing up with that route will be less, but it's always good to know more about what's out there.
    – E J
    Commented Jun 4, 2011 at 22:58
  • If my experience is any guide, then all you've got left is the remaining 80%. memoir does include titlesec-like functionality, but the commands are completely different (and I think titlesec's are harder to deal with, but I may be biased). The only time I've used titlesec at all is for one custom article class, and really only to do runin subsubsection headers. Commented Jun 4, 2011 at 23:17
  • Before making all the effort to coerce TeX to match with your university's strange formatting requirements, have you checked that nobody did this work for you already? Eg, I see a uuthesis package here that deals with the 'inverted pyramid' for titles you were asking earlier, and presumably all of the strange vertical spacing rules. If there's something that doesn't quite work you could always submit a patch to that, rather than starting from scratch. (Writing a thesis is already enough work without the distraction of creating the TeX format).
    – Lev Bishop
    Commented Jun 4, 2011 at 23:41
  • @Lev: You are quite handy searching for stuff. And I thought I left the poor U of U anonymous. (?) That's the class file I used to get it close enough to submit to my committee, but it's woefully antiquated and does not automatically meet all the formatting requirements. The 2011 refresh just updated the page margins, but captions, subheadings, the frontmatter material, equation spacing, and a laundry list of other items aren't handled correctly. I'm definitely using it for inspiration, but found it best to build off the book class since I couldn't even get hyperref to work with the original.
    – E J
    Commented Jun 4, 2011 at 23:44

1 Answer 1

1

For question #1 change the spacing parameters.

For question #2, use

\titleformat{name=\chapter}%
    [display]% shape type
    {\normalfont\rmfamily\bfseries\LARGE}% format for title text
    {\testFirstLineSpace \filcenter CHAPTER \thechapter\filcenter}% format for label 
    {12pt}% spacing between label and title text
    {\leavevmode\vbox{\hsize=4.5in\parindent=0pt#1}}% before code

Maybe the \stupid macro of the other question may be put there. I've deleted the \centering as this makes centered also the text in the \vbox.

Not an explanation :)
The right vertical alignment can be obtained also with \parbox by fooling LaTeX as to what is the top of the \parbox:

\parbox[t]{4.5in}{\hrule height0pt\relax#1}

Now the top is exactly the \hrule.

7
  • @egreg: I suspect you forgot one closing brace, and even with the brace added I could not get your example working.
    – lockstep
    Commented Jun 4, 2011 at 22:37
  • @lockstep: actually there was an open brace too many.
    – egreg
    Commented Jun 4, 2011 at 22:44
  • @egreg: I see I wasn't completely clear on the concerns I have about the spacing following the chapter title. I don't need the text to start in the same place on every page; rather, I need the space between the title and the text to be consistent. Also, I lean towards using LaTeX constructs like \parbox because I've read the LaTeX manual, but not the TeXBook, so I get a little scared of unknown ramifications when I start using raw TeX stuff. Not that I'm totally adverse to doing so, as in the \stupid command you helped me hack out. :-)
    – E J
    Commented Jun 4, 2011 at 22:46
  • @egreg: Indeed, but your example still doesn't work for me. (I'm probably doing something stupid.)
    – lockstep
    Commented Jun 4, 2011 at 22:52
  • @lockstep: now it should be clearer.
    – egreg
    Commented Jun 4, 2011 at 23:09

You must log in to answer this question.

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