I'm writing a document where I need to put some text inside a box. I have figured out how to make a rounded-corner box with the graphical appearence I was looking for.

My code is the following:

\documentclass[11pt, a4paper]{report} 

\definecolor{mycolor}{rgb}{0.122, 0.435, 0.698}

  boxrule=0.5pt,arc=4pt,boxsep=0pt,left=6pt,right=6pt,top=5pt,bottom=5pt, hbox}


\mybox{\textbf{Assumption 1:} Atmospheric forces can be neglected.}


With the following output:

enter image description here

I would like to know how:

  1. Indent the box when it is located at the beginning of a section or paragraph. I've tried \indent but it seems to not work.

  2. How to control the width of the box. When I write a long text it exceeds the page margins. I would like to set the width to constrain the box size and force the text to fit inside the width I have choosen (just in case of a long text).

  3. When a long text wraps to start a new line within the box, I would like to get an alignment just after the colon, i.e. ":", and not with the first world of the box as normally happens.

  4. It is more a curiosity: I've defined a \tcbset{enhanced,colframe={violet!60},colback={black!3!white}, drop shadow} for another box inside the document. Why my "assumption box" acquires the drop shadow option and displays it?

Here some examples of the result I would like to get:

enter image description here

I would appreciate a lot any kind of help. However, It would be great If someone could provide me a MWE to accomplish the whole task. Thank you very much.

  • Your code doesn't produce the shown box. In fact your code is missing [most] option which allows enhanced option. And as you don't use drop shadow in mybox option, it doesn't add any drop shadow to resulting box. – Ignasi May 4 at 13:23
  • I'm sorry @Ignasi, I've forgotten to add [most] on the original MWE I have written. It is actually present in my current code. I don't still get the point. – Catarella May 4 at 18:21
  • My point 4 lecture was wrong. \tcbset fixes options for all boxes, therefore drop shadow inside tcbset will apply this shadow to all boxes unless you use no shadow. It's better that you use \tcbset{ style-name/.style={...}} to define several styles and apply them to particular tcolorboxes. – Ignasi May 4 at 21:53
  • I've solved the point 4 in this way: I have left \newtcbox to define my "assumption box", called \mybox as the MWE shows. The other box, that was defined by \tcbset, now it has been defined by \tcboxmath[option]{formula}, given that it contains a math equation. However, I keep needing help with points 1,2 and 3. I hope that someone come forward. – Catarella May 5 at 15:18
  • Update: It seems I've solved point 1. I've found the option left skip=length inside tcolorbox package, where I replaced "lenght" with my current indentation parameter, equal to 15pt. I don't know if it is a proper way to do it, but it works. Any further suggestions are welcome though. – Catarella May 5 at 16:15

tcolorbox offers two kind of boxes tcbox and tcolorbox. First ones are for a short texts which won't break in lines while seconds can contain longer texts and use a whole line as default width. Therefore, I think that what OP wants is not possible with a unique command.

Following code proposes an environment (tcolorbox) for the larger boxes. The inner contents described by OP looks like a description environment. I've assumed that the box only contains one item. The alignment has been taken from an egreg`s answer

longbox environment has one optional and one mandatory parameters. The mandatory is the item title while the optional will be applied as tcolorbox options to change box format (even width).


\definecolor{mycolor}{rgb}{0.122, 0.435, 0.698}


\newtcolorbox{longbox}[2][]{before upper={\begin{xdesc}{#2}},after upper={\end{xdesc}}, 
    enhanced, breakable, colframe=mycolor,colback=mycolor!7!white,
    boxrule=0.5pt, arc=4pt, boxsep=0pt, left=6pt, right=6pt, top=5pt, bottom=5pt, #1}



\begin{longbox}[width=.8\linewidth]{Assumption 1}

\begin{longbox}[colback=red!30, sharp corners]{Example}

Only one line

enter image description here

  • Thank you so much @Ignasi for the amazing effort. That's the kind of code I needed. I have added left skip=length inside your suggested code, just to set the indentation I need. For the shortest boxes I will keep using tcbox, so that the box adapts to the shorter text with the hbox option. – Catarella May 5 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.