# Change only the colour of the (bracketed part) of the title of a theorem

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)
{}% (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.

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)
{\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}