The question is a follow up of the question posted here how to make adjustbox work correctly .

    margin=\fboxsep+.25cm \fboxsep+.2cm,bgcolor=blue!10,frame,center}\bgroup
 { \bf{Box 1: My caption here}}\\
\tikz \draw[line width=.1cm, red] (0,0) -- (\linewidth,0);

This is rendered as follows: enter image description here

If it is not an overkill then is it possible that Box 1 becomes the label and the text following it is the caption.

  • Could you clarify what is meant by "label" and "caption". From the laymen's point of view, they may be indistinguishable.
    – Werner
    Commented May 27, 2014 at 4:21
  • Sure. In my mind Box 1 is the label and the text "my caption here" is the caption. Typical usage for me would be as follows: Box~\ref{boxlabel} defines all the terminologies used in this paper''. Latex would translate this to Box 1 defines all terminologies...''. Thanks for your attention.
    – Kabira K
    Commented May 27, 2014 at 4:26

1 Answer 1


Since you are constructing a titled colored box, I would suggest to consider the packages mdframed or tcolorbox for your task.

The following example code uses tcolorbox version 3.04 (2014/05/18). An automatically numbered bluebox is contructed which includes the wrapfigure and takes 4 parameters described in the following code.

For easy references, the cleveref package is also included which defines the \Cref macro used in the example.

\usepackage[skins,xparse]{tcolorbox}% version 3.04

% optional  #1: width of the box
% optional  #2: further tcolorbox options
% mandatory #3: title (caption text)
% mandatory #4: label of the box
\NewTColorBox[auto counter,
    Crefname={Box}{Boxes},crefname={box}{boxes}]% <-- replace with your boxname
  {bluebox}{ O{3.00in} O{} m m }{%
  colframe=blue!10!white,interior hidden,coltitle=black,fonttitle=\bfseries,
  title code={\draw[line width=.1cm,red,shorten <=0.25cm+3pt,shorten >=0.25cm+3pt]
    (title.south west)--(title.south east);},
  borderline={0.4pt}{0pt}{black,sharp corners},
  title={Box~\thetcbcounter: #3},label={#4},#2}

Box~\ref{boxlabel} defines all the terminologies used in this paper.

\Cref{boxlabel} defines all the terminologies used in this paper.

\begin{bluebox}{My caption here}{boxlabel}

enter image description here

You must log in to answer this question.

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