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.

This question led to a new feature in a package:
impnattypo

One rule in French typography is that the last line of a paragraph should not be shorter than the double of the indentation of the next paragraph.

Is it possible to specify that, or least considering that all paragraphs are indented of the same value, to make sure the last line is longer than twice this value?

A LuaTeX-specific solution is welcome, too.

share|improve this question
2  
The more I read about french typography, the more I think they have some really odd conventions… –  Seamus Jan 17 '12 at 22:22
    
The requirement that the last line of a paragraph should not be shorter than the indent of the next one is also common in german typography. –  Stephan Lehmke Jul 18 '12 at 17:21
    
@StephanLehmke: then you can also use this option in impnattypo in German :-) –  ℝaphink Jul 19 '12 at 5:31
    
@Raphink I'm very seldomly writing documents with LaTeX, but I've just fixed a bug in the respective configuration option of DocScape to enable this ;-) –  Stephan Lehmke Jul 19 '12 at 6:40

2 Answers 2

up vote 22 down vote accepted

You asked for a LuaTeX solution and you get one:

\documentclass{article}
\usepackage{luatexbase,luacode}

\begin{luacode}
last_line_twice_parindent = function (head)
  while head do
    local _w,_h,_d = node.dimensions(head)
    if head.id == 10 and head.subtype ~= 15 and (_w < 2 * tex.parindent) then

        -- we are at a glue and have less then 2*\parindent to go
        local p = node.new("penalty")
        p.penalty = 10000
        p.next = head
        head.prev.next = p
        p.prev = head.prev
        head.prev = p
    end

    head = head.next
  end
  return true
end

luatexbase.add_to_callback("pre_linebreak_filter",last_line_twice_parindent,"Raphink")
\end{luacode}


\begin{document}
\parindent = 2cm
\emergencystretch = \hsize

A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel.

The charm of existence in this spot, which was created for the bliss of souls like mine. 

I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be
incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now.

\end{document}

What it does is it adds ties (~) between the words at the end of a paragraph, when the distance to the end is less then 2*\parindent. If the \parindent is large enough, the paragraphs will get ugly.

ugly paragraph

share|improve this answer
    
Thanks. I've very interesting to see what can be done with LuaTeX. I'll favor the native, more portable solution, but I'm still interested in the LuaTeX one. –  ℝaphink Sep 13 '11 at 20:59
    
I understand, but I have slight feeling that a native solution based on parfillskip will not handle all situations (see my example in my comment to egreg's solution). –  topskip Sep 13 '11 at 21:07
    
I actually found some other examples in a book of mine where your Lua code worked and not @egreg's setting. –  ℝaphink Sep 13 '11 at 22:00

At the end of each paragraph, TeX usually adds infinitely stretchable glue, since the usual setting of \parfillskip is equivalent to

\setlength{\parfillskip}{0pt plus 1fill}

One way might be to set

\setlength{\parfillskip}{0pt plus\dimexpr\textwidth-2\parindent}

but this would work only for normal paragraphs. In lists one should reset the \parfillskip with \linewidth instead of \textwidth: its value stated as before is not dynamically computed, but rather it's fixed. If \parfillskip had been a macro, instead of a skip parameter (or if Knuth had provided an \everyendofpar token parameter), things would be different. One might redefine \par, of course, but LaTeX already does it in some cases.

Note that glue can always stretch more than the stated value, but in this case the badness of the line would increase, usually producing an Underfull \hbox message. In general I'm inclined not to be overly confident in automatic adjustments like this: no automated system will be able to do this as well as you, writes Knuth about page breaking, but paragraph breaking is very much alike, particularly with respect to the final line.

share|improve this answer
    
The \setlength solution works well :-) –  ℝaphink Sep 13 '11 at 20:26
    
@egreg somehow this solution doesn't work with the extreme settings (and the example) from the example I have chosen (see my answer). Perhaps I have made a mistake!?! –  topskip Sep 13 '11 at 20:41
    
@Patrick: your text works for me. It doesn't if I say \frenchspacing; that's why I said that "automated" adjustments are risky. Your tie might not work either, because TeX might choose to hyphenate in the preceding line. –  egreg Sep 13 '11 at 20:52
    
@egreg can you construct an example where my solution breaks? I'd be very interested! –  topskip Sep 13 '11 at 20:54
    
@egreg this is an example where your solution doesn't work for me: raw.github.com/gist/1215149/… - what am I doing wrong? –  topskip Sep 13 '11 at 20:58

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.