Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

tcolorbox Manual provides the following example:

enter image description here

Can anybody please suggest me how to create exactly this type of box - The no. of rows to add must be flexible(It seems that tcolorbox has no option other than top & bottom):

enter image description here

share|improve this question
    
mdframed would be my first choice –  cmhughes Aug 21 '12 at 3:24
    
I haven't used <mdframed> package much, but I feel that boxes drawn using <tcolorbox> are more beautiful. –  Sandeep Singh Aug 21 '12 at 3:29
    
@SandeepSingh: Both packages can draw frames. how it looks that is your turn. –  Marco Daniel Aug 21 '12 at 7:27
    
@Marco: Can you please post some example code which shows how to achieve this using tcolorbox? Thanks. –  Sandeep Singh Aug 21 '12 at 7:43
    
Later I can. At the momemnt I have no LaTeX. –  Marco Daniel Aug 21 '12 at 8:09

2 Answers 2

up vote 12 down vote accepted

And here's one possibility using mdframed:

\documentclass{article}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}

\definecolor{mybrown}{RGB}{128,64,0}

\mdfdefinestyle{mystyle}{%
linecolor=mybrown,outerlinewidth=1pt,%
frametitlerule=true,frametitlefont=\sffamily\bfseries\color{white},%
frametitlerulewidth=1pt,frametitlerulecolor=mybrown,%
frametitlebackgroundcolor=mybrown,
backgroundcolor=mybrown!05,
innertopmargin=\topskip,
roundcorner=5pt
}
\mdtheorem[style=mystyle]{example}{Example}

\gdef\Sepline{%
  \par\noindent\makebox[\linewidth][l]{%
  \hspace*{-\mdflength{innerleftmargin}}%
   \tikz\draw[thick,dashed,gray!60] (0,0) --%
        (\textwidth+\the\mdflength{innerleftmargin}+\the\mdflength{innerrightmargin},0);
  }\par\nobreak}


\begin{document}

\begin{example}[The Title]
The contents of the first part.
\Sepline
\noindent The contents of the second part.
\Sepline
\noindent The contents of the third part.
\Sepline
\noindent The contents of the fourth part.
\end{example}

\end{document}

enter image description here

Here's now a modification not using a theorem-like structure, but a simple environment with a mandatory argument to provide a title:

\documentclass{article}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}

\definecolor{mybrown}{RGB}{128,64,0}

\mdfdefinestyle{mystyle}{%
linecolor=mybrown,outerlinewidth=1pt,%
frametitlerule=true,frametitlefont=\sffamily\bfseries\color{white},%
frametitlerulewidth=1pt,frametitlerulecolor=mybrown,%
frametitlebackgroundcolor=mybrown,
backgroundcolor=mybrown!05,
innertopmargin=\topskip,
roundcorner=5pt
}
\newmdenv[style=mystyle]{exa}
\newenvironment{example}[1]
  {\begin{exa}[frametitle=#1]}
  {\end{exa}}

\gdef\Sepline{%
  \par\noindent\makebox[\linewidth][l]{%
  \hspace*{-\mdflength{innerleftmargin}}%
   \tikz\draw[thick,dashed,gray!60] (0,0) --%
        (\textwidth+\the\mdflength{innerleftmargin}+\the\mdflength{innerrightmargin},0);
  }\par\nobreak}

\begin{document}

\begin{example}{The Title}
The contents of the first part.
\Sepline
\noindent The contents of the second part.
\Sepline
\noindent The contents of the third part.
\Sepline
\noindent The contents of the fourth part.
\end{example}

\end{document}

enter image description here

share|improve this answer
    
I don't want "Example 1:" To be displayed as the title. I just want my own title here. Can you please suggest the necessary change in the above code to achieve this? Thanks. –  bill joy Aug 31 '12 at 8:54
1  
@billjoy please see my updated answer. –  Gonzalo Medina Aug 31 '12 at 13:17
    
Thanks a lot for the updated code. –  bill joy Aug 31 '12 at 14:40

tcolorbox doesn't provide code to add more than one lower part. But you could add additional lines:

\documentclass{report}

\usepackage{tikz,tcolorbox}


\begin{document}
\makeatletter

\begin{tcolorbox}[colback=red!5,colframe=red!75!black,title=My nice heading]
This is another \textbf{tcolorbox}.
\tcblower
Here, you see the lower part of the box.

\makeatletter
\begin{tikzpicture}
\path[use as bounding box] (0,0) -- (\linewidth,0);
\draw[color=red!75!black,dashed,dash phase=2pt]
      (0-\kvtcb@leftlower-\kvtcb@boxsep,0)--
      (\linewidth+\kvtcb@rightlower+\kvtcb@boxsep,0);
\end{tikzpicture}
\makeatother

and some more
\end{tcolorbox}
\end{document}

This yields:

enter image description here

share|improve this answer
    
@ Ulrike: Thanks a lot ! –  Sandeep Singh Aug 21 '12 at 17:05
    
Is there any way to put the following code: "\makeatletter \begin{tikzpicture} \path[use as bounding box] (0,0) -- (\linewidth,0); \draw[color=red!75!black,dashed,dash phase=2pt] (0-\kvtcb@leftlower-\kvtcb@boxsep,0)-- (\linewidth+\kvtcb@rightlower+\kvtcb@boxsep,0); \end{tikzpicture} \makeatother" into a single command so that multiple rows can be added just by adding a single line, like: /newcommand ? I tried putting them into a single block using "\newcommand" but getting errors. –  Sandeep Singh Aug 22 '12 at 3:54
    
You must put the \makeatletter before the \newcommand, (and the \makeatother after the closing brace). –  Ulrike Fischer Aug 22 '12 at 7:40
    
I am facing problem. My code: \makeatother \newcommand {\mybox}{% \begin{tikzpicture}% \path[use as bounding box] (0,0) -- (\linewidth,0);% \draw[color=red!75!black,dashed,dash phase=2pt]% (0-\kvtcb@leftlower-\kvtcb@boxsep,0)--% (\linewidth+\kvtcb@rightlower+\kvtcb@boxsep,0);% \end{tikzpicture}% } \makeatletter \begin{document} \makeatletter \begin{tcolorbox}[colback=red!5,colframe=red!75!black,title=My nice heading] This is another \textbf{tcolorbox}. \tcblower Here, you see the lower part of the box. \mybox and some more \mybox and even more \end{tcolorbox} \end{document} –  Sandeep Singh Sep 1 '12 at 7:50
    
:@Ulrike:My box display is not proper. Can you please help me correct the above code. –  Sandeep Singh Sep 1 '12 at 7:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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