How is it possible for me to put a box of adjustable size surrounded by a text in a latex document ?

For instance : my inspiration is from the yellow boxes in this image :

enter image description here

\usepackage{tikz, adjustbox}

Paragraphe de test pour essayer de placer une boîte 

\tcbset{colback=green!5!white,colframe=green!75!black,fonttitle=\bfseries, width = 5cm}
\begin{tcolorbox}[title = Third box]


Thank you for your help,

  • 1
    \input{insbox}, or \usepackage{wrapfigure}, or...
    – Skillmon
    Commented May 21, 2022 at 11:15
  • The book has a wonderful and amazing style. How can I view more in detail?
    – karloswitt
    Commented Jan 15, 2023 at 10:34

1 Answer 1


To wrap text around a tcolorbox you can simply put it inside a wrapfigure, using the wrapfig package. To make the tcolorbox smaller than the textwidth, simply use the option width=. Here is an example with a box similar to the yellow in the provided picture:

\usepackage{tikz, adjustbox}
% new packages:

before skip=2mm,after skip=2mm,
attach boxed title to top left={xshift=0cm,yshift*=0mm-\tcboxedtitleheight},
varwidth boxed title*=-3cm,
boxed title style={frame code={
\path[left color=FrameYellow,right color=FrameYellow,
middle color=FrameYellow]
([xshift=-0mm]frame.north west) -- ([xshift=0mm]frame.north east)
[rounded corners=0mm]-- ([xshift=0mm,yshift=0mm]frame.north east)
-- (frame.south east) -- (frame.south west)
-- ([xshift=0mm,yshift=0mm]frame.north west)
[sharp corners]-- cycle;
},interior engine=empty,
  sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
    \path[fill=BgYellow!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
    \path[draw=FrameYellow,shorten <=-0.05mm,shorten >=-0.05mm,color=FrameYellow] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
  drop fuzzy shadow,

Paragraphe de test pour essayer de placer une boîte 

\begin{mybox2}[Third box]


This produces the output: enter image description here

You can change the box to the left side using {L} instead of {R} in \begin{wrapfigure}{R}{0.6\textwidth}(NB make sure the wrapfig is wider than the box!). You can also change the width of the box in the third line in the code (width=0.5\textwidth).

  • Thank you for your answer ! Could you tell me please what is the enhanced environment that you use in the first line of the code ?
    – Waxler
    Commented May 21, 2022 at 17:17
  • From the package documentation: "[Enhanced] translates the drawing commands of the core package into tikz path commands. Therefore, it allows all tikz high level options for these paths and has more flexibility compared to the standard skin. You pay for this with some prolonged compilation time" (Enhanced is a "skin" that provides "enhanced" features to the box).
    – Vebjorn
    Commented May 21, 2022 at 17:29
  • Is there a way to write the text inside the mybox2 such as it should be justified on the right margin like a standard text ? For instance, if I try to write \begin{wrapfigure}{R}{0.5\textwidth} \begin{mybox2}[Mémo] \lipsum[1-1] \end{mybox2} \end{wrapfigure} the text appears to be "centered". Thank you
    – Waxler
    Commented May 23, 2022 at 10:59
  • Just take away the halign=center in the 4th line (under width).
    – Vebjorn
    Commented May 23, 2022 at 11:32
  • Also, you can see tex.stackexchange.com/questions/644989/…
    – Vebjorn
    Commented May 23, 2022 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .