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.

Again me, still trying to emulate a very specific layout...

I used the titlesec package to define chapter and section titles, and am very pleased with the outcome... except of some ponts' worth of vertical space that keep showing up in places where I don't want them. Perhaps you guys can help me out here.

The almost-M-WE is below... all pt values in the source have been figured out from the original with a ruler, I left them in because they are as good as any. Never mind the faulty subsection numbering, that's been taken care of in the "real" document.

This code almost works. I have two problems with it though:

  • If the chapter title contains an Umlaut (Ä, Ö, Ü), additional vertical whitespace gets added between the bars and the title. This isn't exactly a showstopper as I could rename the chapters in a way so they don't contain Umlauts, but I would like to know why this happens and if there is a way to avoid it.

  • I used a baseline smaller than the fontsize in the \subsection and \subsubsection formats to emulate the very compact layout of the original book. However, this setting seems to work only between the second and third line of a long title - there is extra vertical whitespace between the first and second line, which does not get reduced even if I set a yet smaller baseline. If it were the other way around, I could easily work around having three-line titles, but I cannot avoid having two-line titles, and would like to know how to reduce that vspace.

Thanks in advance, you guys have been a great help already in my quest into the LaTeX world!

\documentclass[open=any,twocolumn]{scrbook}

\usepackage[scaled]{helvet}
\usepackage{times}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{titlesec}

\titlespacing{\chapter}{0pt}{0pt}{11pt}
\titlespacing{\section}{0pt}{14pt}{0pt}
\titlespacing{\subsection}{0pt}{11pt}{0pt}
\titlespacing{\subsubsection}{0pt}{5pt}{0pt}

% scaleable chapter bars, credit to Gonzalo Medina, tex.sx #17124
\newcommand*\varhrulefill[1][17pt]
{\leavevmode\leaders\hrule height#1\hfill\kern0pt}

\renewcommand\thechapter{\arabic{chapter}.0}
\titleformat{\chapter}[display]
    {\normalfont\fontsize{25pt}{0pt}\bfseries\sffamily}
    {\varhrulefill\enskip\thechapter\enskip\varhrulefill}
    {-4pt}
    {\center\MakeUppercase}

\newcommand{\trailthesubsection}[1]{\MakeUppercase{#1} (\thesubsection)}
\titleformat{\subsection}
    {\normalfont\fontsize{15pt}{14pt}\bfseries\sffamily}
    {}
    {0pt}
    {\filcenter\trailthesubsection}

\titleformat{\subsubsection}
    {\normalfont\fontsize{12pt}{11pt}\bfseries\scshape}
    {}
    {0pt}
    {\filcenter}

\begin{document}

\chapter{Functional}      % This one looks as it should

\chapter{Düsfunctional}   % The Umlaut triggers extra vspace

% Notice the extra, non-reducable whitespace after the first line break
\subsection{My Long Subsection Title breaking the line twice}
\subsubsection{My Very Long Subsubsection Title actually breaking the line twice}

\end{document}

A pasted-together output sample. Red lines point out the offending vspace.

Red lines point out the offending vspace.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

Question 1: You have to "hide" the height of the title

\renewcommand\thechapter{\arabic{chapter}.0}
\titleformat{\chapter}[display]
    {\normalfont\fontsize{25pt}{0pt}\bfseries\sffamily}
    {\varhrulefill\enskip\thechapter\enskip\varhrulefill}
    {12pt} % <--- modify this for lowering the title
    {\center\ignoretitleheight}
\newcommand{\ignoretitleheight}[1]{\leavevmode\smash{\MakeUppercase{#1}}}

Question 2: You have to avoid inserting the \lineskip when two lines are "too near" to each other

\newcommand{\trailthesubsection}[1]{\MakeUppercase{#1} (\thesubsection)}
\titleformat{\subsection}
    {\normalfont\fontsize{15pt}{14pt}\bfseries\sffamily\lineskiplimit=-\maxdimen}
    {}
    {0pt}
    {\filcenter\trailthesubsection}

\titleformat{\subsubsection}
    {\normalfont\fontsize{12pt}{11pt}\bfseries\scshape\lineskiplimit=-\maxdimen}
    {}
    {0pt}
    {\filcenter}

However the spacing won't be uniform if some character is higher than the stated baseline skip (an accented uppercase letter, for example).

share|improve this answer
    
Answer 1 worked like a charm. As for Answer 2... now that you've set me on the right track, any reason why I shouldn't just \setlength{\lineskip}{0pt}? It looks good enough in the context of the MWE, and my book won't have much (if any) math or figures in it...? (On second thought, wouldn't \squashing the titles help with the accented uppercase letters here, too?) –  DevSolar Sep 29 '11 at 14:52
    
Setting \lineskiplimit to -\maxdimen will even avoid putting \lineskip glue. And, contrary to what I said, will give uniform spacing, but higher characters will possibly overlap with the line above. \smash makes a hbox, so no line break is possible. –  egreg Sep 29 '11 at 14:57
    
Many thanks for the explanation, I really was wondering. ;-) –  DevSolar Sep 29 '11 at 15:03
    
One more question, if you don't mind... how come TeX figured that \lineskip is necessary, but only in the first line break? –  DevSolar Sep 29 '11 at 15:33
    
I suspect that titlesec puts a strut at the beginning of the title. –  egreg Sep 29 '11 at 16:16

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.