I want to create these theorem boxes
- 293
-
(it's better to ask separate individual questions.) Style 2 is tables - Create a box using the tcolorbox package or any other? (image) - TeX - LaTeX Stack Exchange . – user202729 Dec 26 '21 at 01:33
2 Answers
- set
attach boxed title to top leftto get a boxed title on the top left. - rule above the title and the custom title box is drawn in
boxed title style={overlay={...}} - rule above the frame and shade below the title is drawn in
overlay unbroken={...} - left rule is drawn by
borderline west=... - shadow is controled by
drop fuzzy shadow
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\tcbuselibrary{skins}
\usetikzlibrary{shadings}
\newcounter{example}
\colorlet{colexam}{red!75!black}
\tcbset{
base/.style={
empty,
frame engine=path,
colframe=yellow!10,
sharp corners,
title={Example \thetcbcounter},
attach boxed title to top left={yshift*=-\tcboxedtitleheight},
boxed title style={size=minimal, top=4pt, left=4pt},
coltitle=colexam,fonttitle=\large\bfseries\sffamily,
}
}
\newtcolorbox[use counter=example]{myexamplea}{%
base,
boxed title style={overlay={
\draw[colexam,line width=3pt,] (frame.north west)--(frame.north east);
}},
colback=colexam,
overlay unbroken={
\draw[colexam] ([yshift=-1.5pt]title.north east)--([xshift=-0.5pt, yshift=-1.5pt]title.north-|frame.east);
},
}
\newtcolorbox[use counter=example]{myexampleb}{%
base,
drop fuzzy shadow,
borderline west={3pt}{-3pt}{colexam},
}
\newtcolorbox[use counter=example]{myexamplec}{%
base,
drop fuzzy shadow,
coltitle=black,
borderline west={3pt}{-3pt}{teal!50},
attach boxed title to top left={xshift=-3mm, yshift*=-\tcboxedtitleheight/2},
boxed title style={right=3pt, bottom=3pt, overlay={
\draw[draw=teal!70, fill=teal!70, line join=round]
(frame.south west) -- (frame.north west) -- (frame.north east) --
(frame.south east) -- ++(-2pt, 0) -- ++(-2pt, -4pt) --
++(-2pt, 4pt) -- cycle;
}},
overlay unbroken={
\scoped \shade[left color=teal!10!black, right color=teal]
([yshift=-0.2pt]title.south west) -- ([xshift=-1.5pt, yshift=-0.2pt]title.south-|frame.west) -- ++(0, -6pt) -- cycle;
},
}
\begin{document}
\begin{myexamplea}
\lipsum[1][1-3]
\end{myexamplea}
\begin{myexampleb}
\lipsum[1][1-3]
\end{myexampleb}
\begin{myexamplec}
\lipsum[1][1-3]
\end{myexamplec}
\end{document}
- 4,516
-
Very nice and my congratulations. +1. I will use
\ssfamilyfont for the title like the original screenshot. – Sebastiano Jul 05 '20 at 11:37 -
1
-
I'm sorry for my mistake. Thank you very much to have applied my advice. – Sebastiano Jul 05 '20 at 14:50
Straight from the book -- http://mirror.iopb.res.in/tex-archive/macros/latex/contrib/tcolorbox/tcolorbox.pdf
\documentclass[11pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{varioref}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usepackage{cleveref}
\newtcolorbox{YetAnotherTheorem}[1]%
{enhanced,arc=0mm,outer arc=0mm,
boxrule=0mm,toprule=1mm,bottomrule=1mm,left=1mm,right=1mm,
titlerule=0mm,toptitle=0mm,bottomtitle=0mm,top=0mm,
colframe=red!50!black,colback=red!5!white,coltitle=red!50!black,
colbacktitle=yellow!50!white,colback=red!5!white,
title=#1,
fonttitle=\bfseries\sffamily\normalsize,fontupper=\normalsize\itshape,
}
\begin{document}
\begin{YetAnotherTheorem}{Mittelwertsatz f"{u}r $\mathbf{n}$ Variable}
$f\in C^{1}(D,\mathbb{R})$. Dann gibt es auf jeder Strecke
$[x_0,x]\subset D$ einen Punkt $\xi\in[x_0,x]$, so dass gilt
\begin{equation}
f(x)-f(x_0) = \operatorname{grad} f(\xi)^{\top}(x-x_0)
\end{equation}
\end{YetAnotherTheorem}
\end{document}
edit
Experimenting with the options --
{enhanced,arc=1mm,outer arc=1mm,
boxrule=0mm,toprule=0mm,bottomrule=0mm,left=1mm,right=1mm,leftrule=2pt,
titlerule=0mm,toptitle=0mm,bottomtitle=0mm,top=0mm,
colframe=blue!50!black,colback=blue!5!white,coltitle=blue!50!black,
colbacktitle=yellow!50!white,colback=green!5!white,
title=#1,
fonttitle=\bfseries\sffamily\normalsize,fontupper=\normalsize\itshape,
}
--will give different results such as below
edit for title box--by changing the options again
{
enhanced,
arc=1mm,
outer arc=1mm,
boxrule=0mm,
toprule=0mm,
bottomrule=0mm,
left=1mm,
right=1mm,
leftrule=2pt,
titlerule=0mm,
toptitle=0mm,
bottomtitle=0mm,
top=0mm,
colframe=blue!50!black,
colback=blue!5!white,
title=#1,
fonttitle=\bfseries\sffamily\normalsize,fontupper=\normalsize\itshape,
attach boxed title to top left={
xshift=-1mm,
yshift=-5mm,
yshifttext=-1mm
},
top=1.5em,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,colbacktitle=white
}
}
- 21,280





