# New environment with a glyph before its head

I want to create the following exercise environment, for exercises:

That is, insert a black triangle right symbol, ▸, before the header of the exercise.

To accomplish this, I would prefer to use the two packages amsthm together with thmtools and its declaretheoremstyle command.

In the thmtools manual, subsection 1.3.1, they say that

There is one important thing you cannot see in this example: there are more keys you can pass to \declaretheoremstyle[.]

(other than

• spaceabove, spacebelow
• notefont, notebraces
• bodyfont
• qed )

So, is there such a key that prepends a glyph to the header?

I am not familiar with plain TeX, and therefore can't answer my own question just by looking at the dtx and sty files of the package repository.

So that a MWE would be

\documentclass{book}
\usepackage{fontspec}

\usepackage{amsthm,amssymb,thmtools}
\declaretheoremstyle[
⟨insert glyph before head key = value is ▸⟩
]{mystyle}
\declaretheorem[style=mystyle]{exercise}

\begin{document}

\chapter{Prime numbers}
Lorem ipsum
\section{Dolor sit amet}

\begin{exercise}[Euclid]
Prove that for every prime $p$, there is a prime $p^\prime > p$. In particular, the list of primes, $2, 3, 5, 7, \ldots$ , is infinite.
\end{exercise}

\end{document}


You can use headformat:

\documentclass{book}
\usepackage{fontspec}
\usepackage{amsmath,amsthm,amssymb,thmtools}

\newfontfamily{\miscsymbols}{Symbola}[
UprightFont=*,
BoldFont=*,
]

\declaretheoremstyle[
]{mystyle}

\declaretheorem[
style=mystyle,
]{exercise}

\begin{document}

\chapter{Prime numbers}
Lorem ipsum
\section{Dolor sit amet}

\begin{exercise}[Euclid]\label{euclid}
Prove that for every prime $p$, there is a prime $p' > p$.
In particular, the list of primes, $2, 3, 5, 7, \dotsc$ is infinite.
\end{exercise}

\end{document}


I defined a special font because Latin Modern hasn't that particular glyph. Of course you can also use $\blacktriangleright$ instead of a glyph from another text font.

\NOTE is smart and will print nothing if the optional argument is missing in a statement.

Unrelated, but typing p' is easier than p^{\prime} and yields the same result. Use \dotsc from amsmath instead of \ldots in that context.

• The dot after \NOTE is bold. Is it OK? Is it not better to put also \NOTE in bold? Nov 28, 2021 at 16:19
• @CarLaTeX That's standard amsthm Nov 28, 2021 at 16:22
• OK, if it is the standard I don't say nothing :D Nov 28, 2021 at 16:28

This is possible directly with amsthm:

\documentclass{book}
\usepackage{amssymb}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{exer}{$\blacktriangleright$ Exercise}

\begin{document}

\section{A section}
Some text
\begin{exer}
Content of exercise.
\end{exer}

\end{document}


• Silly me. Certainly a way to do that.
– tush
Nov 28, 2021 at 18:05