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

Bernard
  • 271,350
No One
  • 269

2 Answers2

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

Bernard
  • 271,350
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

Dan
  • 3,699
  • May I ask why the downvote? – Dan Dec 26 '21 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 '21 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 '21 at 11:40
  • See also https://meta.stackoverflow.com/questions/391788/how-much-effort-are-answerers-expected-to-put-into-finding-duplicates and https://meta.stackoverflow.com/questions/376165/how-much-research-effort-is-expected-of-answerers for related discussions on Meta.SO and also https://meta.stackexchange.com/questions/202895/should-we-downvote-answers-to-obvious-duplicate-questions from Meta.SE. – Marijn Dec 27 '21 at 11:49