# [texhax] have a piece of thest ragged right à the end of a paragraph

Wilfried Kirschenmann wilfried.kirschenmann at gmail.com
Mon Sep 19 11:22:52 CEST 2011

Thanks.

It works perfectly !
-----
Cordialement,
Wilfried Kirschenmann

"An expert is a person who has made all the mistakes that can be made in a
very narrow field."*
*Niels Bohr - *Danish physicist (1885 - 1962)*

On Mon, Sep 19, 2011 at 10:30, Paul Isambert <zappathustra at free.fr> wrote:

> Le 19/09/2011 10:14, Wilfried Kirschenmann a écrit :
>
>  Hi,
>> I would like to write a command \toRight{#1} allowing me to align a piece
>> of thext to be flushed the right at the end of a justified paragraph,
>> creating a nex line of necessary.
>>
>
> \def\toRight#1{{\unskip\**nobreak\hfil\penalty50
>    \hskip2em\hbox{}\nobreak\hfil #1
>    \parfillskip=0pt \finalhyphendemerits=0 \par}}
>
> Explained in the _TeXbook_, page 106:
>
>    If a line break occurs at the \penalty50, the \hskip2em will disappear
> and the empty
>    \hbox will occur at the beginning of a line, followed by \hfil glue.
> This yields two lines
>    whose badness is zero; the fi
rst of these lines is assessed a penalty
> of 50. But if no line
>    break occurs at the \penalty50, there will be glue of 2 em plus 2 fil
> between the review
>    and the name; this yields one line of badness zero. TeX will try both
> alternatives,
>    to see which leads to the fewest total demerits. The one-line solution
> will usually be
>    preferred if it is feasible.
>
> (The review' is your paragraph and the name' is your argument to
> \toRight.)
>
> Best,
> Paul
> ______________________________**_________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/**texhax/<http://tug.org/pipermail/texhax/>