9

Sometimes, you don't care about the "beauty" of TeX line-breaking algorithm, but just want that one or two extra lines in a document. When faced with such a situation, I start adding ~ at appropriate places, and hope that TeX finds a line-breaking that uses less number of lines. And if often does!

Are there values of the TeX line-breaking parameters that bias the result towards fewer lines in a (justified) paragraph. Note that I already use hanging punctuation.

8

From TeX by Topic (section 19.1.4 The number of lines of a paragraph, p 178):

Deviations from the optimal number of lines, that is, the number of lines stemming from the optimal way of breaking a paragraph into lines, can be forced by the user by means of the \looseness parameter. This parameter, which is reset every time the shape parameters are cleared (see Chapter 18), indicates by how many lines the current paragraph should be made longer than is optimal. A negative value of \looseness will attempt to make the paragraph shorter by a number of lines that is the absolute value of the parameter.

TeX will still observe the values of \pretolerance and \tolerance (see below) when lengthening or shortening a paragraph under influence of \looseness. Therefore, TeX will only lengthen or shorten a paragraph for as far as is possible without exceeding these parameters.

An example of this, in action (and where it was possible to adjust the number of lines:

enter image description here

\documentclass{article}
\usepackage{geometry,lipsum}
\geometry{margin=1in}% Just for this example
\begin{document}
\lipsum[1]

\looseness=-1% Try one fewer line for the following paragraph
\lipsum[1]
\end{document}
3

I don't think there is an absolulte answer to that. There are several options you could tweak, and there is no obvious limit in how much you could tweak for instace interword space before it would be ridiculous.

That said, you can directly tell TeX that you would like a particular paragraph to be one line shorter with \looseness=-1 before the paragraph:

\documentclass{article}
\usepackage[american]{babel}
\usepackage{blindtext}
\usepackage{lineno}             % just to see the effect

\begin{document}

\section{Normal}
\begin{linenumbers*}
  Here is an example.
  \blindtext
\end{linenumbers*}

\section{Tighter}
\begin{linenumbers*}
  \looseness=-1
  Here is an example.
  \blindtext
\end{linenumbers*}
\end{document}

(There is no guarantee that TeX will find a way to do that just because you ask for it though.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.