I want to write both the theorems and definitions (numbering should be chapter-wise, like 2.1, 2.2 etc) in the form of the attached jpg file.
EDIT:
In the upper box only the title will come and within the box, the theorem/definition number will come. What to do?
I get a code in internet. I don't know how to modify it. Please help.
\documentclass{article}
\usepackage{amsmath}
\usepackage{cleveref}
\usepackage[most]{tcolorbox}
\newtcbtheorem{Theorem}{Theorem}{
enhanced,
sharp corners,
attach boxed title to top left={
yshifttext=-1mm
},
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,
}
}{thm}
\newtcbtheorem[no counter]{Proof}{Proof}{
enhanced,
sharp corners,
attach boxed title to top left={
yshifttext=-1mm
},
colback=white,
colframe=blue!25,
fonttitle=\bfseries,
coltitle=black,
boxed title style={
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,
}
}{prf}
\begin{document}
\begin{Theorem}{}{fermat}
No three positive integers \(a\), \(b\) and \(c\) satisfy the equation \(a^{n}
+ b^{n} = c^{n}\) for any integer greater than two.
\end{Theorem}
\begin{Proof}{Theorem \ref{thm:fermat}}{}
The proof is easy, but too large to fit in this box.
\end{Proof}
\end{document}
Edit 2: Only the problem is in setting counter. Theorem should come 1.1, 1.2 ... and definition should come same as 1.1, 1.2 ....
\documentclass{book}
\usepackage{amsmath}
\usepackage[most]{tcolorbox}
\usepackage{cleveref}
\tcbset{theostyle/.style={
enhanced,
sharp corners,
attach boxed title to top left={
xshift=-1mm,
yshift=-4mm,
yshifttext=-1mm
},
top=1.5ex,
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,
}
}}
\newtcbtheorem[number within=chapter]{Theorem}{Theorem}{%
theostyle
}{thm}
\newtcbtheorem[number within=chapter]{Definition}{Definition}{%
theostyle
}{def}
\newenvironment{myTheorem}[2]{ \begin{Theorem}[adjusted title=#1]{}{#2}
\textbf{Theorem \thetcbcounter.} }{\end{Theorem}}
\newenvironment{myDefinition}[2]{ \begin{Theorem}[adjusted title=#1]{}{#2}
\textbf{Definition \thetcbcounter.} }{\end{Theorem}}
\begin{document}
\chapter{Foo chapter}
\begin{myDefinition}{ggggggggg}{ReadingTheManual}
Reading the manual helps ;-)
\end{myDefinition}
\begin{myTheorem}{fffff}{fermat}
No three positive integers \(a\), \(b\) and \(c\) satisfy the equation \(a^{n}
+ b^{n} = c^{n}\) for any integer greater than two.
\end{myTheorem}
\end{document}
chapters
when usingarticle
class? ;-)