4

According to the documentation of memoir, chapter 8.4.1, the command \linenottooshort is supposed to make sure that the last line of a paragraph will not be shorter than an optional length (default 2em). So I expect the command to help me reduce the number of paragraphs that has short last lines.

However, the first MWE (without \linenottooshort) gives the result on the left in the figure below, while the second MWE (with \linenottooshort) gives the result on the right, which is clearly worse regarding short last lines.

I'm guessing that the text in the last line of the example on the right might not be shorter than 2em. But surely \linenottooshort ought not to make paragraphs worse than they would be without it? What's going on here?

Left:

\documentclass[11pt]{memoir}
\setlength{\textwidth}{120mm}
\setlength{\parindent}{0mm}
\usepackage{blindtext}

\begin{document}
\blindtext
\end{document}

Right:

\documentclass[11pt]{memoir}
\setlength{\textwidth}{120mm}
\setlength{\parindent}{0mm}
\usepackage{blindtext}

\linenottooshort

\begin{document}
\blindtext
\end{document}

before and after

Jostein Trondal
  • 1,165
  • 9
  • 20

1 Answers1

4

The location of \linenottooshort is wrong: it should go after \begin{document}, because before it memoir has not yet actualized the page dimensions.

Anyway, the command is bound to give other strange results, because it wrongly sets \@tempdima, which might change value without notice, being a scratch length register.

If you look at the value of \@tempdima after doing \linenottooshort in the preamble, you get 325.19989pt; done in the document environment, the value will be 297.63295pt.

A correct definition would be

\documentclass[11pt]{memoir}
\setlength{\textwidth}{120mm}
\setlength{\parindent}{0mm}
\usepackage{blindtext}

\makeatletter
\renewcommand*{\linenottooshort}[1][4em]{%
  \@tempdima=\hsize
  \advance\@tempdima -#1\relax
  %\leftskip\z@skip    % ???
  %\rightskip\leftskip % ???
  \begingroup\edef\x{\endgroup
    \parfillskip=\the\@tempdima \@minus \the\@tempdima\relax
  }\x
}
\makeatother

\AtBeginDocument{\linenottooshort}

\begin{document}

\blindtext

\end{document}

Beware that this might give strange results in minipage, \parbox or lists. I'm not really sure about its usefulness.

egreg
  • 1,121,712
  • Not sure about the command's usefulness? Indeed. It is a very good concept. But I am not sure if potential problems, in other parts of the paragraph, outweigh the usefulness. If the work is original fiction, I simply advise re-write. –  Apr 24 '17 at 22:25
  • Thank you @egreg. I noticed that tweaking the optional length of \linenottooshort also affected the inter word spacing of section titles(!). Two questions though, when has memoir actualized page dimensions? I was under the impression that this was complete after setting up the page layout with commands described in memman.pdf chapter 2 - Laying out the page, ending with \checkandfixlayout. Another related question: What commands affecting the whole document are necessary to put after begin{document}? – Jostein Trondal Apr 25 '17 at 07:26
  • 1
    @JosteinTrondal What memoir sets is \textwidth, but \hsize is set from the LaTeX parameter later on. – egreg Apr 25 '17 at 09:23
  • This works well until I change column layout with \onecolumn or \twocolumn (whichever was not in use when \linenottooshort was called). Can those commands be amended to run it again in a reliable way? – gnucchi Mar 29 '19 at 00:11
  • @svenper What's the problem? – egreg Mar 29 '19 at 07:20
  • @egreg If I change the MWE like this, page 2 will try to fill another length, causing large word space in this case. Is using \appto or similar, on the column switching commands, a reasonable workaround? – gnucchi Mar 29 '19 at 21:49
  • 1
    @svenper You need to issue \linenottooshort at every change from \onecolumn to \twocolumn or conversely. You can certainly add it to \onecolumn and \twocolumn. – egreg Mar 29 '19 at 22:00