[Tex/LaTex] Styling amsthm theorem using thmtools

thmtools

I'm trying to stylize my definitions/examples etc. a bit to have a more simple overview once finished. Im specifically trying to achieve this: Example But don't really know how to achieve it. I can only think of a thin vertically stretched box aligned to the left of the whole environment but failed at implementing it since I'm fairly new to tex.

MWE:

\pdfminorversion=7

\documentclass[a4paper, 12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{amsmath, amsthm, amssymb, amsfonts}
\usepackage{thmtools}
\usepackage{lipsum}

% Theorem styles
\newtheoremstyle{customDefinition}
    {}            % Space above, empty = `usual value'
    {}            % Space below
    {\itshape}    % Body font
    {}            % Indent amount (empty = no indent, \parindent = para indent)
    {\bfseries}   % Thm head font
    {}            % Punctuation after thm head
    {\newline}    % Space after thm head: \newline = linebreak
    {Definition \thmnumber{#2}\thmname{\hfill#1}}   % Thm head spec

\begin{document}
    \theoremstyle{customDefinition}
    \newtheorem{definition}{Matrix}[section]
    \begin{definition}
        \lipsum[2]
    \end{definition}
\end{document}

Best Answer

I propose this code entirely based on thmtools and the leftbar environment from the framed package:

\pdfminorversion=7

\documentclass[a4paper, 12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry} % showframe only for checking purpose. Remove for production.
\usepackage[svgnames]{xcolor}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{thmtools}
\usepackage{lipsum}

\usepackage{framed}
\colorlet{headcolour}{DarkOrange}
\colorlet{rulecolour}{DarkOrange}
\renewenvironment{leftbar}{%
  \def\FrameCommand{{\color{rulecolour}\vrule width 3pt} \hspace{10pt}}%
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%
 {\endMakeFramed}

 \declaretheoremstyle[headfont=\sffamily\bfseries,%
 notefont=\sffamily\bfseries,%
 notebraces={}{},%
 headpunct=,%
 bodyfont=\sffamily\itshape,%
 headformat=\color{headcolour}\NAME~\NUMBER\hfill\NOTE\smallskip\linebreak,%
 preheadhook=\begin{leftbar},%
 postfoothook=\end{leftbar},%
 ]{customDefinition}
 \declaretheorem[style=customDefinition, numberwithin=section]{definition}

\begin{document}

\setcounter{section}{4}
    \begin{definition}[Matrix]
        \lipsum[2]
    \end{definition}

\end{document} 

enter image description here

Related Question