TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use this code to define a symbol that I put at end of (maths) examples in my file.

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

And I use it like follows:

\begin{defn}The spectrum is:
\sigma(T) = \{ \lambda : (T-\lambda I)^{-1} \text{ does not exist} \}.

Which looks like this:

I want the circle symbol on the same line as the equation. How do I do that? If I put the \demo on the line before the \end{equation*}, it looks even worse; it's pretty much only two spaces to the right of the equation.

share|improve this question
up vote 6 down vote accepted

Look at packages amsthm and ntheorem that provide answers for this. For example the former package defines a proof environment and the \qedhere command just suitable for your needs.

With these packages the procedure for defining theorems uses also the concept of "theorem style":

% default style
\newtheorem{thm}{Theorem} % defines a "thm" counter; 
\newtheorem{cor}[thm]{Corollary} % numbering in common with thm
share|improve this answer
Thanks. With ntheorem, how do I make it so the theorems, defns, lemmas, etc. number successively? Eg, I want: 1.1.1 Theorem, then 1.1.2 Defn, not 1.1.1 Theorem, then 1.1.1 Defn. – P.A May 11 '11 at 19:45
@P.A.: I'll add it in the answer. – egreg May 11 '11 at 20:12
I already have that, but that produces: 1 Thm, 2 Eg, 3 Thm, 4 Defn etc. I want the section numbers: 1.1.1 Thm, 1.1.2 Eg, 1.1.3 Thm, 1.2.1 Defn for example. Adding \numberwithin{equation}{section} doesn't seem to change it. I appreciate your help. – P.A May 11 '11 at 20:18
@P.A. This is basic LaTeX: define the first environment by \newtheorem{thm}{Theorem}[section] – egreg May 11 '11 at 20:27
THANK YOU! You're a lifesaver. – P.A May 11 '11 at 20:33

I made two defs:



and I use the first one at hte text-end-of-proof and the second at the formula-end-of-proof.

It works much better, but is not perfect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.