6

I have a box for tips, but I would like to have a pattern surrounding it like in the example picture.

Example

Thank you for your help!

\documentclass[ngerman]{scrbook}
\usepackage{fontspec}
\usepackage{babel}
\usepackage{tabularx,colortbl,multirow,dcolumn}
    \renewcommand\tabularxcolumn[1]{b{#1}}
\usepackage{xcolor}
\usepackage{calc}
\usepackage{titletoc,titlesec,enumitem}



\newenvironment{Test}{
\begin{center}
\begin{sffamily}
\setlength\arrayrulewidth{0.75pt}\arrayrulecolor{white}
\renewcommand{\arraystretch}{1.3}
    \begin{tabular}[h!]{p{\textwidth-2\tabcolsep}}
    \rowcolor[gray]{0.6} \textbf{{\color{white}Testbox}} \\
    \hline
    \rowcolor[gray]{0.90} }
    {\\ 
    \end{tabular}
\end{sffamily}
\end{center}
}

\begin{document}

\begin{Test}
Content
\end{Test}

\end{document}
David Carlisle
  • 757,742

2 Answers2

8

A possible solution with tcolorbox (it should accomplish all the requests, see the comments in the code):

\documentclass[ngerman]{scrbook}
\usepackage{babel}

\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{decorations.shapes,shapes.geometric,backgrounds}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\newtcolorbox{Test}[1][Testbox]{
  title=Testbox,
  colback=gray!20,
  coltitle=white,
  fonttitle=\bfseries\sffamily,
  fontupper=\sffamily,
  left=1pt, % left space between content text and box
  lefttitle=1pt, % left space between 
  outer arc=0pt,
  boxrule=0pt,
  skin=freelance,
  title engine=path, 
  title style={fill=gray!70,text=white},
  frame code={
    \begin{pgfonlayer}{foreground}
      \draw[white,ultra thick]
          (interior.north east)--(interior.north west); % white line between title and content
      \draw[decorate,
           decoration={shape backgrounds,
                      shape=diamond,
                      shape size=1.75mm, % 
                      shape sep={2mm,between centers}}, % adjust the separation between diamonds
           fill=white]
           (frame.south west) rectangle (frame.north east);
    \end{pgfonlayer}
  },
}

\begin{document}

\begin{Test}
This is some content

\begin{center} % center part of the content
This is some content
\end{center}

This is some content
\end{Test}

\end{document}

The result:

enter image description here

I suggest you to refer to the package documentation for more insights about the various options that the packages provide.

  • Thank you very much, but there are still some smaller things, which I did not achieve. – user36464 Sep 10 '13 at 17:04
  • @user36464: you're welcome. As a new user, I would courteously suggest for the future to upvote all answers you find useful, including those to others' questions and to check/accept the best answers to your own questions by clicking the green tick on the left-hand side of the answer. – Claudio Fiandrino Sep 12 '13 at 06:28
4

This could be a job for the niceframe package:

MWE

\documentclass{article}
\usepackage{niceframe}

% Defining some dummy text 
\newcommand\dummytext{
\begin{minipage}{.85\textwidth}
{\bfseries\large Moral principles types:}
\begin{itemize}
    \item Categoric Imperative (Inmmanuel Kant).
    \item Do not worry about justice, but act and words to justify your action will come to you afterward ( Niccol\`o Machiavelli)
    \item Those are my principles, and if you don't like them... well, I have others (Groucho Marx).    
    \end{itemize}
\end{minipage}
}

% A general nice frame (see "texdoc niceframe")

\newcommand{\marco}[1]{
\font\border=umrandb
\generalframe
{\border \char5} % up left
{\border \char1} % top
{\border \char4} % up rigth 
{\border \char2} % izq 
{\border \char0} % dcha
{\border \char6} % down left
{\border \char3} % bottom
{\border \char7} % down rigth
{#1}
}

\begin{document}
\marco{\dummytext}
\end{document}
Fran
  • 80,769