[texhax] forcing a piece of text to the right margin, even on a blank line

Phillip E. Parker phil at math.wichita.edu
Mon Dec 31 11:08:44 CET 2007


On 12/30/2007 at 05:17 PM, Steve Schwartz <s.schwartz at imperial.ac.uk> wrote:

> Our exam style puts
>the marks for a particular question on the last line of that question, but
>pushed to the right edge (with a bit of leading space) if there's room. Else
>it goes on the next line all by itself, but still aligned along the right
>margin, i.e.,

>|blah blah      [2 marks]|

>and

>|blah blah blah blah blah|
>|               [2 marks]|

Cribbed from the TeXbook c.1996. (Core only -- it's part of my proof style, but you should be able to spot the irrelevant bits for your purpose.)

 \leavevmode\ifproof\global\proofendedtrue\fi
 \ifhmode\unskip\nobreak\hfil\penalty 50 
    \hskip.4em\hbox{}\nobreak\hfil\eops[.5ex]
    \parfillskip=0pt \finalhyphendemerits=0

The trick is to make it adjust the last two lines of the preceding text nicely. (The complete style also adjusts for display math.) \eops is the call to my "end of proof" symbol macro.

-- 
    Phil Parker
--------------------------------------------
URL http://www.math.wichita.edu/~pparker/
Random quote:
  Writing about music is like dancing about architecture.




More information about the texhax mailing list