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.

How to draw the following boxes using TikZ?

enter image description here

EDIT (22.09.) enter image description here

share|improve this question
3  
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 at 17:25
11  
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 at 17:35
1  
@Jake You are right, it's a bit harsh. Downvote retracted. <- i can't untill the next edit. –  Johannes_B Sep 7 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 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 at 23:34

4 Answers 4

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} 

enter image description here

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}
[...]
share|improve this answer
1  
@ Herbert: If you load ltablex instead of tabularx, it can break across pages –  Bernard Sep 7 at 19:42
1  
I suppose that you didn't try it?? –  Herbert Sep 7 at 19:54
    
Right. I just don't see why it wouldn't work… –  Bernard Sep 7 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 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:

enter image description here

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,
  drop shadow={shadow yshift=-1.5pt,shadow xshift=1.5pt}] % <= load in the preamble \usetikzlibrary{shadows}
  (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:

enter image description here

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:

enter image description here

share|improve this answer

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}

enter image description here

share|improve this answer

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}%
  {\item[\rlap{\vbox{\hbox{\hskip\dimexpr\labelsep-\theoremindent\relax\rlap{\fcolorbox{framecolour}{bgcolour}{\color{titlecolour}\theorem@headerfont
          ##1\ ##2\theorem@separator}}}}\hskip 1em \hbox{\smash{\color{framecolour}\rule[\dimexpr-1cm-\FrameSep+2\fboxrule \relax]{2pt}{1cm}}}}]\leavevmode}%
    {\item[\rlap{\vbox{\hbox{\hskip\dimexpr\labelsep-\theoremindent\relax\rlap{\fcolorbox{framecolour}{bgcolour}{\color{titlecolour}\theorem@headerfont
          ##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}}%
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%
 {\vskip 0.25ex\endMakeFramed}
%\setlength\FrameHeightAdjust{1cm}

\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} 

enter image description here

enter image description here

share|improve this answer

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.