0

I am using a thmtools to color my theorems. However, I want the name of this theorems to be uncolored. Now I have :

enter image description here

but I want the "test" in black.

The code I use for these theorems is :

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{color}


\definecolor{thmtitre}{RGB}{218,4,4}

\declaretheoremstyle[
    headfont=\color{thmtitre}\normalfont\bfseries,
    bodyfont=\normalfont\itshape,
    spaceabove = 6pt,
    spacebelow = 6pt,
    ]{thmstyle}

\theoremstyle{thmstyle}
\newtheorem{thm}{Theorem}

\begin{document}
\begin{thm}[test]
hey
\end{thm}
\end{document}

and I did not find an option in thmtools to solve my problem

Thank you by advance !

4
  • What precisely do you want to be colored?
    – egreg
    Aug 19 at 17:22
  • If want that "Theorem 1" stills colored, but the rest in black
    – simonm12
    Aug 19 at 17:26
  • 1
    Please: 1) Envelop your code wihtin {} ... it's not a comment. 2) Complete the code. At least we need the preamble AND the call which shows your "hey"-print. Thanks
    – MS-SPO
    Aug 19 at 17:41
  • Yes sorry, I did not found the right way to write code. I have edited my question
    – simonm12
    Aug 19 at 18:01
3

Here it is, with the headformat key.

Incidentally, needless to load inputenc with option [utf8]: it is what LaTeX expects by default. You don't have to load amsfonts either, since amssymb does it for you.

\documentclass[10pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{xcolor}

\definecolor{thmtitre}{RGB}{218,4,4}

\declaretheoremstyle[
    headformat=\normalfont\textcolor{thmtitre}{\bfseries\NAME\,\NUMBER}\NOTE,%
    bodyfont=\normalfont\itshape,
    spaceabove = 6pt,
    spacebelow = 6pt,
    ]{thmstyle}

\theoremstyle{thmstyle}
\newtheorem{thm}{Theorem}

\begin{document}

\begin{thm}[test]
Successful test?
\end{thm}

\end{document} 

enter image description here

5
  • It works perfectly, thanks a lot !
    – simonm12
    Aug 19 at 19:24
  • headformat=\normalfont\textcolor{thmtitre}{\bfseries\NAME\ \NUMBER}\NOTE (not \,)
    – egreg
    Aug 20 at 8:05
  • @egreg: I tested first with ~ (which is approximately the same as \ , except it's unbreakable, if I'm not mistaken) and found it too large, that's why I used a thin space. Of course, it's a matter of personal taste.
    – Bernard
    Aug 20 at 8:17
  • @Bernard The space produced by ~ can be different from \ when following punctuation, otherwise they're the same; and they produce the standard spacing used everywhere. Anyway, \normalfont should be outside the scope of \color (and \textcolor is better).
    – egreg
    Aug 20 at 8:31
  • @egreg: I've fixed the code – except the spacing: having tested, I really prefer a thin space (somewhat like the spacing between a number and the unit).
    – Bernard
    Aug 20 at 8:52

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.