Flexible brackets around text [duplicate]

Is there any way to make flexible brackets around some text?

So I tried to use fancyvrb and got something like this:

\documentclass{article}
\usepackage{fancyvrb}
\usepackage{color}

\definecolor{darkblue}{rgb}{0.1,0.3,0.5}

\DefineVerbatimEnvironment%
{MyVerbatim}{Verbatim}
{gobble=0,label=\hspace{.85\textwidth},labelposition=all,
frame=single,framerule=3pt,framesep=5mm,rulecolor=\color{darkblue}}

\begin{document}
\begin{minipage}{6cm}
\begin{MyVerbatim}
some text some text some
some text some text some
some text some text some
\end{MyVerbatim}
\end{minipage}
\hfill
\end{document}


However, I am unhapy with it, because of the misuse of fancvrb.

I want to be able to define the thickness of the rule, the size of the corners or the spaces. A good candidate would be a package similar to dashedbox.

Any hint would be appreciated.

marked as duplicate by Werner, Herr K., jubobs, cmhughes, Sean AllredDec 4 '13 at 5:10

Based on the user's comment, I EDITED the answer for ease of use:

This solution just uses an \fbox whose separation and rule thickness are set with \fboxsep and \fboxrule. It then uses a stack to place the verbatimbox content into a white box, vertically augmented to overwrite some of the \fbox border in order to give the appearance of brackets.

To simplify things, I have created the \bracetext macro which takes four arguments. The first is the stuff to embrace. It can be a verbbox, plain text, a parbox, whatever. The second argument is the rule thickness of the brace (\fboxrule). The third argument is the gap around the object (\fboxsep). The last argument is the horizontal width of the brace prong.

\documentclass{article}
\usepackage{verbatimbox}
\usepackage{stackengine}
\renewcommand\stacktype{L}
\usepackage{xcolor}
\newcommand\bracetext[4]{%
\fboxrule=#2
\fboxsep=#3
\def\hsep{#4}
\stackon[-\fboxrule-.1pt]{%
\textcolor{blue}{\fbox{\hspace{\hsep}#1\hspace{\hsep}}}%
}
\parskip 1em
\begin{document}
\begin{verbbox}
This is
a \verbatim
test
\end{verbbox}
\bracetext{\theverbbox}{1pt}{3pt}{5pt}

\bracetext{This is a test}{2pt}{4pt}{5pt}

\bracetext{\parbox{1in}{This is text in a 1 inch parbox}}{4pt}{5pt}{3pt}
\end{document}


• I am starting to implement your package in some of my documents but when I read your documentation, you don't have a lot of examples. It would be nice to provide some standard and advanced examples. – azetina Dec 4 '13 at 0:40
• @azetina Do you mean verbatimbox or stackengine? I think the latter package documentation give a fair number of examples. But by all means, feel free to follow up with any questions. – Steven B. Segletes Dec 4 '13 at 0:44
• Its the stackengine. I have been only able to do two answers here on TeX.SX because I cannot seem to find examples to study from and see where it can be implemented. I think its just the way you prepared your documentation. But I will get it eventually by following how you answer questions. – azetina Dec 4 '13 at 0:54
• @azetina I will certainly give some thought on including more examples in the docs. In the meantime, I have answered a large number of questions on this site, using stackengine. And so a search for the package name will yield quite an assortment from which to choose. – Steven B. Segletes Dec 4 '13 at 1:05
• Thanks for the great answers guy's. Many of the examples use '[]' so, they are not flexible enough. @StevenB.Segletes: I will try this, but it's really not easy, so I need to dive into stackengine. – user42138 Dec 4 '13 at 13:41