# How to make a bracketed environment like this?

I'm hoping to write a custom environment for a double-bracketed "key point" section (see image below). The left and right brackets should be as tall as the text and there should be a little icon with title and text, exactly like in the following example:

Not sure where to start.

• Welcome to TeX.SE! I'd like to encourage you to look at the tcolorbox package. – marmot Sep 24 '18 at 20:49

Just for fun: a tcolorbox based answer.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\newtcolorbox{lbulbox}[1][]{enhanced,
colback=white,
boxrule=0mm,top=0mm,bottom=0mm,left=2cm,right=4mm,sharp corners,
overlay={%
\draw[ultra thick] ([xshift=2mm]frame.north west)-|(frame.south west)--
([xshift=2mm]frame.south west);
\draw[ultra thick] ([xshift=-2mm]frame.north east)-|(frame.south east)--
([xshift=-2mm]frame.south east);
\draw[thick,white] ([xshift=2mm]frame.north west) -- ([xshift=-2mm]frame.north east)
([xshift=2mm]frame.south west) -- ([xshift=-2mm]frame.south east);
\begin{scope}[shift={([xshift=1cm]frame.west)}]
\shadedraw[ball color=yellow] (290:0.3) arc(290:-20:0.3) -- ++(0.2,-0.2)
-- ++(-0.15,-0.15) --cycle;
\fill[top color=gray,middle color=gray!60!black,bottom color=black,shading angle=-40] (-20:0.3)
-- ++(0.2,-0.2) -- ++(-0.15,-0.15) -- (290:0.3) -- cycle;
\foreach \X in {170,140,110}
{\draw[thick] (\X:0.4) -- (\X:0.6);}
\end{scope}
}}

\begin{document}
\lipsum[1]
\begin{lbulbox}
\textbf{New- and old-style classes.}\par
Old-style classes have only human students. In new-style classes, ducks, koalas
and marmots are welcome. Hibernation needs of marmot students are respected.
\end{lbulbox}
\lipsum[2]
\end{document}


The following is a quick implementation of what you want without any packages. The syntax is quick and dirty and a mixture of LaTeX and TeX syntax. Every aspect of the environment should be adjustable if you change the used lengths and macros (every one should be commented to make clear what it's used for).

\documentclass[]{article}

\usepackage[]{graphicx}

\makeatletter
% store the icon
\newsavebox\Bracket@icon
\setbox\Bracket@icon\hbox{\includegraphics[width=1cm]{example-image-duck}}
% the vertical displacement of the icon from the centre of the contents
\newlength\Bracket@iconOffset
\Bracket@iconOffset0pt
% store the contents of the environment
\newsavebox\Bracket@box
% the width it should take as a macro so that the width is evaluated when used,
% this should provide more flexibility
\newcommand\Bracket@totwidth{.95\linewidth}
% the actual contents width (gets calculated)
\newlength\Bracket@width
% the vertical amount of space the brackets are taller than their contents
% the width of the horizontal rules of the brackets
\newlength\Bracket@length
\Bracket@length5mm
% the thickness of the bracket rules
\newlength\Bracket@linewidth
\Bracket@linewidth2pt
% the amount of white space between the left bracket and the logo
% the amount of white space between the logo and the contents
% the amount of white space between the right bracket and the contents
% the vertical white space added above the whole environment
\newlength\Bracket@aboveSkip
\Bracket@aboveSkip1ex
% the vertical white space added below the whole environment
\newlength\Bracket@belowSkip
\Bracket@belowSkip1ex
% the definition of the environment
\newenvironment{Bracket}[1]
{%
\Bracket@width\Bracket@totwidth
\setbox\Bracket@box\vbox\bgroup
\hsize\Bracket@width
\linewidth\hsize
\noindent
\@afterindentfalse
}
{%
\egroup
\par
\vskip\Bracket@aboveSkip
\noindent
\null
\hskip\dimexpr(\linewidth-\Bracket@totwidth)/2\relax
\rlap
{%
width \Bracket@linewidth
\rlap
{%
\rlap
{%
{%
\vrule height 0pt
depth \Bracket@linewidth
width \Bracket@length
}%
}%
{%
\vrule height \Bracket@linewidth
depth 0pt
width \Bracket@length
}%
}%
\raisebox
{%
\dimexpr
.5\ht\Bracket@box-.5\dp\Bracket@box
-.5\ht\Bracket@icon+.5\dp\Bracket@icon
+\Bracket@iconOffset
\relax
}
{\usebox\Bracket@icon}%
\usebox\Bracket@box
width \Bracket@linewidth
\rlap
{%
\hskip-\Bracket@linewidth
\llap
{%
{%
\vrule height 0pt
depth \Bracket@linewidth
width \Bracket@length
}%
}%
\llap
{%
{%
\vrule height \Bracket@linewidth
depth 0pt
width \Bracket@length
}%
}%
}%
}%
\par
\vskip\Bracket@belowSkip
}
\makeatother

\usepackage{duckuments}% only for \blindduck

\begin{document}
\blindduck[1]
\begin{Bracket}{New- and old-style classes}
\blindduck[2]
\end{Bracket}
\noindent
\blindduck[3]
\end{document}


EDIT: Allows a total width greater than the surrounding \linewidth without overfull boxes.

I should mention that the result is not page breakable. If this is required, tcolorbox can be page broken if set up correctly, so take a look at @marmot's answer (this doesn't claim that the way @marmot set up tcolorbox is page breakable, I didn't check this, so it might be breakable, but might as well be not).