# How to control the word 'Theorem' itself in mdframed

In an mdframed theorem environment you get the word 'Theorem' appearing at the top of the frame. How can one control the colour and/or font of the word 'Theorem' in mdframed? Say, I want it to be red and in \ttfamily style?

• Could you provides us with your current \newmdtheoremenv definition? – Werner Oct 11 '16 at 6:51

So I am using the very first example from the manual:

\newmdtheoremenv%
[
outerlinewidth = 0.1,%
roundcorner = 10pt, %
leftmargin= 40, %
rightmargin=40,%
backgroundcolor= yellow!20,%
innertopmargin=0.5ex,%
splittopskip= \topskip,%
ntheorem = true,%
frametitlefont = {\twriter\color{red}},%has no effect
subtitlefont ={\twriter} % has no effect
]
{dvthm}{Theorem}[equation]


The last two entries for frametitlefont and subtitlefont I include just to demonstrate my attempt at doing something to control the title. But nothing happens. Moreover, as far as I understood it these option will only control the so called optional title you can specify. The actual 'Theorem' word - I see no attribute that controls it.

The only option I see is that in the last part

\newmdtheoremenv[...]{dvthm}{Theorem}[equation]


At the very end of the environment one can replace the word 'Theorem' there with the style one likes. But surely this is too crude and not systematic.

• and if you do as I suggest then you can control the word 'Theorem' but not the number of the environment which will remain with the original settings. – Paul Oct 11 '16 at 7:42
• Don't add edits as answer, edit your question. Also put code in the code environment by selecting them and then click on the {}. And I would use tcolorbox instead of mdframed. – Ulrike Fischer Oct 11 '16 at 8:16
• @UlrikeFischer I think those are not the same Pauls (the OP and the answer guy)... I was pretty confused as well but at least the profiles are different ones. – Guilherme Zanotelli Oct 11 '16 at 8:24
• @ALL: sorry guys it is the same Paul. Simply when I tried to comment before I got denied saying I have to have reputation 50 to make a comment. When I tried to edit my question it said something similar. So I had to use the answer. Now for some reason I can write a comment. – Paul Oct 11 '16 at 8:39
• @Paul: You seem to have two profiles, flag a moderator so that they sort this out. – Ulrike Fischer Oct 11 '16 at 9:10

In case you decide to change to tcolorbox you could try following code. It tries to mimic first example from mdframed documentation.

For tcolorbox, the title is formatted by Theorem~number where Theorem is the third parameter in \newtcbtheorem command. Font and color are fixed with options coltitle and fonttitle. The theorem name color and font are fixed with description color and description font options.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}

\tcbset{
mystyle/.style={theorem style=plain,
enhanced,
colback=yellow!20,
colframe=blue!70!black,
fonttitle=\ttfamily\upshape,
fontupper=\itshape,
coltitle=green!70!black,
description color=red,
description font=\sffamily\bfseries
},
}

\newtcbtheorem[number within=section]{myTheorem}{Theorem}{mystyle}{theo}

\begin{document}

\section{Theorems}

\begin{myTheorem}{Pythagorean theorem}{Pythagoras}
In any right triangle, the area
of the square whose side is the hypotenuse is equal to the sum of the areas
of the squares whose sides are the two legs.
$a^2 + b^2 = c^2$
\end{myTheorem}

\end{document}