# How to draw the following box using TikZ?

How to draw the following boxes using TikZ?

EDIT (22.09.)

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. I just downvoted your question as it shows no research effort. Have a look at the tikz-documentation, there is a tutorial in there. –  Johannes_B Sep 7 '14 at 17:25
I don't think downvoting and voting to close the first question of a new user within 15 minutes is very welcoming and certainly not within the spirit of this site. Eliezer, it would be good if you could edit your question to include some more details on what you've tried already to solve the problem yourself. Have you found any similar questions or examples on this or other sites? If yes, can you explain why they don't work for you? –  Jake Sep 7 '14 at 17:35
@Jake You are right, it's a bit harsh. Downvote retracted. <- i can't untill the next edit. –  Johannes_B Sep 7 '14 at 17:37
Editing the question to have something different is certainly bad as it seems the existing answers completely failed to reproduce the uploaded picture. It would have been certainly better to add the new picture to the existing one. –  Claudio Fiandrino Sep 23 '14 at 6:52
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Martin Schröder Oct 11 '14 at 23:34

no need for tikZ it can be done with simple LaTeX commands:

\documentclass{article}
\usepackage{tabularx}
\usepackage{xcolor}
\newcounter{tema}
\newenvironment{Tema}
{\par\noindent\refstepcounter{tema}\color{blue!80!black!40}\fboxrule=2pt
\fbox{\color{black}\bfseries Tema \thetema}\\[-1pt]% interlineskip
\color{black}\tabularx{\linewidth}
{!{\kern1em\color{blue!80!black!40}\vrule width 2pt}X @{}}~\\[-0.5\normalbaselineskip]}
{\endtabularx\par\bigskip}
\begin{document}
\begin{Tema}
Prominent think tanks, nonprofits known for their impartiality, have
received millions of dollars from foreign governments while pushing U.S.
officials to adopt policies that often reflect the donors’ priorities, an
investigation by The New York Times has found.\label{no1}
\end{Tema}

\begin{Tema}
Hundreds of people gathered in Manhattan to say goodbye to Joan Rivers,
who once wrote of the funeral she wanted: a huge showbiz affair with
lights, cameras, action''
\end{Tema}

\begin{Tema}
foo bar baz
\end{Tema}

As said in the New York Times (Tema~\ref{no1}) \ldots
\end{document}


And the same for a longtable:

[...]
\usepackage{longtable}
\newcounter{tema}
\newenvironment{Tema}
{\par\noindent\refstepcounter{tema}\color{blue!80!black!40}\fboxrule=2pt
\fbox{\color{black}\bfseries Tema \thetema}\\[\dimexpr-1pt-1.5\bigskipamount]
\color{black}\longtable
{!{\kern1em\color{blue!80!black!40}\vrule width 2pt}p{\dimexpr\linewidth-2pt-1em-\tabcolsep} @{}}~\\[-0.5\normalbaselineskip]
}
{\endlongtable\par}
[...]

-
@ Herbert: If you load ltablex instead of tabularx, it can break across pages –  Bernard Sep 7 '14 at 19:42
I suppose that you didn't try it?? –  Herbert Sep 7 '14 at 19:54
Right. I just don't see why it wouldn't work… –  Bernard Sep 7 '14 at 19:56
ltablex redefines \TX@endtabularx. It needs some more modification, loading ltablex is not enough. However, using longtable and a p column should be possible if pagebreaks are needed. –  Herbert Sep 7 '14 at 20:17

Another option is tcolorbox which offers auto counter, flexible frame definition and handles pagebreaks:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}

\newtcolorbox[auto counter]{tema}[1][]{colback=white, colframe=white,
coltitle=black,
title={\textsc{Tema}}~\thetcbcounter,#1,
enhanced,
breakable,
title code={%
\draw[very thick,blue!50!cyan!80!black]
(title.south west) rectangle
($(title.north west)!0.375!(title.north)$);%
},
interior titled code={%
\draw[very thick,blue!50!cyan!80!black]
([xshift=7pt]interior.north west) rectangle
([xshift=7pt]interior.south west);%
}
}

\begin{document}

\begin{tema}[label=no1]
Prominent think tanks, nonprofits known for their impartiality, have
received millions of dollars from foreign governments while pushing U.S.
officials to adopt policies that often reflect the donors’ priorities, an
investigation by The New York Times has found.
\end{tema}

\begin{tema}[label=x2]
Hundreds of people gathered in Manhattan to say goodbye to Joan Rivers,
who once wrote of the funeral she wanted: a huge showbiz affair with
lights, cameras, action''
\end{tema}

\begin{tema}
foo bar baz
\end{tema}

As said in the New York Times (Tema~\ref{no1} and Tema~\ref{x2}) \ldots

\end{document}


The result:

I would propose the following minor modifications to improve the overall look:

