This question already has an answer here:

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

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

Brackets with fancyvrb




some text some text some 
some text some text some 
some text some text some 

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 Allred Dec 4 '13 at 5:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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.

\parskip 1em
This is
a \verbatim

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

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

enter image description here

  • 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
  • 1
    @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