3

I saw the following beautifully colored text for definitions, theorems, examples... in someone's notes. How do we achieve this in latex?

enter image description here

2

2 Answers 2

3

Here is a way to reproduce the second image with ntheorem, mdframed and xcolor:

\documentclass[11pt]{book} %
\usepackage[T1]{fontenc}
\usepackage[svgnames]{xcolor}%
\usepackage{amssymb,amsmath}
%\usepackage{framed}
\usepackage[amsmath,framed]{ntheorem}
\usepackage[ntheorem]{mdframed}
\theoremheaderfont{\sffamily\bfseries}
\theorembodyfont{\normalfont\upshape}
   \theoremstyle{plain}
\newmdtheoremenv[topline=false, bottomline=false, rightline=false, leftline=true, linewidth=2pt, linecolor=Purple, backgroundcolor=Thistle! 20, innertopmargin=10pt, innerbottommargin=10pt]{example}{Example}

\begin{document}

\begin{example}
The rule $1$ cannot follow. $1$ corresponds to
    \[ A = \begin{bmatrix}
      1 & 1 \\ 1 & 0
    \end{bmatrix} \]%
\end{example}

\end{document}

enter image description here

2

With tcolorbox

\documentclass{article}
\usepackage{tcolorbox, xcolor}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[colback=blue!15, sharp corners, boxrule=0pt, leftrule=1mm, colframe=blue]
\lipsum[1]
\end{tcolorbox}
\end{document}

enter image description here

4
  • May I ask why the downvote?
    – Dan
    Dec 26, 2021 at 16:26
  • I did not downvote but a possible explanation might be that the person that downvoted felt that it is a bad idea to answer a question that is a duplicate, because it causes fragmentation of answers to the same question in multiple places and/or because you don't 'deserve' reputation for providing essentially the same answer as has been given before.
    – Marijn
    Dec 27, 2021 at 11:37
  • I noticed that you wrote your answer before the first vote to close as duplicate so you cannot be 'accused' of knowingly answering a duplicate but maybe the downvoter felt that you should have looked for the duplicate yourself instead of answering.
    – Marijn
    Dec 27, 2021 at 11:40
  • See also meta.stackoverflow.com/questions/391788/… and meta.stackoverflow.com/questions/376165/… for related discussions on Meta.SO and also meta.stackexchange.com/questions/202895/… from Meta.SE.
    – Marijn
    Dec 27, 2021 at 11:49

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