3

I am writing a macro to typeset proofs of theorems. By getting rid of irrelevant (for this question) things, it simplifies to

\def\demo#1\enddemo{\noindent{\it Proof.\quad}#1\quad\copy\cvdbox\medskip}

where cvdbox is a box which contains an end-of-proof symbol. For example, let it be:

\newbox\cvdbox
\setbox\cvdbox=\hbox{\bf CVD}

The macro does it's job as expected, except when the proofs ends with a displayed equation, that is something in between double dollar signs. In fact, the \cvdbox is placed on a new line by itself, instead of being placed on the right of the last line. I would like that, when the proof ends with a displayed formula, the \cvdbox is set at the end of the display, just before the closing double dollar signs. For example, I would like that

\demo
 ...
$$\int_a^bf.$$
\enddemo

gets transformed into

\noindent{\it Proof.\quad}... $$\int_a^bf.\quad\copy\cvdbox$$\medskip}

instead of

\noindent{\it Proof.\quad}... $$\int_a^bf.$$\quad\copy\cvdbox\medskip}

How can I do?

1
  • it looks like you're using the ams-tex syntax. putting the end-of-proof marker into the right place automatically is a hard problem, which is why, in joy of tex it's recommended to insert \qed manually. if you really are using ams-tex, you could do worse than copying the definition of \qed and substituting your "cvd" content. Commented Nov 9, 2015 at 22:47

2 Answers 2

6

If you needn't to put the QED mark immediately after the formula in display line but aligned right in this line, then you can use this:

\input plipsum

\def\demo{\par\noindent{\it Proof.\quad}}
\def\enddemo{\ifdim\lastskip=0pt % after display
      \par \dimen0=\lastskip \removelastskip 
      \advance\dimen0 by\prevdepth \kern-\prevdepth
      \nointerlineskip \vbox to0pt{\vss\line{\hss\bf QED}}
      \vskip\dimen0
   \else \unskip \quad\hbox{\bf QED}\fi
   \medskip
}

\demo
\lipsum{1}
$$
\int_a^bf.
$$
\enddemo

\demo
\nopar\lipsum{1}
\enddemo

\end
0
4

In my opinion you want to define a \qedhere macro to be used like

\input plipsum

\long\def\demo#1\enddemo{%
  \global\qedtrue
  \noindent{\it Proof.\quad}%
  #1%
  \ifqed\quad\copy\cvdbox\fi
  \medskip
}
\newif\ifqed
\def\qedhere{\global\qedfalse\rlap{\quad\copy\cvdbox}}

\newbox\cvdbox
\setbox\cvdbox=\hbox{\bf CVD}

\demo
\lipsum{1}
$$
\int_a^bf.\qedhere
$$
\enddemo

\demo
\nopar\lipsum{1}
\enddemo

\bye

enter image description here

3
  • that's really all that \qed does in ams-tex. there's an \if@qedhere defined there, but if's never used in any useful way. maybe something happened in lamstex, but i haven't got a copy here to check. Commented Nov 9, 2015 at 22:50
  • @egreg Good suggestion!
    – User
    Commented Nov 11, 2015 at 14:17
  • @barbarabeeton Looking at lamstex I see nothing anymore about 'qed'.
    – User
    Commented Nov 11, 2015 at 14:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .