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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to fully stretch one line of text on the full width of the page, without manually setting the letter spacing, no matter how many characters on the line?

share|improve this question
If it is just one line, adding \hfill between each word should produce the output you desire.. – Peter Grill Apr 2 '12 at 20:39
I did not really make that clear, sorry for that, but I am looking for a method that solves this by letter-spacing, not word-spacing. See my comment below – grrrbytes Apr 2 '12 at 21:18
look at the letterspacing tag: tex.stackexchange.com/questions/tagged/letterspacing – David Carlisle Apr 2 '12 at 21:24
tnx, I am aware of that. However, this gives less flexibility in the sense you have to constantly alter the letter-spacing relative to the amount of characters, font, font-size, font-type and width of page. The examples below are quite close to what I want, however, they distribute on word-spacing – grrrbytes Apr 2 '12 at 21:29
@Mixhael You could make your intent clearer; letterspacing is generally not a good typographical device for getting justified text. – egreg Apr 2 '12 at 21:38
up vote 16 down vote accepted

I assume you are referring to the spacing between words (or inter-word spacing) when you reference "a line text".

If the number of characters will always fit on the line, then the optional s-parameter for \makebox alignment inserts enough inter-word spacing stretch to fill the box. If the text is greater than the box width, an overfull \hbox warning is generated:

enter image description here

\setlength{\parindent}{0pt}% Just for this example.
\makebox[\linewidth][s]{Here is some text.} \par
\makebox[\linewidth][s]{Here is some more text.} \par
\makebox[\linewidth][s]{Here is a whole whack of text, plus some punctuation.} \par
\makebox[\linewidth][s]{Here is a whole whack of text, plus some punctuation, and then some more text.} \par
\makebox[\linewidth][s]{Here is a whole whack of text, plus some punctuation, and then some more text, and nothing else.} \par

The last line stretches beyond the text margin. In the above minimal working example (MWE), replacing \linewidth with \textwidth would also work.

For inter-letter spacing, the soul package can be of help. You define your own inter-letter, inner and outer spaces via a command \sodef{<cmd>}{<font>}{<inter-letter>}{<inner space>}{<outer space>}:

enter image description here

\usepackage{soul}% http://ctan.org/pkg/soul
\setlength{\parindent}{0pt}% Just for this example.
\sodef\spaceout{}{0pt plus 1fil}{.4em plus 1fil}{0pt}
\makebox[\linewidth][l]{\spaceout{Here is some text.}} \par
\makebox[\linewidth][l]{\spaceout{Here is some more text.}} \par
\makebox[\linewidth][l]{\spaceout{Here is a whole whack of text, plus some punctuation.}} \par
\makebox[\linewidth][l]{\spaceout{Here is a whole whack of text, plus some punctuation, and then some more text.}} \par
\makebox[\linewidth][l]{\spaceout{Here is a whole whack of text, plus some punctuation, and then some more text, and nothing else.}} \par

Since I am unfamiliar with this kind of modification, consider this just a guide to get you going. The soul package documentation (section 3 Letter spacing, p 8 onward) is filled with examples.

I'm sure microtype would also be able to facilitate your needs.

share|improve this answer
Thanks all. This is exactly what I meant, however: I was looking for a method that spreads text evenly on a horizontal line by increasing the letter-space, instead of the word-space. Is that possible too? – grrrbytes Apr 2 '12 at 21:17
So, 'exactly' was not the right wording. It is very close to what I want – grrrbytes Apr 2 '12 at 21:30
Tnx @Werner, will look into the soul package – grrrbytes Apr 2 '12 at 21:54

spread as a command to a box instruction is built into tex (texbook, p.77):

\hbox spread \linewidth{Here is some text.}

text spread to line width

share|improve this answer
Thanks, see my comment above :) – grrrbytes Apr 2 '12 at 21:17
spread -- learning something new all the time :) – yo' Apr 3 '12 at 12:38

if you want to stretch all the letters evenly rather than words you can use:


\spreadeven{A fox jumped over the lazy dog}

This uses the LaTeX kernel @tfor to iterate over all the letters and add hfill between them.

share|improve this answer
Thanks for that. It almost does it as I wanted it, however it seems not to take spaces into consideration, so spaces won't be doubled. I can't differentiate between words anymore – grrrbytes Apr 2 '12 at 21:57
@Mixhael I answered this way based on your comments in Werner's answer. i think what you are looking is \so{} using the soul package. – Yiannis Lazarides Apr 2 '12 at 22:03

Using the soul package

enter image description here


\sodef\ugg{}{.4em plus 1fill}{1em plus 2 fill}{2em plus 2fill minus.1em}


\noindent\ugg{one two three\\four five six}

share|improve this answer
Many thanks @David – grrrbytes Apr 3 '12 at 0:29

In ConTeXt there is the \stretched macro for this purpose. Example:

    \stretched{Here is some text}


share|improve this answer

Your Answer


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.