Create a box using the tcolorbox package or any other? (image)
The following might give you an idea on how to start:
\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcolorbox{mybox}{
enhanced,
boxrule=0pt,frame hidden,
borderline west={4pt}{0pt}{green!75!black},
colback=green!10!white,
sharp corners
}
\begin{document}
\begin{mybox}
\textbf{Definition} My definition text here
\end{mybox}
\end{document}
A very light weight solution is to use a tabular. Not as sexy as \tcolorbox
and other TikZ based solution, but it compiles fast. The simplest is to use a p
-column as wide as the \linewidth
.
First I define a new column type
N
and calculate its width to\linewidth
minus twotabcolsep
. Then the table fits between the margins and will adapt if you change margins.Since we need some space above an below the "box", I have set the table inside a
\center
-environment to ensure that the table is fixed between the margins, and vertical space on par with other environments.Thereafter, I define the width and colour of the left vertical bar. I put the redefinition inside the centring environment, which limits the scope of the redefinitions to this taular. Without, all table rules will be green and 3 pt thick!
I have since yesterday slightly optimised the code. It is possible to define a new environment, and move most of the code to such definition. This may be useful if you have lot of boxes.
\documentclass{article}
\usepackage{amsmath}
\usepackage[table]{xcolor}
\usepackage{array}
\newcolumntype{N}{@{}|>{\raggedright\arraybackslash\hspace{0pt}}p{\dimexpr(\linewidth-2\tabcolsep)}@{}}
\begin{document}
We need som more meaningless test to for a multiline paragraph, because these form a basis for the space of all compex $4\times4$ matrices.
\begin{center}
\setlength{\extrarowheight}{4pt}
\setlength{\arrayrulewidth}{3pt}
\arrayrulecolor{green!50!black}
\begin{tabular}{N}
\cellcolor{green!15}{
\textbf{Definition:} $\lambda^{5}$ is defined to be the matrix given by:
\medskip
\[\lambda^{5}=\dfrac{1}{14} \epsilon_{abcd}\gamma^{abcd} \]
}
\end{tabular}
\end{center}
We can invert this to obtain $ \epsilon_{abcd}i\gamma^{abcd} \lambda^{5}$, but we need som more meaningless test to for a multiline paragraph.
\end{document}
I have used mdframed
instead of tcolorbox
(they are similar package but tcolorbox
is mor complete than mdframed
). You can see that you have the same result. Here there is my proposal where I have used for theorem, definition, examples, the specific package amsthm
with the possibility to create a book: see the specific class of the document \documentclass[12pt]{book}
. For to increase the tickness vertical green line you can to change the value linewidth=2.5pt
.
This example sets the text in italic:
\documentclass[12pt]{book}
\usepackage{amsthm}
\usepackage{amsmath,amssymb}
\usepackage[svgnames]{xcolor}
\RequirePackage[framemethod=default]{mdframed}
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=Green,
backgroundcolor=Green!10,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=2pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=2.5pt,
innerbottommargin=5pt]{dBox}
\newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}}
\newtheorem{definitionT}{Definition}[section]
\begin{document}
\begin{definition}
$\gamma^5$ is defined to be a matrix given by:
\[\gamma^5=\frac{1}{24}\epsilon_{abcd}\gamma^{abcd}\]
\end{definition}
\end{document}
Another code sets the text in roman adding \theoremstyle{definition}
. See this MWE:
\documentclass[12pt]{book}
\usepackage{amsthm}
\usepackage{amsmath,amssymb}
\usepackage[svgnames]{xcolor}
\RequirePackage[framemethod=default]{mdframed}
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=Green,
backgroundcolor=Green!10,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=2pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=2.5pt,
innerbottommargin=5pt]{dBox}
\theoremstyle{definition}
\newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}}
\newtheorem{definitionT}{Definition}[section]
\begin{document}
\begin{definition}
$\gamma^5$ is defined to be a matrix given by:
\[\gamma^5=\frac{1}{24}\epsilon_{abcd}\gamma^{abcd}\]
\end{definition}
\end{document}