1

How may I change only the colour of the title of a theorem, i.e. the part that appears in brackets after say, "Theorem", "Definition" etc. when using the amsthm package?

I have tried passing \color{red} to the Theorem Head Font (see below) but this also changes the first part, that is not in brackets.

\newtheoremstyle{note}% (name)
    {}% (space above)
    {}% (space below)
    {}% (body font)
    {}% (indent amount)
    {\bfseries\color{red}}% (Theorem head font)
    {:}% (Punctuation after theorem head)
    {.5em}% (Space after theorem head)
    {}% (Theorem head spec (can be left empty, meaning ‘normal’))

To clarify, when saying

\begin{definition}[foo] an explanation \end{definition}

I would like only "foo" to be red but definition to remain as i had defined it in the theorem head font.

3

You could use the last argument of \newtheoremstyle for this. The arguments of \thmname, \thmnumber and \thmnote are only printed if the relevant field is present.

\documentclass{article}

\usepackage{amsthm}
\usepackage{xcolor}

\newtheoremstyle{note}% (name)
    {}% (space above)
    {}% (space below)
    {}% (body font)
    {}% (indent amount)
    {\bfseries}% (Theorem head font)
    {:}% (Punctuation after theorem head)
    {.5em}% (Space after theorem head)
    {\thmname{#1}\thmnumber{ #2}\thmnote{ (\textcolor{red}{#3})}}
    % ^^(Theorem head spec (can be left empty, meaning ‘normal’))

\theoremstyle{note}
\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}[Named theorem]
    This theorem has a name.
\end{theorem}

\begin{theorem}
    This theorem does not.
\end{theorem}

\end{document}

output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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