[OS X TeX] Problem with \hfill

Jonathan Kew jonathan_kew at sil.org
Wed Oct 5 10:09:15 CEST 2005


On 3 Oct 2005, at 8:54 am, Bruno Voisin wrote:

> Le 2 oct. 05 à 19:04, Ewan Delanoy a écrit :
>
>
>> if I resize my page settings with the following commands :
>>
>> \addtolength{\textwidth}{4cm}
>> \addtolength{\textheight}{4cm}
>>
>> then \hfill has an unwanted behaviour : for example,
>>
>> \hfill {Q. E. D. } \newline              in the source file
>>
>> produces
>>
>> Line n      (...) Q.
>> Line n+1  E.D.
>>
>> in the output file. Does anyone know a way to fix this ?
>>
>
> To make sure "Q. E. D." isn't spread over several lines, you should  
> use unbreakable spaces namely "Q.~E.~D.", or even better include  
> the thing inside a box namely \mbox{Q.~E.~D.}.

Yes, using non-breaking spaces ("ties"), or putting the Q. E. D. in a  
box, will prevent a line-break occurring there; otherwise, TeX is  
free to consider those spaces as potential breaks.

However, this is probably not a sufficient solution in all cases,  
because a line-break could also occur at the \hfill glue, leaving "Q.  
E. D." flush LEFT on a line by itself. I'm guessing that if it  
doesn't fit on the end of the last line of the paragraph, it should  
appear flush RIGHT on the next line, but as the \hfill glue will be  
discarded if chosen as the line-break, that won't happen.

For a more complete solution, see page 106 of The TeXbook, where  
Knuth deals with a similar situation (reviewer's signatures at the  
end of articles in Mathematical Reviews). A "\QED" macro (untested)  
based on the example there might look something like this (see the  
book for explanation):

\def\QED{{\unskip\nobreak\hfil\penalty50\hskip2em\hbox{}\nobreak
   \hfil Q.~E.~D.\parfillskip=0pt \par}}

JK
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list