4

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}
1
  • amsmath has nothing to do with theorems; you mean amsthm. Please fix the title. Commented Apr 13, 2019 at 20:54

1 Answer 1

5

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

3
  • You're welcome. Note that it should break across pages if necessary, but I didn't test it
    – Bernard
    Commented Apr 13, 2019 at 19:37
  • Maybe remove the showfram so others dont get confused Commented Apr 13, 2019 at 20:20
  • It was there only to check every thing was placed as expected. I'll a word about it.
    – Bernard
    Commented Apr 13, 2019 at 20:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .