[texhax] On \qed macros

Steve Schwartz s.schwartz at imperial.ac.uk
Mon Dec 31 23:47:04 CET 2007

Firstly, my thanks to those who have provided input to this question,
and my apologies for those of you who have been distracted by it.

To date, there have been 3 generic solutions to this:

1 provided by Lars Madsen:

\leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill

that works as advertised, but if the box is forced onto the next line,
the previous line is ALWAYS stretched to be right justified. This is
either a good thing or a bad thing depending on the situation and your
sense of aesthetics.

2 provided by several of you, based on stuff in the TeX book (my slight
apologies for not reading it) best represented by Michael's previous
commented version of \pushright, or Michael Westcoat's \rtuck, or ...,
from his journal's style file, that doesn't stretch a line that is too
long to also have the box. This seems to be quite robust

3 Michael's suggestion below which works most but not all of the time,
especially if the box is replaced by some longer text, like the
[nn~marks] I originally sought. If you wish to experiment, cut/paste any
of these into the sample I supplied and \renewcommand\qmarks[1] to use
them instead of my original. You'll then see that some of the [nn marks]
end up at the beginning of the next line. Read on...

On Mon, 2007-12-31 at 15:37 -0500, Michael Barr wrote:
> After the discussion involving \pushright and so on, I got to wonder if 
> there wasn't a simpler solution.  Perhaps there is a problem with the 
> following, but it seemed to work:
> \documentclass{article}
> \newbox\endproofbox
> \setbox\endproofbox\hbox{\vrule width5pt height 5pt depth 0pt}
> \def\eop{\hbox to .3em {\hss}\hfill\copy\endproofbox \par\kern5pt}
> \begin{document}
> Now is the time for all good men to come to the aid of the party.\eop
> Now is the time for all good men to come to the aid of the party.
> Now is~the \eop
> \end{document}
> The reason for the ~ in the last line was to inhibit tex from putting 
> "the" on the next line.

Indeed, that should be a good indicator that this approach is less than
foolproof, though I have a lot of sympathy with the notion that the
original problem seems sufficiently simple that it ought to have a
simple two-line solution.

Anyway, for those who are better at this than I, and who want to waste
some more time, here's another variant I thought would be easy but
isn't. Often, a question asks to show that \[ display equation \], and
that's the end of the question. None of the examples I've been given
work, I think, within a displayed math environment, so the marks end up
below that, which takes up more vertical space on the page and is less
than ugly. After some trials, I realised I was trying to re-invent the
wheel as TeX's equation numbering knew how to do this. Following some
digging, I tried:

\newcommand\qmarks[1]{\ifmmode \eqno \hbox{[#1~marks]}%
 \else \pushright{\hbox{[#1~marks]}}\fi}

but this gives an error about a bad math delimeter. It's obviously a
problem with the \eqno, as omitting it compiles (but doesn't do what I
want), though the construction looks to be the way equation numbers are
done in latex. \eqno is a TeX primitive. I've also tried hacking the
construction in leqno.clo which generates an hbox and stuffs the
equation number in the left, but I don't know how to do this. I'm away
that \eqno will only work in displaymath, whereas \ifmmode would also
apply to $...$ maths, but it is easy for the user to fix in that case by
putting the \qmarks command outside the inline maths.

I won't specify what behaviour I would want/expect if the displaymath
were in an equation environment that got equation numbers, but my
inclincation in this case would be to force the user to use leqno.

I'm off to join my neighbours in bringing in the New Year.


> +-------------------------------------------------------------------+
> 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
> +-------------------------------------------------------------------+

More information about the texhax mailing list