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.

For the needs of a running title (in header), I would like the text of a running title (in header) to be stretched over the page. So far, I stretch it manually (using LetterSpace and WordSpace in fontspec), but my chapters can have pretty short or very long titles, so either short chapters will be not-so-stretched, or long chapters will look horrible.

Is there a way to adapt the stretching dynamically?

share|improve this question
    
You know about the short version of chapter titles which can be given with the optional argument of \chapter, don't you? This is the normal way to handle longer chapter titles in headers. –  Martin Scharrer Jun 13 '11 at 12:34
    
Ah, interesting @Martin. I use this to typeset chapter titles properly on their page while keeping them correct in the ToC. –  ℝaphink Jun 13 '11 at 12:37
add comment

4 Answers

up vote 2 down vote accepted

You can use \resizebox{\linewidth}{!}{Your headline} from the graphicx package to stretch the text over the full line width or any other width you want. This of course will give shorter chapter titles a larger font than longer ones. I'm not sure what you want exactly.

share|improve this answer
    
Thanks. I don't expect the font size to adapt, rather the amount of spaces between letters and words (an effect a la \textls). –  ℝaphink Jun 13 '11 at 10:55
    
@Raphink: I see. You could measure the natural text width and compare it with the available width, but you would also need to know the amount of letters and words to calculate the correct letter spacing. This doesn't seem very easy. You could use \resizebox{<some width>}{\height}{Your headline} to stretch the text without changing the height, but this wouldn't look good. –  Martin Scharrer Jun 13 '11 at 11:41
    
right, keeping the height and resizing the width might look very ugly. –  ℝaphink Jun 13 '11 at 11:42
1  
@Raphink: It will look ugly also expanding the spaces. –  egreg Jun 13 '11 at 16:15
    
Hehe... de gustibus et coloribus... –  ℝaphink Jun 13 '11 at 17:58
add comment

TeX can increase the natural width of a \hbox by a given absolute amount like shown below. You probably want to increase that amount based on the natural width of a given text and I'm sure someone more versed with TeX's boxes could provide a macro that adds, say, 10% of extra spacing by first measuring the natural width.

\documentclass{article}
\begin{document}
\section{\hbox spread 15pt{Headline with 15pt of extra spacing}}
\section{\hbox spread 5pt{Headline with 05pt of extra spacing}}
\end{document}

Two headlines with different spacing

share|improve this answer
add comment

I am not sure if I understand your question. However, \spaceskip 3.333pt plut 1fill minus 0pt could be useful to you

share|improve this answer
add comment

I have actually chosen another solution to my problem.

Since I capture the current chapter title as \chaphead during \chapter assignment in order to display it in the header, I am actually redefining \chaphead to be shorter in the case of a very long chapter title:

% Use first argument for ToC (lots of space there)
% Second argument for title display (on two lines)
\chapter[Pourquoi le charisme se change souvent en charismanie]%
  {Pourquoi le charisme\\ se change souvent en charismanie}
% Reset running title to be shorter
\renewcommand{\chaphead}{Pourquoi le charisme se change souvent\dots{}} 
share|improve this answer
add comment

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.