[Tex/LaTex] Create a box using the tcolorbox package or any other? (image)

boxcolorpackagestablestcolorbox

I would like to make a box like the figure below. Can you assist me with text code using tcolorbox?
enter image description here

Thanks

Best Answer

I offer a solution based on the xcoffin package, not to compete with the other excellent solutions proposed, but to show the advantages of a great package.

Many questions posted in this forum relates with the positioning of various elements as graphics, tables, text, etc. on a page, in specific places and in relation with one another. In many cases against TeX wishes.

Over time I was able to replace geometry, rotate, titlepage, and similar packages with xcoffin, to design book covers, title-pages, posters, chapter styles, etc. thus avoiding conflicts and specially avoiding the dreadful time checking a full upgrade to discover that old projects not longer produce the same output or simply did not run at all.

To me the lesser number of packages, the better.

xcoffin provides only a handful of commands with intuitive meaning (at least for me) and does not require remembering dozens of keyvals or options. Excellent manual, by the way.

I also appreciate the fact that in the case of the one-time jobs mentioned earlier, the resulting code is very simple since there not need to contemplate multiple alternatives for the input and it is mostly auto-documented. Even if a book title changes over the course of a project, the corrections are straightforward.

Of course previously you need to produce the material, perhaps using amsmath, xcolor, tabularx, graphicx, ... and then fill the coffin with it.

Afterward you fit the coffins in the page using as origin the current text insertion point, or in relative positions among themselves, as could be the case of an image and a margin explanatory note. Then you typeset the result at the insertion point or in any other place of the page of your liking (a plus) since the resulting coffin it is not a float.

In this particular case only four coffins are required: the Output which will collect the others, a green rectangle, a side rule, and the inside text, as shown in the code. Both the rectangle and the rule adapts theirs height to the text content.

I also include a macro, to be moved to the preamble, to reduce the clutter of the document. For the fun of it, and supposing that several Definitions will be included in the document, I added a counter and applied the macro five times.

\documentclass{article}

\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{xcoffins,calc}

\begin{document}

%% Create and Set Coffins

\NewCoffin\Output   %Coffin to hold the others 
\NewCoffin\Definition % Definition definition ...
\NewCoffin\BackFrame % Background: green rectangle
\NewCoffin\SideRule  %lateral left border

\SetHorizontalCoffin\Output{} % It will provide the reference point to join the others

\SetVerticalCoffin\Definition{\linewidth}{%
\textbf{Definition.} $\gamma^5$ is defined to be the matrix given by:%
\[\gamma^5=\frac{1}{24}\epsilon_{abcd}\gamma^{abcd} \]%
}

%% Make both \BackFrame & SideRule heights = height of Definition + 1*baselineskip
\SetHorizontalCoffin\BackFrame{\color{green!30!gray!15}\rule{\linewidth}{\CoffinTotalHeight\Definition + \baselineskip}}    

\SetHorizontalCoffin\SideRule{\color{green!50!black}\rule{3pt}{\CoffinTotalHeight\Definition +\baselineskip}} %vertical side rule 

%% Assembly Coffins
\JoinCoffins*\Output[l,t]\BackFrame[l,t] %attach left-top corner of BackFrame  to idem of Output
\JoinCoffins*\Output[l,t]\SideRule[l,t] %attach left-top corner of  SideRule to idem of Output
\JoinCoffins*\Output[l,t]\Definition[l,t](0pt,-\baselineskip) %attack left-top corner of Definition to idem of Output

%% now your document

We need some more meaningless test to for a multiline paragraph, because these form a basis for the space of all complex $4\times4$ matrices.

%% Typeset Definition
\noindent\TypesetCoffin\Output % at the text insertion point. It is not a float.
\vspace*{\CoffinTotalHeight\Definition}\bigskip %make some room for Output

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. 

%%%%%%%%%%%%%%%%%  macro def, to be moved  to the preamble, use as \SetDefinition{your-text}
\newcounter{defcounter}

\newcommand{\SetDefinition}[1]{%
    \SetHorizontalCoffin\Output{} % It will be the reference point join the others  
    \SetVerticalCoffin\Definition{\linewidth}{\textbf{Definition \stepcounter{defcounter}\Roman{defcounter}.} #1} %added counter

    %% Make both \BackFrame & SideRule heights = height of Definition + 1*baselineskip
    \SetHorizontalCoffin\BackFrame{\color{green!30!gray!15}\rule{\linewidth}{\CoffinTotalHeight\Definition + \baselineskip}}    
    \SetHorizontalCoffin\SideRule{\color{green!50!black}\rule{3pt}{\CoffinTotalHeight\Definition +\baselineskip}} %vertical side rule 

    %% Assembly Coffins
    \JoinCoffins*\Output[l,t]\BackFrame[l,t] %attach left-top corner of BackFrame  to idem of Output
    \JoinCoffins*\Output[l,t]\SideRule[l,t] %attach left-top corner of  SideRule to idem of Output
    \JoinCoffins*\Output[l,t]\Definition[l,t](0pt,-\baselineskip) %attack left-top corner of Definition to idem of Output
    %% Typeset ooutput
    \noindent\TypesetCoffin\Output % at the text insertion point. It is not a float.
    \vspace*{\CoffinTotalHeight\Definition}\bigskip %make some room for Output
}   
%%%%%%%%%%%%%%%%%%%%%   end macro

\SetDefinition{$\gamma^1$ is defined to be the matrix given by:\[\gamma^1=\frac{1}{24}\epsilon_{abcd}\gamma^{abcd} \]}
\SetDefinition{$\gamma^2$ is defined to be the matrix given by:\[\gamma^2=\frac{1}{24}\epsilon_{abcd}\gamma^{abcd} \]}
\SetDefinition{$\gamma^3$ is defined to be the matrix given by:\[\gamma^3=\frac{1}{24}\epsilon_{abcd}\gamma^{abcd} \]}
\SetDefinition{$\gamma^4$ is defined to be the matrix given by:\[\gamma^4=\frac{1}{24}\epsilon_{abcd}\gamma^{abcd} \]}
\SetDefinition{$\gamma^5$ is defined to be the matrix given above.\\} % a short Definition
\end{document}

Definition

Related Question