3

I want that theorems, lemmas, examples... are ended with a diamond. Like this:enter image description here

I found out that I can use \hfill\mbox{$\diamond$}. But I already wrote my document with 100s of examples, lemmas... I don't want to set it manually. So I thought I could set it up in \theoremstyle. Where do I have to set this? Here's my MWE:

\documentclass[ngerman, fontsize=11pt, DIV=15, BCOR = 10mm,parskip=half-, twoside]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}

\newtheoremstyle{definition}{}{}{}{}{\bfseries}{:}{5 pt}{}

\theoremstyle{definition}
\newtheorem{defi}[]{Definition}

\begin{document}
      Here's the example.

\begin{defi}
       Does the diamond appear?
\end{defi}
\end{document}
8
  • 1
    Welcome to TeX.SE. which document class are you using, your code doesn't compile as it is missing that
    – JamesT
    Mar 6 at 9:43
  • 1
    @JamestT I use scrartcl. Sorry, I added it. Mar 6 at 9:46
  • If you use ntheorem instead og amsthm then this is a feature of this package. Note that the method for styling in ntheorem is different.
    – daleif
    Mar 6 at 9:51
  • @daleif I had to redefine all my environments then. Hm, if there is no other possibility, I think I have to do it Mar 6 at 9:55
  • 1
    All packages has manuals... And the proof env is just an theorem with no number, and there is a style for that.
    – daleif
    Mar 6 at 10:47

4 Answers 4

2

You could use \AtEndEnvironment to automatically add your code (or my slightly adapted version) every time your defi environment ends.

As I use not only \diamonds at the end of some environments but also \triangle, I personally want them to have (approximately) the same size, so I added an environment defiBig which adds a rescaled \diamond. This resizing involves the scalerel package. Result

\documentclass[ngerman, fontsize=11pt, DIV=15, BCOR = 10mm,parskip=half-, twoside]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{scalerel} % only necessary for the version with big \diamond

\newtheoremstyle{definition}{}{}{}{}{\bfseries}{:}{5 pt}{}

\theoremstyle{definition}
\newtheorem{defi}[]{Definition}
\AtEndEnvironment{defi}{\null\hfill\ensuremath{\diamond}}
% For a bigger \diamond you can use the following:
\newtheorem{defiBig}[defi]{DefinitionBig}
\newlength\myheight  \settoheight\myheight{$\triangle$}
\AtEndEnvironment{defiBig}{\null\hfill\ensuremath{\scaleto{\diamond}{\myheight}}}

\begin{document}
      Here's the example.
      \begin{defi}
             Does the diamond appear?
      \end{defi}
      \begin{defiBig}
             Does the big diamond appear?
      \end{defiBig}
\end{document}
12
  • @mathquester exactly which LaTeX installation are you using? Seems very old
    – daleif
    Mar 6 at 11:10
  • Note that this construction is fragile. One may end up in a situation where the diamond is on a line of its own at the top of the next page.
    – daleif
    Mar 6 at 11:11
  • As Celdor and daleif said, you seem to have not updated your stuff for a while. For me it works in Overleaf, probably you need to add \usepackage{etoolbox} to your preamble. Mar 6 at 11:12
  • 1
    @Οὖτις ntheorem can add the marker into some math constructions....
    – daleif
    Mar 6 at 11:20
  • 1
    Note that several packages offer \mdlgwhtdiamond , \mdlgwhtlozenge , and \diamondsuit as alternatives for the larger diamond symbol.
    – Davislor
    Mar 6 at 22:48
5

Just to be consistent, here is a solution using ntheorem. It has not changed in like 10 years should should not have issues with a 2017 installation. Just remember it takes several compilations for the markers to settle.

Caveat: The ntheorem envs with markers does not like blank lines before the \end{env} part.

Code example including how to define proof:

\documentclass[ngerman, fontsize=11pt, DIV=15, BCOR = 10mm,parskip=half-, twoside]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
%\usepackage{amsthm}
\usepackage{amssymb}
\usepackage[amsmath,thmmarks]{ntheorem}

\theorembodyfont{\normalfont}
\theoremseparator{.}
\theoremsymbol{\enskip\ensuremath{\diamond}}
\newtheorem{defi}{Definition}

% body font is shared from above
\theoremstyle{nonumberplain}
\theoremheaderfont{\itshape}
\theoremsymbol{\enskip\ensuremath{\Box}}
\newtheorem{proof}{Proof}


\begin{document}
Here's the example.

\begin{defi}
  Does the diamond appear?
