4

I want to create a minipage like the one shown in the picture. Any ideas how to do it? Thanks! enter image description here

  • You might want to look at mdframed or the newer (and possibly better) tcolorbox. – Manuel Jul 23 '14 at 16:05
  • @Manuel: I'm using \documentclass{book}, can I use them? Could you give me a simple example? – LatexQuest Jul 23 '14 at 16:07
  • Yes, they are packages. Look for the documentation (texdoc, or may be google) or even in this site. – Manuel Jul 23 '14 at 16:10
8

Here's one possibility admitting page breaks using tcolorbox:

\documentclass{article}
\usepackage[skins,many]{tcolorbox}
\usepackage{lipsum}

\definecolor{myblue}{RGB}{32,92,195}

\newtcolorbox{mybox}[1]{
   freelance,
   breakable,
   title=#1,
   left=0pt,
   right=0pt,
   width=.9\textwidth,
   enlarge left by=.1\textwidth,
   coltitle=black,
   frame code={},
   interior titled code={
     \draw[myblue,ultra thick] 
       ([yshift=5pt]frame.south west) |- ([xshift=60pt,yshift=-4pt]title.south west);
   }
}

\begin{document}

\lipsum[4]
\begin{mybox}{The title}
\lipsum[4]
\end{mybox}
\lipsum[4]

\end{document}

enter image description here

And with mdframed:

  • Very nice, I like it! But, I would like to push the box a bit to the right, similar to a minipage that extends for instance 0.9\text width. Besides, I also like to modify the distance between where the text starts and the vertical line. Is that using "[xshift=60pt,yshift=-4pt]"? – LatexQuest Jul 23 '14 at 16:29
  • @LatexQuest Please see my updated answer. The relevant keys are left, right, width and enlarge left by. – Gonzalo Medina Jul 23 '14 at 16:47
  • @LatexQuest do you want the length of the horizontal line to automatically adapt to the length of the title? – Gonzalo Medina Jul 24 '14 at 14:10
  • thanks a lot. The one Herbert suggested is working that way. – LatexQuest Jul 24 '14 at 14:25
3

A solution with a tabular:

%\PassOptionsToPackage{table}{xcolor}%% maybe needed if you have a special class
\documentclass{article}
\usepackage[table]{xcolor}%%% Delete it if your special class alread loads it
\usepackage{tabularx,booktabs}
\usepackage{blindtext}    
\definecolor{myblue}{RGB}{32,92,195}
\newenvironment{mybox}[1]
  {\par\medskip\noindent\arrayrulewidth=2pt\arrayrulecolor{myblue}%
   \hfill\tabularx{0.8\linewidth}{!{\color{myblue}\vrule width 2pt} X @{}}
   \multicolumn{1}{@{}l}{\tabular{@{}l}\kern\tabcolsep\textbf{#1}\\\hline\endtabular}\\}
  {\endtabularx\par\medskip}
\begin{document}

\begin{mybox}{The title with some more text in the title}
Onyl some text here
\end{mybox}

\blindtext

\begin{mybox}{The title}
\blindtext
\end{mybox}

\blindtext

\end{document}

enter image description here

  • Thanks, exactly what I want. It works perfectly when I run it separately but when I add it to my document, it returns this error => Option clash for package xcolor. Next line complains about => \usepackage{tabularx,booktabs}. – LatexQuest Jul 24 '14 at 8:20
  • The package xcolor is already loaded by you. Write just before the documentclass \PassOptionsToPackage{table}{xcolor} and then delete the line \usepackage[table]{xcolor}. See my edited answer – user2478 Jul 24 '14 at 8:37
  • I did it, but I get some other weird problem. It says no room for a new dim check .... looks like the problem returns to many packages I have ... or a conflict :( – LatexQuest Jul 24 '14 at 8:54
  • \usepackage{etex} will help – user2478 Jul 24 '14 at 8:59
  • could you please check my related question here=> tex.stackexchange.com/questions/194118/… – LatexQuest Jul 31 '14 at 10:19

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.