2

Apologize if this is a duplicate.

\documentclass[12pt]{extbook}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{etoolbox}
\theoremstyle{definition}
\newtheorem{example}{Example}[section]
\AtEndEnvironment{example}{\qed}%
%example
\begin{document}
\begin{example}
For example, if $E$ is the set of even numbers,
\begin{equation*}
\{x \in E: x = 2\}
\end{equation*}
is the set of all even numbers $x$ such that $x = 2$. Of course, there is only one even number equal to $2$, so 
\begin{equation*}
\{x \in E: x = 2\} = \{2\}\text{.}
\end{equation*}
\end{example}
\end{document}

enter image description here

Can I somehow move \qed up one line, to the right of the equation environment by changing the example environment definition?

2
  • 1
    Why no use \qedhere inside equation. (\{x \in E: x = 2\} = \{2\}\text{.}\qedhere)?
    – skpblack
    Nov 10, 2014 at 1:43
  • @skpblack: that doesn’t work in this situation. It works inside a proof environment, but not inside a theorem-style environment: a \qedhere on its own produces nothing, and a \qed inside the equation comes out immediately following the equation text, not right-aligned as one wants. Feb 26, 2016 at 13:39

2 Answers 2

2

With the ntheorem package, you have an automatic placement of \qedsymbol, and it's easy to have several types of \qedsymbols if you use the thmmarks option. The amsthm option provides a partial compatibility with the layouts defined in amsthm, but the syntax to define new theorem-like environments is more intuitive. Finally, the thref option provides extended refencing possibilities (compatible with cleveref).

\documentclass[12pt]{extbook}
\usepackage{amsmath, amssymb}
\usepackage[thmmarks, amsmath, thref]{ntheorem}
\theoremstyle{definition}
\theorembodyfont{\normalfont}
\theoremsymbol{\ensuremath{\square}}
\newtheorem{example}{Example}[section]

\begin{document}

\begin{example}
For example, if $E$ is the set of even numbers,
\begin{equation*}
\{x ∈ E: x = 2\}
\end{equation*}
is the set of all even numbers $x$ such that $x = 2$. Of course, there is only one even number equal to $2$, so
\begin{equation*}
\{x ∈ E: x = 2\} = \{2\}\text{.}
\end{equation*}
\end{example}

\end{document} 

enter image description here

1

It is rather bad style to end an example with a displayed material. If you cannot reformulate it, there is an exemplary solution. If you want the square to be moved to the right, you can replace \qed by \tag*{\qed}, but certainly only for unnumbered equations.

\documentclass[12pt]{extbook}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{etoolbox}
\theoremstyle{definition}
\newtheorem{example}{Example}[section]
\AtEndEnvironment{example}{\qed}%
\newtheorem{exampleqed}[example]{Example}
\AtEndEnvironment{exampleqed}{}%
%example
\begin{document}

\begin{example}
For example, if $E$ is the set of even numbers,
\begin{equation*}
\{x \in E: x = 2\}
\end{equation*}
is the set of all even numbers $x$ such that $x = 2$. Of course, there is only one even number equal to $2$, so 
\begin{equation*}
\{x \in E: x = 2\} = \{2\}\text{.}
\end{equation*}
\end{example}

\begin{exampleqed}
For example, if $E$ is the set of even numbers,
\begin{equation*}
\{x \in E: x = 2\}
\end{equation*}
is the set of all even numbers $x$ such that $x = 2$. Of course, there is only one even number equal to $2$, so 
\begin{equation*}
\{x \in E: x = 2\} = \{2\}\text{.}
\qed
\end{equation*}
\end{exampleqed}
\end{document}
1
  • This certainly works for my needs. Just simple and quick. If worked just fine for an equation at the end of a section in which I prove a theorem using the IEEEtran template. Thanks!
    – kentropy
    Feb 12, 2020 at 21:24

You must log in to answer this question.

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