0

I would like to change the theorem environment so that the title and name are coloured. What can I do? Have checked ways to do this (e.g. with \newtheoremstyle) but have not worked well yet. I do not want to use theorom packages such as amsthm, but stick with basic built-in theorem structure.

\documentclass[12pt]{article}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\usepackage{xcolor}

\begin{document}

\begin{theorem}[Continuous Function] Let (f) be a function whose derivative exists in every point, then (f) is a continuous function. \end{theorem}

\end{document}

I would have other environments using \newtheorem that I would want the same colouring scheme as would happen with \begin{theorem} ... \end{theorem}.

Veak
  • 1
  • 1
    Can you add a minimal working example so we can see which of the theorem packages you are using? – samcarter_is_at_topanswers.xyz Sep 07 '22 at 10:48
  • 3
  • I could not get that one to work for me. – Veak Sep 07 '22 at 11:21
  • That example does not even compile. You still need to define theorem. This should be diable using thmtools (haven't tested it) or directly via amsthm and defining custom theorem styles. – daleif Sep 07 '22 at 11:49
  • I want to use the built-in latex functionality to do it without amsthm. Doable but how? – Veak Sep 07 '22 at 13:07
  • If you ask someone a direct question please use @name to notify. thmtools works with regular \newtheorem. What is wrong with using amsthm? You're already using xcolor so what is the point is requiring build-in latex functionality? – daleif Sep 07 '22 at 13:26
  • 1
    I'm voting to leave open because the OP asks for a solution without amsthm, which makes it a different question. – Marijn Sep 07 '22 at 13:27
  • @konmi -- If you don't want to use amsthm or other particular packages, please add that to your question. – barbara beeton Sep 07 '22 at 15:42
  • There isn't any such thing as "basic builtin theorem structure" as far as I know. Your current code does not compile because no theorem environment is defined. Why don't you want to use amsthm? How are you defining theorem environments now? – frabjous Sep 07 '22 at 16:59
  • @frabjous do remember that \newtheorem is in the core. The op does not need amsthm, it is just a strange requirement to not use packages – daleif Sep 07 '22 at 18:20
  • Here is where we disagree. I only want to change colour for something that is in core without relying on theorem packages. – Veak Sep 07 '22 at 19:03

2 Answers2

1

In https://tex.stackexchange.com/a/17555/4427 you find the default values for theorem styles. You just need to tailor the last argument to your needs.

\documentclass{article}
\usepackage{amsthm}
\usepackage{xcolor}

\newtheoremstyle{colorplain} {\topsep} % ABOVESPACE {\topsep} % BELOWSPACE {\itshape} % BODYFONT {0pt} % INDENT (empty value is the same as 0pt) {\bfseries} % HEADFONT {.} % HEADPUNCT {5pt plus 1pt minus 1pt} % HEADSPACE {% \thmnumber{\textcolor{red!75}{#1}}% \ % space \thmname{\textcolor{green!60!red}{#2}}% \thmnote{ \textcolor{blue!80!green}{#3}}% }

\theoremstyle{colorplain} \newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem} This has no theorem note. \end{theorem}

\begin{theorem}[Note] This has a theorem note. \end{theorem}

\end{document}

enter image description here

But this is definitely ugly. I believe you just want one color for the whole heading.

\documentclass{article}
\usepackage{amsthm}
\usepackage{xcolor}

\newtheoremstyle{colorplain} {\topsep} % ABOVESPACE {\topsep} % BELOWSPACE {\itshape} % BODYFONT {0pt} % INDENT (empty value is the same as 0pt) {\color{blue!80!green}\bfseries} % HEADFONT {.} % HEADPUNCT {5pt plus 1pt minus 1pt} % HEADSPACE {}

\theoremstyle{colorplain} \newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem} This has no theorem note. \end{theorem}

\begin{theorem}[Note] This has a theorem note. \end{theorem}

\end{document}

enter image description here

egreg
  • 1,121,712
0

Albeit using both the amsthm and thmtools environments, something like this?

(I also corrected the run-on sentence and corrected the preposition "in" to be "at.")

\documentclass[12pt]{article}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\usepackage{xcolor}  
\usepackage{amsmath,amsthm}
\usepackage{thmtools}

\declaretheoremstyle[ headfont={\color{red}\bfseries}, notefont={\color{blue}}, ]{thmstyle} % \declaretheorem[name=Theorem, style=thmstyle]{theorem}

\begin{document}

\begin{theorem}[Continuous Function] If (f) is a function whose derivative exists at every point, then (f) is a continuous function. \end{theorem}

\end{document}

Color theorem head and note

murray
  • 7,944