Math & ScienceSymbol at the end of a displayed equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
dnemoc
Posts: 19
Joined: Mon May 11, 2009 2:29 pm

Symbol at the end of a displayed equation

Post by dnemoc »

Hi!

I checked the earlier posts for the solution to my question, but it doesn't seem to be there; so here it is:

Suppose I have an equation

Code: Select all

\[
    E = m c^2
\]
and I want a $\Diamond$ (or any other for that matter,) symbol at the end of the displayed equation flushed right. My numbering scheme has equation numbers at the left, so the standard trick of using \tag*{$\Diamond$} at the end of the equation does not work. There must be a way to do this, but it's just not working with \hfill, etc. Fine-tuning with \vspace both to the left and right of the displayed equation is also not a good way to go.

Could anyone please help?

Best regards,
- D.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Symbol at the end of a displayed equation

Post by gmedina »

Hi,

in the following example I defined two new environments qedequation and its *-ed version qedequation* which behave like equation and equation* but also produce the QED symbol, as defined in amsthm, flushed right. Of course, the use of the numbered version only makes sense if the leqno package option for amsmath is active.

Code: Select all

\documentclass{article}
\usepackage[leqno]{amsmath}
\usepackage{amsthm}

\makeatletter
% queequation only makes sense with the leqno option for amsmath
\newenvironment{qedequation}{%
  \pushQED{\qed}%
  \incr@eqnum
  \mathdisplay@push
  \st@rredfalse \global\@eqnswtrue
  \mathdisplay{equation}%
}{%
  \endmathdisplay{equation}%
  \mathdisplay@pop
  \ignorespacesafterend
  \popQED\@endpefalse
}

\newenvironment{qedequation*}{%
  \pushQED{\qed}%
  \mathdisplay@push
  \st@rredtrue \global\@eqnswfalse
  \mathdisplay{equation*}%
}{%
  \endmathdisplay{equation*}%
  \mathdisplay@pop
  \ignorespacesafterend
  \popQED\@endpefalse
}
\makeatother

\begin{document}

\begin{qedequation}
  E = m c^2\qedhere
\end{qedequation}

\begin{qedequation*}
  E = m c^2\qedhere
\end{qedequation*}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
dnemoc
Posts: 19
Joined: Mon May 11, 2009 2:29 pm

Re: Symbol at the end of a displayed equation

Post by dnemoc »

Thank you, thank you, thank you! This is it!
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

Symbol at the end of a displayed equation

Post by CrazyHorse »

dnemoc wrote: Suppose I have an equation

Code: Select all

\[
    E = m c^2
\]
and I want a $\Diamond$ (or any other for that matter,) symbol at the end of the displayed equation flushed right. My numbering scheme has equation numbers at the left, so the standard trick of using \tag*{$\Diamond$} at the end of the equation does not work. There must be a way to do this, but it's just not working with \hfill, etc. Fine-tuning with \vspace both to the left and right of the displayed equation is also not a good way to go.

Code: Select all

\documentclass{article}
\usepackage[leqno]{amsmath}
\usepackage{amsthm}
\begin{document}

\noindent\rule{\linewidth}{1pt}
\begin{flalign}
  && E = m c^2  &&\qed
\end{flalign}

\begin{flalign*}
  && E = m c^2  &&\qed
\end{flalign*}

\end{document}
Herbert
dnemoc
Posts: 19
Joined: Mon May 11, 2009 2:29 pm

Re: Symbol at the end of a displayed equation

Post by dnemoc »

Thank you too Herbert!

Best regards to you both!

- D.
Post Reply