\newtcolorbox[auto counter]{tema}[1][]{colback=white, colframe=white,
coltitle=black,
title={\textsc{Tema}}~\thetcbcounter,#1,
enhanced,
breakable,
title code={%
\draw[very thick,blue!50!cyan!80!black,
rounded corners, fill=white,
(title.south west) rectangle
($(title.north west)!0.375!(title.north)$);%
},
interior titled code={%
\draw[very thick,blue!50!cyan!80!black]
([xshift=7pt]interior.north west) rectangle
([xshift=7pt]interior.south west);%
}
}


which provides:

To get the new shape, without loading the shapes.callout library, one can do:

\newtcolorbox[auto counter]{tema}[1][]{colback=white, colframe=white,
coltitle=black,
title={\textsc{Tema}}~\thetcbcounter,#1,
enhanced,
breakable,
title code={%
\draw[very thick,blue!50!cyan!80!black]
(title.south west) |-
($(title.north west)!0.375!(title.north)$)--
($(title.south west)!0.375!(title.south)$)--++
(-0.45em,0)--++
(-115:2mm)--++
(125:2mm)--cycle
;%
},
interior titled code={%
\draw[very thick,blue!50!cyan!80!black]
([xshift=7pt]interior.north west) rectangle
([xshift=7pt]interior.south west);%
}
}


The result:

-

Another variant with tcolorbox with call outs:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usetikzlibrary{shapes.callouts}
\tikzset{note/.style={rectangle callout,fill=#1}}
\newtcolorbox[auto counter]{mybox}[1][]{
colback=white,
left=0.5ex,
top=1ex,
right=0.5ex,
bottom=0ex,
arc=0pt,
outer arc=0pt,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
nobeforeafter,
enhanced jigsaw,
overlay={
\node[note=white,callout  absolute pointer={([shift={(0.75in,-1ex)}]frame.north west)},callout pointer width=0.5cm,draw,line width=1pt,anchor=south west,align=center,minimum width=1in]
at ([shift={(-2ex,0ex)}]frame.north west) {Tema~\thetcbcounter};
},
before=\vspace*{2em}\noindent,
#1
}

\begin{document}
\begin{mybox}[label=no1]
This is some thing This is some thing This is some thing This is some thing This is
some thing This is some thing This is some thing This is some thing This is some
thing
\end{mybox}
\begin{mybox}[label=no2]
This is some thing This is some thing This is some thing This is some thing This is
some thing This is some thing This is some thing This is some thing This is some
thing
\end{mybox}
\end{document}


-

Here is a way that allows for page breaks, based on the ntheorem and the framed packages. I define the Tema environment as a patched leftbar environment (from framed) nested in a theme theorem, defined as a framed-break theorem style theorem. This style is a modification of the standard break style so as to have a framed label, of a special type that lines up with the left bar.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe, no marginpar]{geometry}
\usepackage{amssymb, amsfonts, amsmath}
\usepackage[x11names]{xcolor}
\usepackage{framed}
\usepackage{etoolbox}
\usepackage[framed]{ntheorem}

\usepackage{lipsum}

\colorlet{framecolour}{DeepSkyBlue3}
\colorlet{bgcolour}{SlateGray1!20!}
\colorlet{titlecolour}{Tomato3}

\makeatletter
\newtheoremstyle{framedbreak}%
##1\ ##2\theorem@separator}}}}\hskip 1em \hbox{\smash{\color{framecolour}\rule[\dimexpr-1cm-\FrameSep+2\fboxrule \relax]{2pt}{1cm}}}}]\leavevmode}%
##1\ ##2\ (##3)\theorem@separator}}}}\hskip 1em \hbox{\smash{\color{framecolour}\rule[\dimexpr-1cm-\FrameSep+\fboxrule \relax]{2pt}{1cm}}}}]\leavevmode}%
\makeatother
\parindent = 0pt
\setlength\fboxrule{2pt}

\theorempreskip{\bigskipamount}
\theorempostskip{\bigskipamount}
\theoremstyle{framedbreak}
\theorembodyfont{\upshape}
\newtheorem{theme}{Tema}

\renewenvironment{leftbar}{%
\def\FrameCommand{\hskip 1em{\color{framecolour}\vrule width 2pt} \hspace{0.333em}}%
{\vskip 0.25ex\endMakeFramed}

\newenvironment{Tema}[1][]{%
\ifblank{#1}{\theme}{\theme[#1]}\leftbar}
{\endleftbar\endtheme}

\begin{document}

\begin{Tema}
Prominent think tanks, nonprofits known for their impartiality, have
received millions of dollars from foreign governments while pushing U.S.
officials to adopt policies that often reflect the donors’ priorities, an
investigation by The New York Times has found.\label{no1}
\end{Tema}

\begin{Tema}
Hundreds of people gathered in Manhattan to say goodbye to Joan Rivers,
who once wrote of the funeral she wanted: a huge showbiz affair with
lights, cameras, action''
\end{Tema}

\begin{Tema}[A Trial]
Prominent think tanks, nonprofits known for their impartiality, have received millions of dollars from foreign governments while pushing U.S. officials to adopt policies that often reflect the donors’ priorities, aninvestigation by The New York Times has found.
\end{Tema}

\lipsum[2]
\begin{Tema}%
\lipsum[1-4]
\end{Tema}

\end{document}


-