5

using the TikZ package to create a style for book sections like the image below?

enter image description here

cfr
  • 198,882

1 Answers1

14

I believe I got a somewhat more organized.

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,calc}
\usetikzlibrary{positioning,calc}
\usepackage{lipsum}
\usepackage[hmargin=0.5in,bmargin=1in,tmargin=1in,centering]{geometry}

\definecolor{cor1}{HTML}{57C3CF}
\definecolor{cor2}{HTML}{4EA8B1}


\newcommand\SecTitle[4]{%
\begin{tikzpicture}

    \node (A) [rectangle,minimum width=\textwidth, minimum height=1cm,color=white,fill=cor2, text width=\textwidth-3cm,align=left] {\hspace{1.5cm}\parbox{\textwidth}{\huge\textbf{\textsf{#4}}}};
    \fill[fill=cor1] (A.north west) -- ($(A.north west)+(1.5cm,0)$) -- ($0.5*(A.north west)-0.5*(A.north west)-(0.5*\textwidth-2.5cm,0)$)--($(A.south west)+(1.5cm,0)$)--(A.south west);
    \node [color=white](A.north west) at ($0.5*(A.north west)-0.5*(A.north west)-(0.5*\textwidth-1cm,0)$) {\Huge\textbf{\textsf{\thesection}}};

\end{tikzpicture}

}
\titleformat{\section}
{\normalfont}{}{0em}
{\SecTitle{east}{west}{0\paperwidth}{#1}}

\begin{document}

\chapter{Teste}

\section{Test Section One}
\lipsum[2]
\section{Test Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Tt Section Two}
\lipsum[2]
\clearpage
\section{Test Section Three}
\lipsum[2]
\section{Test Section Four}
\lipsum[2]

\end{document}

enter image description here

Arzigoglu
  • 1,348