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

Wilfried Kirschenmann wilfried.kirschenmann at gmail.com
Mon Sep 19 10:14:52 CEST 2011


 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.
Example 1 :
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph
\toRight{foo}

would create a paragrapph looking like :
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph            foo

Example 2 :
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph
\toRight{very long foo}

would create a paragrapph looking like :
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph
                                                                  very long
foo


Currently, I have
toRight defined such as :
\newcommand{\toright}[1]{%
\hspace{\stretch{1}}%
{\hfil\penalty 100 \hfilneg \raggedright \hbox{#1}}
}

It works perfectly fot rhe first example. It also correctly prevent the #1
argument to be splitted over several lines.
However, it doesn't allo to rag right when a new line is created.

with this implementation, Example 2 looks like :
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph
very long foo

which is not good.

Any Idea ?

-----
Regards,
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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20110919/57af29d5/attachment.html>


More information about the texhax mailing list