2

I would like to increase the spacing between each word in the last line of each paragraph.

I am using the command {\hbox spread 10pt{...}} to achieve this, but noticed that the space between words is not constant depending of the length of the last line. For example, a short last line will have larger spaces between words than a longer line, even though the same hbox with the same parameters is used.

Is there a way to fix this?

Thanks!

10
  • 1
    how are you adding hbox??? by hand after you see where tex breaks the line? Feb 6, 2023 at 18:40
  • @DavidCarlisle Yes. I enclosed by hand the last line of each paragraph into a \hbox
    – Beginner
    Feb 6, 2023 at 18:41
  • 1
    why?........... what would you do if the natural length did not leave 10pt? Feb 6, 2023 at 18:42
  • 1
    that is not, in general, the case. Feb 6, 2023 at 18:50
  • 1
    @Beginner with the default \parfillskip the last line is set to its natural width, other lines may have spaces stretched or shrunk to justify the text. So on average the final line should be the same as the others, always stretching by 10pt seems very wrong Feb 6, 2023 at 18:57

2 Answers 2

2

enter image description here

You can adjust the stretch on the last line by adjusting \parfillskip

\documentclass{article}

\newcommand\qq{\smash{\kern-1pt\rule[-5cm]{1pt}{5cm}}}
\begin{document}

One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.\qq

\setlength\parfillskip{0pt plus \textwidth}% always safe but only slight stretch
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.\qq


\setlength\parfillskip{0pt plus .5\textwidth}% more stretch but may cause underfull boxes
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.\qq
\end{document}
1

etex introduced the (rarely used) command \lastlinefit, which will adjust the stretch and shrink components in the last line according to those in the preceding one: it accepts values between 0 and 1000, where 0 means that the line will be typeset at its natural width, 1000 means that it will be typeset with the same interword spaces as the preceding line; any values between 0 and 1000 will be an interpolation of the two extremes.

Putting \lastlinefit=1000 (or 500 or whatever your prefer) into your preamble should therefore solve your problem.

1
  • +1 I can live without another green tick Feb 7, 2023 at 15:58

You must log in to answer this question.

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