[texhax] forcing a piece of text to the right margin, even on a blank line
Michael T. Wescoat
wescoat at cruzio.com
Sun Dec 30 18:51:35 CET 2007
Hi,
On Dec 30, 2007, at 9:17 AM, Steve Schwartz 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 do the following, based on the discussion on p. 106 of _The TeXbook_:
\newcommand{\rtuck}{\@ifnextchar[{\@rtuck}{\@rtuck[1em]}}
\def\@rtuck[#1]#2{{\unskip\nobreak\hfil\penalty50\hskip#1\null
\nobreak\hfil #2\parfillskip=0pt\finalhyphendemerits=0\par}}
Invoke the macro with this:
\rtuck{[2 marks]}
In a given instance, you can adjust the bit of leading space by
including an optional argument:
\rtuck[0.5em]{[2 marks]}
all the best,
mtw
More information about the texhax
mailing list