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.

Here is the specs of the box.

  1. Color of the bar rule should be:

    \definecolor{mycolor}{rgb}{0.122, 0.435, 0.698}
    
  2. Radius of the 4 corners of the box: 4pt

  3. Thick line = 0.5pt
  4. Text should be 6pt indention on all sides
share|improve this question
add comment

3 Answers

up vote 14 down vote accepted

Have a look at the mdframed package:

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

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

\newmdenv[innerlinewidth=0.5pt, roundcorner=4pt,linecolor=mycolor,innerleftmargin=6pt,
innerrightmargin=6pt,innertopmargin=6pt,innerbottommargin=6pt]{mybox}

\begin{document}

\lipsum[2]
\begin{mybox}
\lipsum[4]
\end{mybox}
\lipsum[2]

\end{document}

enter image description here

share|improve this answer
add comment

The tcolorbox package does a beautiful job of setting coloured boxes:

enter image description here

\documentclass{article}
\usepackage{tcolorbox}% http://ctan.org/pkg/tcolorbox
\definecolor{mycolor}{rgb}{0.122, 0.435, 0.698}% Rule colour
\makeatletter
\newcommand{\mybox}[1]{%
  \setbox0=\hbox{#1}%
  \setlength{\@tempdima}{\dimexpr\wd0+13pt}%
  \begin{tcolorbox}[colframe=mycolor,boxrule=0.5pt,arc=4pt,
      left=6pt,right=6pt,top=6pt,bottom=6pt,boxsep=0pt,width=\@tempdima]
    #1
  \end{tcolorbox}
}
\makeatother
\begin{document}
\mybox{Here is some fancy box text.}
\end{document}

The tcolorbox options are:

  1. color=mycolor
  2. arc=4pt
  3. boxrule=0.5pt
  4. left=6pt, right=6pt, top=6pt, bottom=6pt

The macro \mybox will always set the box on a single line. If you want more than one line, some changes are required. To remove the background colour, add the option colback=white.

share|improve this answer
    
Hi Werner, Do you know how to fix this? Runaway argument? { title/.store in=\kvtcb@title , notitle/.style={title=}, adjusted ti\ETC. ! Paragraph ended before \pgfkeys@@qset was complete. <to be read again> \par l.87 parskip/.style={before={\par \pagebreak[0]\noindent},after={\par}}, ? –  jeecabz Aug 7 '12 at 5:53
    
@jee-ar: What code caused this? Are you adding a title to tcolorbox? –  Werner Aug 7 '12 at 14:14
    
@ werner: no, this is the error comes out when I try to use your given code/tag. –  jeecabz Aug 8 '12 at 3:56
    
@jee-ar: You need to embrace the \mybox command with \makeatletter ... \makeatother. –  Werner Aug 8 '12 at 4:22
    
@ werner: thanks. It is now working. I just modify the tcoolbox package. But If I want to include section, subsection, paragraph - It does not work. –  jeecabz Aug 8 '12 at 5:35
show 1 more comment

Since version 2.02 (2013/03/13), the package tcolorbox contains the \tcbox and \newtcbox (version 2.22) macros which allow to give an alternative answer. I also added some text around the box example to demonstrate the usage of the option tcbox raise base.

\documentclass{article}
\usepackage{tcolorbox}
\definecolor{mycolor}{rgb}{0.122, 0.435, 0.698}

\newtcbox{\mybox}{nobeforeafter,colframe=mycolor,colback=mycolor!10!white,boxrule=0.5pt,arc=4pt,
  boxsep=0pt,left=6pt,right=6pt,top=6pt,bottom=6pt,tcbox raise base}

\begin{document}
Some text. \mybox{Here is some fancy box text.} More text.
\end{document}

enter image description here

share|improve this answer
1  
I had to add the options nobeforeafter to get the box inline like your picture. –  Nate Glenn Jul 8 '13 at 5:41
    
@NateGlenn Thank you for this hint! The version I used had a bug which is eliminated now. Therefore, nobeforeafter has to be set. I corrected the the example. Thanks again! :-) –  Thomas F. Sturm Jul 8 '13 at 6:35
    
No problem! Thanks for showing me that this distribution allows inline text boxing. I had been searching for it for a while. –  Nate Glenn Jul 8 '13 at 20:30
add comment

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.