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

Lars Madsen daleif at imf.au.dk
Mon Sep 19 10:26:40 CEST 2011


Wilfried Kirschenmann wrote, On 2011-09-19 10:14:
>  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)
> 
> 

steal the \sourceatright macro from the memoir class sources

-- 

/daleif


More information about the texhax mailing list