\end{defi}

\begin{proof}
  Test
\end{proof}
     
\end{document}
4

A more elegant way is as follows. By the way, it's better to select the ending symbol as the same as the qed symbol. Just as what I said about theorem formats in my book, the qed symbol indicates "the ending of a proof". So we can generally use the symbol to indicate “the transitory ending of some texts" and extend its use rang to all kinds of propositions, definitions, remarks and so on without proofs.

\documentclass{article}

\usepackage{amsthm}
\usepackage{latexsym}%for \Diamond
\renewcommand{\qedsymbol}{$\Diamond$}

\theoremstyle{theorem}
\newtheorem{theorem}{Theorem}
\newenvironment{thm}{\pushQED{\qed}\theorem}{\popQED\endtheorem}

\theoremstyle{definition}
\newtheorem{definition}{Definition}
\newenvironment{defi}{\pushQED{\qed}\definition}{\popQED\enddefinition}

\begin{document}

Here are the examples.

\begin{theorem}
Does the diamond appear? No!
\end{theorem}

\begin{thm}
Does the diamond appear? Yes!
\end{thm}

\begin{definition}
Does the diamond appear? No!
\end{definition}

\begin{defi}
Does the diamond appear? Yes!
\end{defi}

\end{document}

enter image description here

The following image shows how I use the qed symbol personally.

enter image description here

7
  • And now you just gave proofs a diamond marker.
    – daleif
    Mar 6 at 13:11
  • @daleif In fact, I usually use the square at the end of propositions without proofs. Since both the symbols at the end of propositions without proofs and the end of proofs means "the ending", so it's better to set them to be the same.
    – M. Logic
    Mar 6 at 15:01
  • I have several lecturers who would disagree and feel it very confusing to the reader.
    – daleif
    Mar 6 at 15:34
  • @daleif So it may be necessary to say it clearly at the first time just like when to use it at the end of proofs at the first time.
    – M. Logic
    Mar 7 at 5:47
  • If you will put the \renewcommand{\qedsymbol}{$\Diamond$} at the begin definition of the defi environment the change won't be applied to proofs, but only to definitions
    – Udi Fogiel
    Mar 7 at 6:22
3

You could create a wrapper environment which would add a diamond at the end of the environment defined by amsthm. Something around these lines:

\documentclass[ngerman, fontsize=11pt, DIV=15, BCOR = 10mm,parskip=half-, twoside]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}

\newtheoremstyle{definition}{}{}{}{}{\bfseries}{:}{5 pt}{}
\theoremstyle{definition}
\newtheorem{ddefi}[]{Definition}
\NewDocumentEnvironment{defi}{s +b}{%
  \begin{ddefi}
    #2\nolinebreak\IfBooleanT{#1}{\hfill}\enspace$\diamond$
  \end{ddefi}}{}


\begin{document}
Here's the example.
\begin{defi}
  Does the diamond appear
\end{defi}

\begin{defi}*
  Does the diamond appear
\end{defi}
\end{document}

enter image description here


EDIT. The code based on standard \newenvironment:

\documentclass[ngerman, fontsize=11pt, DIV=15, BCOR = 10mm,parskip=half-, twoside]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}

\newtheoremstyle{definition}{}{}{}{}{\bfseries}{:}{5 pt}{}
\theoremstyle{definition}
\newtheorem{ddefi}[]{Definition}
\newenvironment{defi}{\begin{ddefi}}{\nolinebreak\hfill\enspace$\diamond$\end{ddefi}}


\begin{document}
Here's the example.
\begin{defi}
  Does the diamond appear
\end{defi}
\end{document}
5
  • I get Undefined control sequence. \NewDocumentEnvironment Mar 6 at 10:25
  • 1
    \NewDocumentEnvironment is defined in xparse but since the October 2020 (I think) it is a part of the kernel. I guess you run an old LaTeX distribution, which you really should update. For the time being, add \usepackage{xparse}.
    – Celdor
    Mar 6 at 10:32
  • Now I get LaTeX error: "xparse/unknown-argument-type" Unknown argument type 'b' for the command '\environment defi'. For immediate help type H <return>. Mar 6 at 11:01
  • 1
    @mathquester please update your question with information about your LaTeX installation. The version numbers is listed at the top of the log file.
    – daleif
    Mar 6 at 11:12
  • @mathquester see my update and try to compile the new code. I checked it runs on TeXLive 2014.
    – Celdor
    Mar 6 at 11:12

You must log in to answer this question.

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