theorems and definitions boxes (numbering should be chapter-wise)

\documentclass{book}
\usepackage{amsmath}
\usepackage{cleveref}
\usepackage[most]{tcolorbox}

\newtcbtheorem[number within=chapter]{Theorem}{}{
        enhanced,
        sharp corners,
        attach boxed title to top left={
            xshift=-1mm,
            yshift=-5mm,
            yshifttext=-1mm
        },
        top=1.5em,
        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[number within=chapter]{Definition}{}{
        enhanced,
        sharp corners,
        attach boxed title to top left={
            xshift=-1mm,
            yshift=-5mm,
            yshifttext=-1mm
        },
        top=1.5em,
        colback=white,
        colframe=blue!75!black,
        fonttitle=\bfseries,
        boxed title style={
            sharp corners,
            size=small,
            colback=blue!75!black,
            colframe=blue!75!black,
        } 
    }{def}

\newenvironment{myTheorem}[2]{ \begin{Theorem}[adjusted title=#1]{}{#2} 
  \textbf{Theorem \thetcbcounter.} }{\end{Theorem}}

  \newenvironment{myDefinition}[2]{ \begin{Definition}[adjusted title=#1]{}{#2} 
  \textbf{Definition \thetcbcounter.} }{\end{Definition}}

\begin{document}
\chapter{Foo}
\begin{myTheorem}{Fermats Last Theorem}{thm:FermatsLastTheorem}
    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}
\begin{myDefinition}{Reading the Manual}{def:ReadingTheManual}
  Reading the manual helps ;-)
\end{myDefinition}
\begin{myDefinition}{Definition}{def:Definition}
  A statement of the meaning of a word, phrase, or term, as in a dictionary entry.
\end{myDefinition}
\begin{myTheorem}{Pythagoras Theorem}{thm:PythagorasTheorem}
    In a right angled triangle: the square of the hypotenuse is equal to the sum of the squares of the other two sides.
\end{myTheorem}
\end{document}

enter image description here


Use the number within=chapter 'init' option of the \newtcbtheorem macro to apply chapter-wise counting of theorems defined with this macro. (See sections 5 and 16 of the tcolorbox manual for more information on the init option.)

The box style can be changed by using the xshift and yshift keys of attach boxed title to top left.

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


\begin{document}

\chapter{Foo chapter}

\begin{Definition}{}{ReadingTheManual}
  Reading the manual helps ;-)
\end{Definition}

\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}
\end{document}

enter image description here