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

Steve Schwartz s.schwartz at imperial.ac.uk
Sun Dec 30 18:17:51 CET 2007

Dear All,

I have one that has defeated me, but should be solvable. 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]|

where | shows the edge of the text. Try as I might, I can't generate a
macro that will do this. It's easy to do the first, but if the line is
too long, leading space tends to get gobbled up and I end up with:

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

I've tried all manner of boxes, \phantoms, etc. The best I have managed
is:

\newcommand\qmarks[1]{\quad\nolinebreak\hfill{[#1~qmarks]}}

which needs to be placed immediately after the question without any
space, i.e.,

blah blah blah blah blah\qmarks{2}

This ALWAYS gets the marks to the right edge, because it drags the last
blah to the next line with it. This makes for ugly lines as tex
desperately stretches the rest out. I attach a short sample for someone
to play with.

With best wishes for the New Year,
Steve

--
+-------------------------------------------------------------------+
Professor Steven J Schwartz      Phone: +44-(0)20-7594-7660
Space and Atmospheric Physics    Fax:   +44-(0)20-7594-7772
The Blackett Laboratory          E-mail: s.schwartz at imperial.ac.uk
Imperial College London          Office: Huxley 6M70
London SW7 2BW, U.K.             Web: http://www.sp.ph.ic.ac.uk/~sjs
+-------------------------------------------------------------------+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rjust_marks.tex
Type: text/x-tex
Size: 1651 bytes
Desc: not available
Url : http://tug.org/pipermail/texhax/attachments/20071230/1fc0543e/attachment.bin


More information about the texhax mailing list